#chain #mempool #block #transaction #notifications #called #updated

bitcoinchain-notifications

interface for notifying when, for example: transactions are added/removed to the mempool, blocks are connected/disconnected, the block tip is updated, or the chain state is flushed

2 releases

0.1.16-alpha.0 Apr 2, 2023
0.1.12-alpha.0 Jan 19, 2023

#22 in #mempool

Download history 101/week @ 2023-12-13 115/week @ 2023-12-20 60/week @ 2023-12-27 68/week @ 2024-01-03 97/week @ 2024-01-10 93/week @ 2024-01-17 36/week @ 2024-01-24 38/week @ 2024-01-31 58/week @ 2024-02-07 111/week @ 2024-02-14 82/week @ 2024-02-21 115/week @ 2024-02-28 80/week @ 2024-03-06 86/week @ 2024-03-13 142/week @ 2024-03-20 178/week @ 2024-03-27

512 downloads per month
Used in 41 crates (8 directly)

MIT license

1MB
4K SLoC

bitcoinchain-notifications crate

The BitcoinChain-Notifications crate provides chain notifications for Bitcoin clients. This crate contains trait definitions for various events that clients can subscribe to in order to be notified about various changes in the Bitcoin chain.

The ChainNotifications trait is the main trait for listening to chain notifications. This trait is composed of other traits, including TransactionAddedToMempool, TransactionRemovedFromMempool, BlockConnected, BlockDisconnected, UpdatedBlockTip, and ChainStateFlushed. Each of these traits defines a method for listening to a specific type of event.

The TransactionAddedToMempool trait defines a method that is called when a transaction is added to the mempool.

The TransactionRemovedFromMempool trait defines a method that is called when a transaction is removed from the mempool.

This notification is fired for transactions that are removed from the mempool for various reasons including expiration, size limit, reorg, conflict, and replaced.

However, it does not fire for transactions that are removed from the mempool because they have been included in a block. Any client interested in transactions removed from the mempool for inclusion in a block can learn about those transactions from the BlockConnected notification.

The BlockConnected trait defines a method that is called when a new block is connected to the chain.

The BlockDisconnected trait defines a method that is called when a block is disconnected from the chain.

The UpdatedBlockTip trait defines a method that is called when the block tip is updated.

Finally, the ChainStateFlushed trait defines a method that is called when the chain state is flushed.

All of these traits are designed to be used on a background thread.

To use this crate, you can implement any of the traits in your client code and register your implementation with the client's notification system. When a chain event occurs that matches your implementation, the corresponding method will be called.

Dependencies

~102MB
~836K SLoC