Skip to content

Commit e581555

Browse files
TheSentinel454claudebrow
authored
perf(relay): serve named-only channel access from the access caches (#9735)
## What REQ, COUNT, `POST /query` and `POST /count` now take a reader's named-only channel access (system channels, and any type added later) from the two access caches they already read. Before, any filter that opted in to system channels, or named a channel outside the implicit set, ran `get_readable_named_only_channels` on the writer, uncached, on every request. ## Why Clients send such a filter on every connect. buzz-app's system channel discovery reads `{kinds:[39002], "#p":[me], "#t":["system"]}`. So a fleet reconnect (rollout, relay restart, network blip) paid one extra uncached writer read per client, on top of the cached access set. This read showed up near the top of writer SQL during reconnect herds. ## How - `get_member_channels_read_at` and `get_listed_open_channels_read_at` (buzz-db) return every channel type, with their connection checkout time, and split rows into the implicit set (legacy types) and the named-only set, with the type. They are the same two queries as before, without the type filter. `get_member_channel_ids` and `get_listed_open_channel_ids` keep their results. - With no names, the two named-only halves together are exactly what `get_readable_named_only_channels` returns. A new Postgres test pins that equality for a member and a non-member. - `AppState::get_channel_access_cached` returns a `ChannelAccess` from the member cache (per pubkey, 10 s, dropped on every membership write) and the open cache (1 s, shared reads). It yields the named-only channels on demand, so a request that uses only the implicit set does no extra work. `get_accessible_channel_ids_cached` is now a wrapper around it. - Both caches' refills are fenced against invalidation by a small shared `LoadFence` (new `load_fence.rs`), as `MembershipCache` does. Overlapping misses for a key share one load token, so the first read to finish publishes. Invalidation drops the token, and a read publishes only while its token is current. Before, a read that began before a removal (or an open-to-private change) could finish after it and cache the old set. That race also affected private stream/forum channels. - The member snapshot is dated from its read's connection checkout, like the open set, and a hit older than `MEMBER_CHANNELS_MAX_AGE` (10 s) reads again. Before, its 10 s started at insert, so a slow read stretched the bound. - `readable_named_only_channels_for_filters` uses the cached set when every channel the request names outside the implicit set is in it. The system opt-in needs exactly that set. When a request names any other channel (an unlisted open channel, or one it can't read), it keeps the uncached read, unchanged. - A `"consistency": "strong"` `POST /query` takes its named-only access from the database, so a client that just created a system channel finds it even on a pod that has not yet seen the invalidation. REQ, COUNT and `POST /count` keep the cache. - The thread-window and workflow checks keep the uncached read. ## Staleness Same as the implicit set's today. Every membership write (`invalidate_membership`) drops the per-pubkey entry, whatever the channel type, and the drop is sent to every pod. On the pod that ran the removal, the next request sees it (the refill fence closes the race). A missed cross-pod drop keeps a removed member's system channel for up to 10 s after the read began on that pod, as for a private channel. The open half is used for 1 s. ## What got simpler No new access cache and no new invalidation trigger. The named-only access now comes from the same snapshot as the implicit set, so REQ no longer mixes a cached implicit set with an uncached named-only set. `get_member_channel_ids` and `get_listed_open_channel_ids` no longer have their own SQL, and their unused `Db` wrappers are gone. The two replacement reads keep the old span names (`get_member_channel_ids`, `get_listed_open_channel_ids`). ## Tests - `handlers::system_channels::tests::cached_access_answers_named_only_needs_without_a_database_read` (unit, unreachable DB): discovery and a cached `#h` name are answered with no read, the token scope still narrows the result, and a name outside the cached sets reads the database. - `store::unlisted_channels_postgres_tests::cached_channel_sets_match_the_uncached_named_only_read` (Postgres): the cached halves equal the uncached read and the accessible set. - `state::tests::a_member_read_that_straddles_an_invalidation_is_not_cached` (unit): a read held open through a per-user or a community-wide invalidation answers its own request but is not cached. - `state::tests::an_open_read_that_straddles_an_invalidation_is_not_cached` (unit): an open-set read held open through the community's invalidation answers its own request, and the next request reads again. - `state::tests::a_member_snapshot_ages_from_its_read_not_its_insert` (unit): a member snapshot already 10 s old when published is not served. - `state::tests::overlapping_member_reads_cache_the_first_to_finish` (unit): a second miss that starts while the first read is in flight does not stop the first from being cached. - `handlers::system_channel_postgres_tests::a_strong_query_sees_a_just_created_system_channel_past_a_stale_cache` (Postgres): a strong `/query` finds a just-created system channel past a stale member entry. - `handlers::system_channel_postgres_tests::a_token_scope_narrows_system_channels_on_both_access_paths` (Postgres): token-scoped WS REQ and COUNT, through the cache path and the database path. - Must-fail mutants: always take the database branch; keep only legacy types in the member query; drop the token scope at the REQ call site; publish without the fence check; drop the open-set token on invalidation; ignore the member snapshot's checkout age. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Luke Tornquist <tornquist@squareup.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz>
1 parent 9bc5740 commit e581555

13 files changed

Lines changed: 1112 additions & 150 deletions

File tree

‎Justfile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,12 @@ test-unit:
661661
cargo nextest run -p buzz-relay --lib -E 'test(/^concurrency_limits::tests::/) + test(/^feature_flags::tests::/) + test(=handlers::auth::tests::auth_cap_sheds_a_verified_login_with_a_bare_close)'
662662
# Relay read caches: the admitted-connection index, the shared-read
663663
# gates (open set, restriction, tenant host), the community-active
664-
# cache, tenant host cache, the
664+
# cache, tenant host cache, the access caches' refill fences and
665+
# member snapshot age, the
665666
# overlong-host rejection and the ban disconnect's restriction-cache
666667
# drop. Infra-free; the
667668
# database URL refuses at once. Keep scripts/run-tests.sh in step.
668-
cargo nextest run -p buzz-relay --lib -E 'test(=state::tests::admitted_index_follows_every_key_change) + test(/^shared_reads::tests::/) + test(/^membership_cache::tests::/) + test(/^community_active::tests::/) + test(=state::tests::concurrent_open_channel_misses_share_the_in_flight_read) + test(=state::tests::concurrent_restriction_and_host_misses_share_the_in_flight_read) + test(=tenant::tests::app_state_resolver_serves_fresh_cached_hosts_only) + test(=tenant::tests::an_overlong_host_fails_closed_before_the_resolver) + test(=state::tests::disconnect_drops_the_cached_restriction_row)'
669+
cargo nextest run -p buzz-relay --lib -E 'test(=state::tests::admitted_index_follows_every_key_change) + test(/^shared_reads::tests::/) + test(/^membership_cache::tests::/) + test(/^community_active::tests::/) + test(=state::tests::concurrent_open_channel_misses_share_the_in_flight_read) + test(=state::tests::a_member_read_that_straddles_an_invalidation_is_not_cached) + test(=state::tests::a_member_snapshot_ages_from_its_read_not_its_insert) + test(=state::tests::overlapping_member_reads_cache_the_first_to_finish) + test(=state::tests::an_open_read_that_straddles_an_invalidation_is_not_cached) + test(=state::tests::concurrent_restriction_and_host_misses_share_the_in_flight_read) + test(=tenant::tests::app_state_resolver_serves_fresh_cached_hosts_only) + test(=tenant::tests::an_overlong_host_fails_closed_before_the_resolver) + test(=state::tests::disconnect_drops_the_cached_restriction_row)'
669670
# Retain partially consumed mesh receives across housekeeping ticks.
670671
cargo nextest run -p buzz-relay --lib -E 'test(=mesh_boot::tests::demo_echo_retains_pending_receive_across_housekeeping_ticks)'
671672
# boot_lifecycle spawns the real relay binary and asserts its startup

‎crates/buzz-db/src/store/channel_members.rs‎

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,35 +1696,75 @@ pub async fn get_accessible_channel_ids(
16961696
Ok(ids)
16971697
}
16981698

1699+
/// Channel IDs split by how a query reaches them: the legacy-type channels
1700+
/// in its implicit scope, and the named-only channels with their type (see
1701+
/// [`get_readable_named_only_channels`]).
1702+
#[derive(Debug, Clone, Default, PartialEq, Eq)]
1703+
pub struct ChannelSet {
1704+
/// Channels of legacy types ([`buzz_core::channel::LEGACY_CHANNEL_TYPES`]).
1705+
pub implicit: Vec<Uuid>,
1706+
/// Channels of every other type, with the type as text.
1707+
pub named_only: Vec<(Uuid, String)>,
1708+
}
1709+
1710+
impl FromIterator<(Uuid, String)> for ChannelSet {
1711+
fn from_iter<I: IntoIterator<Item = (Uuid, String)>>(rows: I) -> Self {
1712+
let mut set = Self::default();
1713+
for (id, channel_type) in rows {
1714+
if buzz_core::channel::LEGACY_CHANNEL_TYPES.contains(&channel_type.as_str()) {
1715+
set.implicit.push(id);
1716+
} else {
1717+
set.named_only.push((id, channel_type));
1718+
}
1719+
}
1720+
set
1721+
}
1722+
}
1723+
16991724
/// The member half of [`get_accessible_channel_ids`]: legacy-type channels
17001725
/// where the pubkey is an active member.
17011726
pub async fn get_member_channel_ids(
17021727
pool: &PgPool,
17031728
community_id: CommunityId,
17041729
pubkey: &[u8],
17051730
) -> Result<Vec<Uuid>> {
1731+
Ok(get_member_channels_read_at(pool, community_id, pubkey)
1732+
.await?
1733+
.value
1734+
.implicit)
1735+
}
1736+
1737+
/// Every channel where the pubkey is an active member, split by type, with
1738+
/// when its connection was checked out. Its implicit half is
1739+
/// [`get_member_channel_ids`]; its named-only half is the member part of
1740+
/// [`get_readable_named_only_channels`].
1741+
pub async fn get_member_channels_read_at(
1742+
pool: &PgPool,
1743+
community_id: CommunityId,
1744+
pubkey: &[u8],
1745+
) -> Result<ReadAt<ChannelSet>> {
17061746
let mut connection = crate::observability::acquire_writer(
17071747
pool,
17081748
crate::observability::WriterOperation::Authorization,
17091749
)
17101750
.await?;
1711-
let sql = format!(
1751+
let read_at = std::time::Instant::now();
1752+
let rows: Vec<(Uuid, String)> = sqlx::query_as(
17121753
r#"
1713-
SELECT cm.channel_id
1754+
SELECT cm.channel_id, c.channel_type::text
17141755
FROM channel_members cm
17151756
JOIN channels c ON cm.community_id = c.community_id AND cm.channel_id = c.id AND c.deleted_at IS NULL
17161757
WHERE cm.community_id = $1 AND cm.pubkey = $2 AND cm.removed_at IS NULL
1717-
AND {member_types}
17181758
"#,
1719-
member_types = crate::store::channel::legacy_channel_type_sql("c.channel_type"),
1720-
);
1721-
// Built only from the constant type list.
1722-
sqlx::query_scalar(sqlx::AssertSqlSafe(sql))
1723-
.bind(community_id.as_uuid())
1724-
.bind(pubkey)
1725-
.fetch_all(&mut *connection)
1726-
.await
1727-
.map_err(Into::into)
1759+
)
1760+
.bind(community_id.as_uuid())
1761+
.bind(pubkey)
1762+
.fetch_all(&mut *connection)
1763+
.await?;
1764+
Ok(ReadAt {
1765+
value: rows.into_iter().collect(),
1766+
read_at,
1767+
})
17281768
}
17291769

17301770
/// The open half of [`get_accessible_channel_ids`]: listed open channels of
@@ -1733,37 +1773,39 @@ pub async fn get_listed_open_channel_ids(
17331773
pool: &PgPool,
17341774
community_id: CommunityId,
17351775
) -> Result<Vec<Uuid>> {
1736-
Ok(get_listed_open_channel_ids_read_at(pool, community_id)
1776+
Ok(get_listed_open_channels_read_at(pool, community_id)
17371777
.await?
1738-
.value)
1778+
.value
1779+
.implicit)
17391780
}
17401781

1741-
/// [`get_listed_open_channel_ids`], with when its connection was checked out.
1742-
pub async fn get_listed_open_channel_ids_read_at(
1782+
/// Every listed open channel, split by type, with when its connection was
1783+
/// checked out. Its implicit half is [`get_listed_open_channel_ids`]; its
1784+
/// named-only half is the listed part of [`get_readable_named_only_channels`].
1785+
pub async fn get_listed_open_channels_read_at(
17431786
pool: &PgPool,
17441787
community_id: CommunityId,
1745-
) -> Result<ReadAt<Vec<Uuid>>> {
1788+
) -> Result<ReadAt<ChannelSet>> {
17461789
let mut connection = crate::observability::acquire_writer(
17471790
pool,
17481791
crate::observability::WriterOperation::Authorization,
17491792
)
17501793
.await?;
17511794
let read_at = std::time::Instant::now();
1752-
let sql = format!(
1795+
let rows: Vec<(Uuid, String)> = sqlx::query_as(
17531796
r#"
1754-
SELECT id
1797+
SELECT id, channel_type::text
17551798
FROM channels
17561799
WHERE community_id = $1 AND visibility = 'open' AND NOT unlisted AND deleted_at IS NULL
1757-
AND {open_types}
17581800
"#,
1759-
open_types = crate::store::channel::legacy_channel_type_sql("channel_type"),
1760-
);
1761-
// Built only from the constant type list.
1762-
let value = sqlx::query_scalar(sqlx::AssertSqlSafe(sql))
1763-
.bind(community_id.as_uuid())
1764-
.fetch_all(&mut *connection)
1765-
.await?;
1766-
Ok(ReadAt { value, read_at })
1801+
)
1802+
.bind(community_id.as_uuid())
1803+
.fetch_all(&mut *connection)
1804+
.await?;
1805+
Ok(ReadAt {
1806+
value: rows.into_iter().collect(),
1807+
read_at,
1808+
})
17671809
}
17681810

17691811
/// Appends the channels of `more` that `ids` lacks.
@@ -1794,7 +1836,9 @@ pub struct ReadableNamedOnlyChannel {
17941836
/// one also has it through [`get_accessible_channel_ids`]; listing it here
17951837
/// as well is harmless, since a filter's scope is deduplicated.
17961838
///
1797-
/// Uncached, so a caller can trust it for a channel the request names. A
1839+
/// Uncached, so a caller can trust it for a channel the request names. With
1840+
/// no names, it is the named-only halves of [`get_member_channels_read_at`] and
1841+
/// [`get_listed_open_channels_read_at`] together, which the relay caches. A
17981842
/// read reaches one only by naming it, or, for system channels, by opting in
17991843
/// to them. The opt-in needs every listed system channel, so those are all
18001844
/// loaded; an unlisted channel is loaded only when named, since a community
@@ -2844,35 +2888,29 @@ impl Db {
28442888
get_active_membership_ids_bulk_read_at(&self.pool, community_id, pubkeys, limit).await
28452889
}
28462890

2847-
/// Channel IDs where a pubkey is an active member. See [`get_member_channel_ids`].
2891+
/// Every channel where a pubkey is an active member, split by type, with
2892+
/// when its connection was checked out. See [`get_member_channels_read_at`].
2893+
/// The span keeps the name of the read it replaced, so dashboards keep
2894+
/// their history.
28482895
#[datastore_span(name = "get_member_channel_ids", system = "postgresql")]
2849-
pub async fn get_member_channel_ids(
2896+
pub async fn get_member_channels_read_at(
28502897
&self,
28512898
community_id: CommunityId,
28522899
pubkey: &[u8],
2853-
) -> Result<Vec<Uuid>> {
2854-
get_member_channel_ids(&self.pool, community_id, pubkey).await
2855-
}
2856-
2857-
/// A community's listed open channel IDs. See [`get_listed_open_channel_ids`].
2858-
pub async fn get_listed_open_channel_ids(
2859-
&self,
2860-
community_id: CommunityId,
2861-
) -> Result<Vec<Uuid>> {
2862-
Ok(self
2863-
.get_listed_open_channel_ids_read_at(community_id)
2864-
.await?
2865-
.value)
2900+
) -> Result<ReadAt<ChannelSet>> {
2901+
get_member_channels_read_at(&self.pool, community_id, pubkey).await
28662902
}
28672903

2868-
/// [`Self::get_listed_open_channel_ids`], with when its connection was
2869-
/// checked out, for caches that bound staleness from the read.
2904+
/// Every listed open channel, split by type, with when its connection
2905+
/// was checked out, for caches that bound staleness from the read. See
2906+
/// [`get_listed_open_channels_read_at`]. The span keeps the name of the
2907+
/// read it replaced, so dashboards keep their history.
28702908
#[datastore_span(name = "get_listed_open_channel_ids", system = "postgresql")]
2871-
pub async fn get_listed_open_channel_ids_read_at(
2909+
pub async fn get_listed_open_channels_read_at(
28722910
&self,
28732911
community_id: CommunityId,
2874-
) -> Result<ReadAt<Vec<Uuid>>> {
2875-
get_listed_open_channel_ids_read_at(&self.pool, community_id).await
2912+
) -> Result<ReadAt<ChannelSet>> {
2913+
get_listed_open_channels_read_at(&self.pool, community_id).await
28762914
}
28772915

28782916
/// The channels of non-legacy types a pubkey can read (member, or open

‎crates/buzz-db/src/store/unlisted_channels_postgres_tests.rs‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,102 @@ async fn channel_created_unlisted_is_never_listed() {
422422
assert!(f.implicit(&f.owner).await.contains(&chat));
423423
}
424424
}
425+
426+
/// The relay caches the member and listed-open channel sets and serves a
427+
/// request's named-only channels from them when it names nothing else. Their
428+
/// named-only halves together must equal the uncached read with no names,
429+
/// and their implicit halves the accessible set, for a member and a non-member.
430+
/// Mutation: restrict `get_member_channels_read_at` or
431+
/// `get_listed_open_channels_read_at` to legacy types, or drop `NOT unlisted`
432+
/// from the latter → RED.
433+
#[tokio::test]
434+
#[ignore = "requires Postgres"]
435+
async fn cached_channel_sets_match_the_uncached_named_only_read() {
436+
let f = Fixture::new().await;
437+
let system_private = f
438+
.typed_channel(
439+
"system-private",
440+
ChannelType::System,
441+
ChannelVisibility::Private,
442+
)
443+
.await;
444+
let system_listed = f
445+
.typed_channel(
446+
"system-listed",
447+
ChannelType::System,
448+
ChannelVisibility::Open,
449+
)
450+
.await;
451+
let system_unlisted = f
452+
.typed_channel(
453+
"system-unlisted",
454+
ChannelType::System,
455+
ChannelVisibility::Open,
456+
)
457+
.await;
458+
f.set_unlisted(system_unlisted, true).await;
459+
let stream_listed = f.channel("stream-listed", ChannelVisibility::Open).await;
460+
let stream_unlisted = f.channel("stream-unlisted", ChannelVisibility::Open).await;
461+
f.set_unlisted(stream_unlisted, true).await;
462+
let stream_private = f
463+
.channel("stream-private", ChannelVisibility::Private)
464+
.await;
465+
466+
let sorted = |mut ids: Vec<Uuid>| {
467+
ids.sort_unstable();
468+
ids
469+
};
470+
let open =
471+
f.db.get_listed_open_channels_read_at(f.community)
472+
.await
473+
.expect("listed open channels")
474+
.value;
475+
assert_eq!(open.implicit, [stream_listed]);
476+
assert_eq!(open.named_only, [(system_listed, "system".to_owned())]);
477+
478+
for (reader, member_named_only) in [
479+
(
480+
&f.owner,
481+
sorted(vec![system_private, system_listed, system_unlisted]),
482+
),
483+
(&f.outsider, Vec::new()),
484+
] {
485+
let member =
486+
f.db.get_member_channels_read_at(f.community, &reader.public_key().to_bytes())
487+
.await
488+
.expect("member channels")
489+
.value;
490+
assert_eq!(
491+
sorted(member.named_only.iter().map(|(id, _)| *id).collect()),
492+
member_named_only
493+
);
494+
let mut cached: Vec<(Uuid, String)> = member.named_only.clone();
495+
cached.extend(
496+
open.named_only
497+
.iter()
498+
.filter(|(id, _)| !member.named_only.iter().any(|(have, _)| have == id))
499+
.cloned(),
500+
);
501+
cached.sort_unstable();
502+
let mut uncached = f.named_only(reader, &[]).await;
503+
uncached.sort_unstable();
504+
assert_eq!(
505+
cached, uncached,
506+
"named-only halves match the uncached read"
507+
);
508+
509+
let mut implicit = member.implicit.clone();
510+
crate::channel_members::merge_channel_ids(&mut implicit, &open.implicit);
511+
assert_eq!(sorted(implicit), sorted(f.implicit(reader).await));
512+
}
513+
// The owner is a member of every stream channel, listed or not.
514+
let owner =
515+
f.db.get_member_channels_read_at(f.community, &f.owner.public_key().to_bytes())
516+
.await
517+
.expect("owner member channels")
518+
.value;
519+
assert_eq!(
520+
sorted(owner.implicit),
521+
sorted(vec![stream_listed, stream_unlisted, stream_private])
522+
);
523+
}

‎crates/buzz-relay/src/api/bridge.rs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,20 +1798,28 @@ async fn query_member_events(
17981798
}
17991799

18001800
// Get channels this user can access — same enforcement as WS REQ handler.
1801-
let mut accessible_channels = state
1802-
.get_accessible_channel_ids_cached(tenant.community(), &pubkey_bytes)
1801+
let mut access = state
1802+
.get_channel_access_cached(tenant.community(), &pubkey_bytes)
18031803
.await
18041804
.map_err(|e| internal_error(&format!("channel access lookup: {e}")))?;
1805+
let mut accessible_channels = std::mem::take(&mut access.implicit);
18051806
// Named-only channels (system, and types added later) are outside
18061807
// `accessible_channels`; a filter that names one reads it in its own
18071808
// scope only (see `handlers::system_channels`).
1809+
// A strong read must see the caller's own just-accepted write, such as a
1810+
// system channel it just created, so its named-only access comes from the
1811+
// database rather than a cached membership a peer pod may not have dropped.
1812+
let strong = raw_filters
1813+
.iter()
1814+
.any(|raw| matches!(extract_consistency(raw), Consistency::Strong));
18081815
let mut named_only =
18091816
crate::handlers::system_channels::readable_named_only_channels_for_filters(
18101817
state,
18111818
tenant.community(),
18121819
&pubkey_bytes,
18131820
&filters,
18141821
&accessible_channels,
1822+
(!strong).then_some(&access),
18151823
None,
18161824
)
18171825
.await
@@ -2449,10 +2457,11 @@ async fn count_member_events(
24492457
}
24502458

24512459
// Get channels this user can access.
2452-
let mut accessible_channels = state
2453-
.get_accessible_channel_ids_cached(tenant.community(), &pubkey_bytes)
2460+
let mut access = state
2461+
.get_channel_access_cached(tenant.community(), &pubkey_bytes)
24542462
.await
24552463
.map_err(|e| internal_error(&format!("channel access lookup: {e}")))?;
2464+
let mut accessible_channels = std::mem::take(&mut access.implicit);
24562465
// Named-only channels (system, and types added later) are outside
24572466
// `accessible_channels`; a filter that names one reads it in its own
24582467
// scope only (see `handlers::system_channels`).
@@ -2463,6 +2472,7 @@ async fn count_member_events(
24632472
&pubkey_bytes,
24642473
&filters,
24652474
&accessible_channels,
2475+
Some(&access),
24662476
None,
24672477
)
24682478
.await

‎crates/buzz-relay/src/handlers/count.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ pub async fn handle_count(
8888
};
8989

9090
// Get channels this user can access — same enforcement as WS REQ handler.
91-
let mut accessible_channels = match state
92-
.get_accessible_channel_ids_cached(conn.tenant.community(), &pubkey_bytes)
91+
let (mut accessible_channels, cached_access) = match state
92+
.get_channel_access_cached(conn.tenant.community(), &pubkey_bytes)
9393
.await
9494
{
95-
Ok(ids) => ids,
95+
Ok(mut access) => (std::mem::take(&mut access.implicit), access),
9696
Err(e) => {
9797
warn!(sub_id = %sub_id, error_kind = %e.kind(), "Failed to get accessible channels");
9898
conn.send(RelayMessage::closed(&sub_id, DATABASE_ERROR_CLOSED));
@@ -117,6 +117,7 @@ pub async fn handle_count(
117117
&pubkey_bytes,
118118
&filters,
119119
&accessible_channels,
120+
Some(&cached_access),
120121
token_channel_ids.as_deref(),
121122
)
122123
.await

0 commit comments

Comments
 (0)