Documentation
    Preparing search index...

    Interface RelayPoolAdapter

    Abstract relay pool — runtime uses this to subscribe to and publish events on real Nostr relays. Implementor wraps their relay library.

    interface RelayPoolAdapter {
        closeScopedRelay(windowId: string): void;
        isAvailable(): boolean;
        openScopedRelay(
            windowId: string,
            relayUrl: string,
            subId: string,
            filters: NostrFilter[],
            sendToNapplet: SendToNapplet,
        ): void;
        publish(event: NostrEvent): void | Promise<void>;
        publishToScopedRelay(
            windowId: string,
            event: NostrEvent,
        ): boolean | Promise<boolean>;
        selectRelayTier(filters: NostrFilter[]): string[];
        subscribe(
            filters: NostrFilter[],
            callback: (item: NostrEvent | "EOSE") => void,
            relayUrls?: string[],
        ): RelaySubscriptionHandle;
        trackSubscription(subKey: string, cleanup: () => void): void;
        untrackSubscription(subKey: string): void;
    }
    Index

    Methods

    • Publish an event to relays.

      Async adapters return a promise that settles only after the transport has accepted or rejected the publish.

      Parameters

      Returns void | Promise<void>

    • Publish to a scoped relay.

      Async adapters settle the returned promise after transport acceptance. Returns false if no active scoped relay or publication fails.

      Parameters

      Returns boolean | Promise<boolean>

    • Track a subscription key for lifecycle management.

      Parameters

      • subKey: string
      • cleanup: () => void

      Returns void