Skip to content

Commit 01d4617

Browse files
committed
Expose ChannelMonitor::block_[dis]connected as pub
These are essentially required to make rescan-at-reload doable as individual ChannelMonitors may be synced to different chain states and thus need to have blocks replayed separately.
1 parent 198dbb7 commit 01d4617

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,12 +1889,17 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
18891889
Vec::new()
18901890
}
18911891

1892-
/// Called by SimpleManyChannelMonitor::block_connected, which implements
1893-
/// ChainListener::block_connected.
1894-
/// Eventually this should be pub and, roughly, implement ChainListener, however this requires
1895-
/// &mut self, as well as returns new spendable outputs and outpoints to watch for spending of
1896-
/// on-chain.
1897-
fn block_connected<B: Deref, F: Deref>(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)-> Vec<(Txid, Vec<TxOut>)>
1892+
/// Called when a new block has been connected to the best chain by <SimpleManyChannelMonitor
1893+
/// as ChainListener>::block_connected, and should thus generally not be called during normal
1894+
/// operation. It is exposed both for users who wish to use ChannelMonitors directly and to
1895+
/// simplify rescans that occur at load-time.
1896+
///
1897+
/// This is very similar to ChainListener::block_connected itself, but requires an &mut self,
1898+
/// and an explicit reference to a transaction broadcaster and fee estimator.
1899+
///
1900+
/// Returns a list of new (txid, outputs) pairs which spends of must be watched for. Note that
1901+
/// after this call these are also available via get_outputs_to_watch().
1902+
pub fn block_connected<B: Deref, F: Deref>(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)-> Vec<(Txid, Vec<TxOut>)>
18981903
where B::Target: BroadcasterInterface,
18991904
F::Target: FeeEstimator
19001905
{
@@ -1992,7 +1997,14 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
19921997
watch_outputs
19931998
}
19941999

1995-
fn block_disconnected<B: Deref, F: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)
2000+
/// Called when a block has been disconnected from the best chain by <SimpleManyChannelMonitor
2001+
/// as ChainListener>::block_disconnected, and should thus generally not be called during
2002+
/// normal operation. It is exposed both for users who wish to use ChannelMonitors directly and
2003+
/// to simplify rescans that occur at load-time.
2004+
///
2005+
/// This is very similar to ChainListener::block_disconnected itself, but requires an &mut self,
2006+
/// and an explicit reference to a transaction broadcaster and fee estimator.
2007+
pub fn block_disconnected<B: Deref, F: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)
19962008
where B::Target: BroadcasterInterface,
19972009
F::Target: FeeEstimator
19982010
{

0 commit comments

Comments
 (0)