Documentation
    Preparing search index...

    Interface Nip66Aggregator

    Aggregator handle returned by createNip66Aggregator. Each call returns a fresh instance with its own closure-scoped state — multi-instance safe (unlike a module-globals pattern).

    const aggregator = createNip66Aggregator({ pool, bootstrap: ['wss://monitor.example.com'] });
    aggregator.start();
    const relays = aggregator.getRelaySet();
    interface Nip66Aggregator {
        getRelayAttributes(url: string): Nip66RelayAttributes | undefined;
        getRelaySet(): ReadonlySet<string>;
        getRelaysForAttributeGroup(
            groupName: string,
            groups?: Readonly<Record<string, readonly RelayAttributeMatcher[]>>,
        ): string[];
        getRelaysMatchingAttributes(
            matchers: readonly RelayAttributeMatcher[],
        ): string[];
        getRelaysSupportingNip(nip: number): string[];
        relaySupportsNip(url: string, nip: number): boolean;
        resync(): void;
        start(): void;
        stop(): void;
    }
    Index

    Methods

    • The current set of relay URLs discovered from kind-30166 d-tags. Empty until start() fires at least one event.

      Returns ReadonlySet<string>

    • Relay URLs whose N-tags declare support for the given NIP number.

      Parameters

      • nip: number

        NIP number to query support for (e.g. 44 for NIP-44 encrypted DMs)

      Returns string[]

      Array of relay URLs supporting that NIP

    • Whether the relay at url has been seen with an N-tag declaring support for nip.

      Parameters

      • url: string

        Relay WebSocket URL to check

      • nip: number

        NIP number to query support for

      Returns boolean

      true iff the relay has been observed with a matching N-tag

    • Tear down the current subscription, clear accumulated state, and re-subscribe. Call when networks semantics change upstream.

      Returns void

    • Begin subscribing against the bootstrap relay set. Idempotent — calling twice is a no-op.

      Returns void

    • Tear down the current subscription. Idempotent — calling without a prior start() is a safe no-op. Preserves accumulated state (getRelaySet, relaySupportsNip) — use resync() if you need to clear state AND re-subscribe in one step. A subsequent start() re-subscribes against the bootstrap relays (identical contract to the first start).

      Wire this to your consumer's teardown path (browser: beforeunload; React: effect cleanup; Electron: app.before-quit) — the aggregator holds a pool subscription that otherwise lives for the tab lifetime (PITFALLS.md M-03).

      Returns void