Skip to content

Commit c78b08b

Browse files
committed
Add further additional documentation to Listen
`Listen` is somewhat quiet on high-level use and even requirements, which we document further here.
1 parent dbb51a3 commit c78b08b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lightning/src/chain/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ impl_writeable_tlv_based!(BestBlock, {
7373
/// By using [`Listen::filtered_block_connected`] this interface supports clients fetching the
7474
/// entire header chain and only blocks with matching transaction data using BIP 157 filters or
7575
/// other similar filtering.
76+
///
77+
/// # Requirements
78+
///
79+
/// Each block must be connected in chain order with one call to either
80+
/// [`Listen::block_connected`] or [`Listen::filtered_block_connected`]. If a call to the
81+
/// [`Filter`] interface was made during block processing and further transaction(s) from the same
82+
/// block now match the filter, a second call to [`Listen::filtered_block_connected`] should be
83+
/// made immediately for the same block (prior to any other calls to the [`Listen`] interface).
84+
///
85+
/// In case of a reorg, you must call [`Listen::blocks_disconnected`] once with information on the
86+
/// "fork point" block, i.e. the highest block that is in both forks. You may call
87+
/// [`Listen::blocks_disconnected`] multiple times as you walk the chain backwards, but each must
88+
/// include a fork point block that is before the last.
89+
///
90+
/// # Object Birthday
91+
///
92+
/// Note that most implementations take a [`BestBlock`] on construction and blocks only need to be
93+
/// applied starting from that point.
7694
pub trait Listen {
7795
/// Notifies the listener that a block was added at the given height, with the transaction data
7896
/// possibly filtered.

0 commit comments

Comments
 (0)