subscribe_blocks

Function subscribe_blocks 

Source
pub fn subscribe_blocks(
    start_block: Word,
    acquire_conn: impl AcquireConnection,
    await_new_block: impl AwaitNewBlock,
) -> impl Stream<Item = Result<Block, QueryError>>
Expand description

Subscribe to all blocks from the given starting block number.

The given acquire_conn type will be used on each iteration to asynchronously acquire a handle to a new rusqlite Connection from a source such as a connection pool. If the returned future completes with None, it is assumed the source of Connections has closed, and in turn the Stream will close.

The given await_new_block type will be used as a signal to check whether or not a new block is available within the DB. The returned stream will yield immediately for each block until a DB query indicates there are no more blocks, at which point await_new_block is called before continuing. If await_new_block returns None, the source of new block notifications is assumed to have been closed and the stream will close.