Skip to content

Commit eec4beb

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 9098240 commit eec4beb

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
@@ -1837,12 +1837,17 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
18371837
Vec::new()
18381838
}
18391839

1840-
/// Called by SimpleManyChannelMonitor::block_connected, which implements
1841-
/// ChainListener::block_connected.
1842-
/// Eventually this should be pub and, roughly, implement ChainListener, however this requires
1843-
/// &mut self, as well as returns new spendable outputs and outpoints to watch for spending of
1844-
/// on-chain.
1845-
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>)>
1840+
/// Called when a new block has been connected to the best chain by <SimpleManyChannelMonitor
1841+
/// as ChainListener>::block_connected, and should thus generally not be called during normal
1842+
/// operation. It is exposed both for users who wish to use ChannelMonitors directly and to
1843+
/// simplify rescans that occur at load-time.
1844+
///
1845+
/// This is very similar to ChainListener::block_connected itself, but requires an &mut self,
1846+
/// and an explicit reference to a transaction broadcaster and fee estimator.
1847+
///
1848+
/// Returns a list of new (txid, outputs) pairs which spends of must be watched for. Note that
1849+
/// after this call these are also available via get_outputs_to_watch().
1850+
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>)>
18461851
where B::Target: BroadcasterInterface,
18471852
F::Target: FeeEstimator
18481853
{
@@ -1940,7 +1945,14 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
19401945
watch_outputs
19411946
}
19421947

1943-
fn block_disconnected<B: Deref, F: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)
1948+
/// Called when a block has been disconnected from the best chain by <SimpleManyChannelMonitor
1949+
/// as ChainListener>::block_disconnected, and should thus generally not be called during
1950+
/// normal operation. It is exposed both for users who wish to use ChannelMonitors directly and
1951+
/// to simplify rescans that occur at load-time.
1952+
///
1953+
/// This is very similar to ChainListener::block_disconnected itself, but requires an &mut self,
1954+
/// and an explicit reference to a transaction broadcaster and fee estimator.
1955+
pub fn block_disconnected<B: Deref, F: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F)
19441956
where B::Target: BroadcasterInterface,
19451957
F::Target: FeeEstimator
19461958
{

0 commit comments

Comments
 (0)