Skip to content

Commit fc03ab1

Browse files
authored
Merge pull request #501 from TheBlueMatt/2020-02-rescan-clarify
Clarify rescan rules for block_connected somewhat
2 parents bae2338 + ca4c970 commit fc03ab1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ pub trait BroadcasterInterface: Sync + Send {
7272
/// A trait indicating a desire to listen for events from the chain
7373
pub trait ChainListener: Sync + Send {
7474
/// Notifies a listener that a block was connected.
75-
/// Note that if a new transaction/outpoint is watched during a block_connected call, the block
76-
/// *must* be re-scanned with the new transaction/outpoints and block_connected should be
77-
/// called again with the same header and (at least) the new transactions.
7875
///
79-
/// Note that if non-new transaction/outpoints may be registered during a call, a second call
76+
/// The txn_matched array should be set to references to transactions which matched the
77+
/// relevant installed watch outpoints/txn, or the full set of transactions in the block.
78+
///
79+
/// Note that if txn_matched includes only matched transactions, and a new
80+
/// transaction/outpoint is watched during a block_connected call, the block *must* be
81+
/// re-scanned with the new transaction/outpoints and block_connected should be called
82+
/// again with the same header and (at least) the new transactions.
83+
///
84+
/// Note that if non-new transaction/outpoints are be registered during a call, a second call
8085
/// *must not* happen.
8186
///
8287
/// This also means those counting confirmations using block_connected callbacks should watch
@@ -281,15 +286,13 @@ impl<'a, CL: Deref<Target = ChainListener + 'a> + 'a> BlockNotifier<'a, CL> {
281286
return last_seen != self.chain_monitor.reentered();
282287
}
283288

284-
285289
/// Notify listeners that a block was disconnected.
286290
pub fn block_disconnected(&self, header: &BlockHeader, disconnected_height: u32) {
287291
let listeners = self.listeners.lock().unwrap();
288292
for listener in listeners.iter() {
289293
listener.block_disconnected(&header, disconnected_height);
290294
}
291295
}
292-
293296
}
294297

295298
/// Utility to capture some common parts of ChainWatchInterface implementors.
@@ -363,7 +366,6 @@ impl ChainWatchInterfaceUtil {
363366
}
364367
}
365368

366-
367369
/// Checks if a given transaction matches the current filter.
368370
pub fn does_match_tx(&self, tx: &Transaction) -> bool {
369371
let watched = self.watched.lock().unwrap();

0 commit comments

Comments
 (0)