Expose ChannelMonitor::block_[dis]connected as pub
authorMatt Corallo <git@bluematt.me>
Thu, 13 Feb 2020 04:55:22 +0000 (23:55 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 25 May 2020 19:33:55 +0000 (15:33 -0400)
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

index ff0b6e9eb8903a0ab3d2c03a7cba8f892026f623..9e42749ce2e82083ca461fbc610441a32de68bd1 100644 (file)
@@ -1797,12 +1797,17 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                Vec::new()
        }
 
-       /// 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<B: Deref, F: Deref, L: Deref>(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F, logger: L)-> Vec<(Txid, Vec<TxOut>)>
+       /// Called when a new block has been connected to the best chain by <SimpleManyChannelMonitor
+       /// as ChainListener>::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<B: Deref, F: Deref, L: Deref>(&mut self, txn_matched: &[&Transaction], height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F, logger: L)-> Vec<(Txid, Vec<TxOut>)>
                where B::Target: BroadcasterInterface,
                      F::Target: FeeEstimator,
                                        L::Target: Logger,
@@ -1901,7 +1906,14 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                watch_outputs
        }
 
-       fn block_disconnected<B: Deref, F: Deref, L: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F, logger: L)
+       /// Called when a block has been disconnected from the best chain by <SimpleManyChannelMonitor
+       /// as ChainListener>::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<B: Deref, F: Deref, L: Deref>(&mut self, height: u32, block_hash: &BlockHash, broadcaster: B, fee_estimator: F, logger: L)
                where B::Target: BroadcasterInterface,
                      F::Target: FeeEstimator,
                      L::Target: Logger,