From 79c9544859be23417755d9dd39bc55daa68412ef Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 12 Feb 2020 23:55:22 -0500 Subject: [PATCH] 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. --- lightning/src/ln/channelmonitor.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index afe559157..8f01f8dd1 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -2571,12 +2571,17 @@ impl ChannelMonitor { } } - /// Called by SimpleManyChannelMonitor::block_connected, which implements - /// ChainListener::block_connected. - /// Eventually this should be pub and, roughly, implement ChainListener, however this requires - /// &mut self, as well as returns new spendable outputs and outpoints to watch for spending of - /// on-chain. - fn block_connected(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &Sha256dHash, broadcaster: B, fee_estimator: F)-> Vec<(Sha256dHash, Vec)> + /// Called when a new block has been connected to the best chain by ::block_connected, and should thus generally not be called during normal + /// operation. It is exposed both for users who wish to use ChannelMonitors directly and to + /// simplify rescans that occur at load-time. + /// + /// This is very similar to ChainListener::block_connected itself, but requires an &mut self, + /// and an explicit reference to a transaction broadcaster and fee estimator. + /// + /// Returns a list of new (txid, outputs) pairs which spends of must be watched for. Note that + /// after this call these are also available via get_outputs_to_watch(). + pub fn block_connected(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &Sha256dHash, broadcaster: B, fee_estimator: F)-> Vec<(Sha256dHash, Vec)> where B::Target: BroadcasterInterface, F::Target: FeeEstimator { @@ -2819,7 +2824,14 @@ impl ChannelMonitor { watch_outputs } - fn block_disconnected(&mut self, height: u32, block_hash: &Sha256dHash, broadcaster: B, fee_estimator: F) + /// Called when a block has been disconnected from the best chain by ::block_disconnected, and should thus generally not be called during + /// normal operation. It is exposed both for users who wish to use ChannelMonitors directly and + /// to simplify rescans that occur at load-time. + /// + /// This is very similar to ChainListener::block_disconnected itself, but requires an &mut self, + /// and an explicit reference to a transaction broadcaster and fee estimator. + pub fn block_disconnected(&mut self, height: u32, block_hash: &Sha256dHash, broadcaster: B, fee_estimator: F) where B::Target: BroadcasterInterface, F::Target: FeeEstimator { -- 2.39.5