qbit-rpc
    Preparing search index...

    Class QbitZmqSubscriber

    Subscribes to qbitd's ZMQ notifications and yields parsed messages, gaps in each topic's sequence counter, malformed messages and socket replacements. The socket is replaced when a receive fails or the connection drops. Counters are tracked across replacements, and the first message on each topic after one is always reported as a gap, since messages published meanwhile are lost and a restarted qbitd's counter can happen to line up. A gap is the signal to reconcile over RPC (for blocks, getbestblockhash and walk back with getblockheader): ZMQ is a wake-up, not a ledger. A failure that retrying cannot fix (a zeromq module that does not load, an address connect() refuses) ends the iteration with a ZmqSetupError instead.

    One consumer at a time: iterate it with for await.

    Implements

    Index
    • Connect, subscribe and yield each event until close(), or until a ZmqSetupError ends the iteration. One consumer at a time: a second iteration while one runs throws.

      Returns AsyncGenerator<ZmqEvent, void, undefined>

    • A snapshot of what the subscriber has observed. See ZmqHealthStatus.

      The last message's age is measured on the monotonic clock (performance.now()), so a step in the wall clock makes a fresh subscriber neither stale nor an old one receiving. now is the wall-clock time (Date.now() units) to report the status at, by default the present: the age is shifted by now - Date.now(), so health(Date.now() + 60_000) tells whether the subscriber will be stale in a minute if no message arrives meanwhile.

      Parameters

      • Optionalnow: number

      Returns ZmqHealth