mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
refactor(blocks): route block-list sub through SubscriptionManager (P4)
kind-10000/30002 block-list live subscription now goes through L1 (dedup + reconnect re-issue), handle closed on teardown; relaySubscriptionService kept as manager-less fallback. user-blocks + dm-block-filter suites pass. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
09d0e045e8
commit
dd3fbfdae6
1 file changed
+25
@@ -752,6 +752,14 @@ class UserBlockListManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopBlockListSubscription() {
|
stopBlockListSubscription() {
|
||||||
|
if (this.blockListSubscriptionHandle) {
|
||||||
|
try {
|
||||||
|
this.blockListSubscriptionHandle.close();
|
||||||
|
} catch (error) {
|
||||||
|
devLogger.warn("[UserBlockList] Failed to close block-list subscription handle", error);
|
||||||
|
}
|
||||||
|
this.blockListSubscriptionHandle = null;
|
||||||
|
}
|
||||||
if (this.blockListSubscriptionKey) {
|
if (this.blockListSubscriptionKey) {
|
||||||
relaySubscriptionService.stopSubscription(
|
relaySubscriptionService.stopSubscription(
|
||||||
this.blockListSubscriptionKey,
|
this.blockListSubscriptionKey,
|
||||||
@@ -775,6 +783,23 @@ class UserBlockListManager {
|
|||||||
{ kinds: [30002], authors: [normalized], "#d": [BLOCK_LIST_IDENTIFIER] },
|
{ kinds: [30002], authors: [normalized], "#d": [BLOCK_LIST_IDENTIFIER] },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Route through the L1 SubscriptionManager when available (dedup + reconnect
|
||||||
|
// re-issue); fall back to relaySubscriptionService in manager-less envs.
|
||||||
|
const manager =
|
||||||
|
typeof nostrClient.getSubscriptionManager === "function"
|
||||||
|
? nostrClient.getSubscriptionManager()
|
||||||
|
: null;
|
||||||
|
if (manager) {
|
||||||
|
this.blockListSubscriptionHandle = manager.subscribe({
|
||||||
|
key,
|
||||||
|
relays,
|
||||||
|
filters,
|
||||||
|
label: "block-list",
|
||||||
|
onEvent: (event) => this.handleBlockListEvent(event),
|
||||||
|
});
|
||||||
|
return this.blockListSubscriptionHandle;
|
||||||
|
}
|
||||||
|
|
||||||
return relaySubscriptionService.ensureSubscription({
|
return relaySubscriptionService.ensureSubscription({
|
||||||
key,
|
key,
|
||||||
pool: nostrClient.pool,
|
pool: nostrClient.pool,
|
||||||
|
|||||||
Reference in new issue
Block a user