pub struct Emitter<'c, C> { /* private fields */ }
Expand description
The Emitter
is used to emit data sourced from [bitcoincore_rpc::Client
].
Refer to module-level documentation for more.
Implementations§
Source§impl<'c, C: RpcApi> Emitter<'c, C>
impl<'c, C: RpcApi> Emitter<'c, C>
Sourcepub fn new(client: &'c C, last_cp: CheckPoint, start_height: u32) -> Self
pub fn new(client: &'c C, last_cp: CheckPoint, start_height: u32) -> Self
Construct a new Emitter
.
last_cp
informs the emitter of the chain we are starting off with. This way, the emitter
can start emission from a block that connects to the original chain.
start_height
starts emission from a given height (if there are no conflicts with the
original chain).
Sourcepub fn mempool(&mut self) -> Result<Vec<(Transaction, u64)>, Error>
pub fn mempool(&mut self) -> Result<Vec<(Transaction, u64)>, Error>
Emit mempool transactions, alongside their first-seen unix timestamps.
This method emits each transaction only once, unless we cannot guarantee the transaction’s ancestors are already emitted.
To understand why, consider a receiver which filters transactions based on whether it
alters the UTXO set of tracked script pubkeys. If an emitted mempool transaction spends a
tracked UTXO which is confirmed at height h
, but the receiver has only seen up to block
of height h-1
, we want to re-emit this transaction until the receiver has seen the block
at height h
.
Sourcepub fn next_header(&mut self) -> Result<Option<BlockEvent<Header>>, Error>
pub fn next_header(&mut self) -> Result<Option<BlockEvent<Header>>, Error>
Emit the next block height and header (if any).
Sourcepub fn next_block(&mut self) -> Result<Option<BlockEvent<Block>>, Error>
pub fn next_block(&mut self) -> Result<Option<BlockEvent<Block>>, Error>
Emit the next block height and block (if any).