Trait Listen

Source
pub trait Listen {
    // Required methods
    fn filtered_block_connected(
        &self,
        header: &Header,
        txdata: &TransactionData<'_>,
        height: u32,
    );
    fn blocks_disconnected(&self, fork_point_block: BestBlock);

    // Provided method
    fn block_connected(&self, block: &Block, height: u32) { ... }
}
Expand description

The Listen trait is used to notify when blocks have been connected or disconnected from the chain.

Useful when needing to replay chain data upon startup or as new chain events occur. Clients sourcing chain data using a block-oriented API should prefer this interface over Confirm. Such clients fetch the entire header chain whereas clients using Confirm only fetch headers when needed.

By using Listen::filtered_block_connected this interface supports clients fetching the entire header chain and only blocks with matching transaction data using BIP 157 filters or other similar filtering.

§Requirements

Each block must be connected in chain order with one call to either Listen::block_connected or Listen::filtered_block_connected. If a call to the Filter interface was made during block processing and further transaction(s) from the same block now match the filter, a second call to Listen::filtered_block_connected should be made immediately for the same block (prior to any other calls to the Listen interface).

In case of a reorg, you must call Listen::blocks_disconnected once with information on the “fork point” block, i.e. the highest block that is in both forks. You may call Listen::blocks_disconnected multiple times as you walk the chain backwards, but each must include a fork point block that is before the last.

§Object Birthday

Note that most implementations take a BestBlock on construction and blocks only need to be applied starting from that point.

Required Methods§

Source

fn filtered_block_connected( &self, header: &Header, txdata: &TransactionData<'_>, height: u32, )

Notifies the listener that a block was added at the given height, with the transaction data possibly filtered.

Source

fn blocks_disconnected(&self, fork_point_block: BestBlock)

Notifies the listener that one or more blocks were removed in anticipation of a reorg.

The provided BestBlock is the new best block after disconnecting blocks in the reorg but before connecting new ones (i.e. the “fork point” block). For backwards compatibility, you may instead walk the chain backwards, calling blocks_disconnected for each block that is disconnected in a reorg.

Provided Methods§

Source

fn block_connected(&self, block: &Block, height: u32)

Notifies the listener that a block was added at the given height.

Implementations on Foreign Types§

Source§

impl<Signer: EcdsaChannelSigner, T: Deref, F: Deref, L: Deref> Listen for (ChannelMonitor<Signer>, T, F, L)

Source§

fn filtered_block_connected( &self, header: &Header, txdata: &TransactionData<'_>, height: u32, )

Source§

fn blocks_disconnected(&self, fork_point: BestBlock)

Source§

impl<T: Deref, U: Deref> Listen for (T, U)
where T::Target: Listen, U::Target: Listen,

Source§

fn filtered_block_connected( &self, header: &Header, txdata: &TransactionData<'_>, height: u32, )

Source§

fn blocks_disconnected(&self, fork_point: BestBlock)

Source§

impl<T: Listen> Listen for dyn Deref<Target = T>

Source§

fn filtered_block_connected( &self, header: &Header, txdata: &TransactionData<'_>, height: u32, )

Source§

fn blocks_disconnected(&self, fork_point: BestBlock)

Implementors§

Source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> Listen for OutputSweeper<B, D, E, F, K, L, O>

Source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> Listen for OutputSweeperSync<B, D, E, F, K, L, O>

Source§

impl<ChannelSigner: EcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref, ES: Deref> Listen for ChainMonitor<ChannelSigner, C, T, F, L, P, ES>

Source§

impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref> Listen for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>