@@ -187,13 +187,12 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
187
187
let mut reentered = true ;
188
188
while reentered {
189
189
let matched_indexes = self . chain_monitor . filter_block ( header, txdata) ;
190
- let matched_txn: Vec < _ > = matched_indexes. iter ( ) . map ( |index| txdata[ * index] . 1 ) . collect ( ) ;
190
+ let matched_txn: Vec < _ > = matched_indexes. iter ( ) . map ( |index| txdata[ * index] ) . collect ( ) ;
191
191
let last_seen = self . chain_monitor . reentered ( ) ;
192
- let block_hash = header. bitcoin_hash ( ) ;
193
192
{
194
193
let mut monitors = self . monitors . lock ( ) . unwrap ( ) ;
195
194
for monitor in monitors. values_mut ( ) {
196
- let txn_outputs = monitor. block_connected ( & matched_txn, height, & block_hash , & * self . broadcaster , & * self . fee_estimator , & * self . logger ) ;
195
+ let txn_outputs = monitor. block_connected ( header , & matched_txn, height, & * self . broadcaster , & * self . fee_estimator , & * self . logger ) ;
197
196
198
197
for ( ref txid, ref outputs) in txn_outputs {
199
198
for ( idx, output) in outputs. iter ( ) . enumerate ( ) {
@@ -207,10 +206,9 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
207
206
}
208
207
209
208
fn block_disconnected ( & self , header : & BlockHeader , disconnected_height : u32 ) {
210
- let block_hash = header. bitcoin_hash ( ) ;
211
209
let mut monitors = self . monitors . lock ( ) . unwrap ( ) ;
212
210
for monitor in monitors. values_mut ( ) {
213
- monitor. block_disconnected ( disconnected_height , & block_hash , & * self . broadcaster , & * self . fee_estimator , & * self . logger ) ;
211
+ monitor. block_disconnected ( header , disconnected_height , & * self . broadcaster , & * self . fee_estimator , & * self . logger ) ;
214
212
}
215
213
}
216
214
}
@@ -1877,12 +1875,12 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1877
1875
/// Eventually this should be pub and, roughly, implement ChainListener, however this requires
1878
1876
/// &mut self, as well as returns new spendable outputs and outpoints to watch for spending of
1879
1877
/// on-chain.
1880
- 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 > ) >
1878
+ fn block_connected < B : Deref , F : Deref , L : Deref > ( & mut self , header : & BlockHeader , txn_matched : & [ ( usize , & Transaction ) ] , height : u32 , broadcaster : B , fee_estimator : F , logger : L ) -> Vec < ( Txid , Vec < TxOut > ) >
1881
1879
where B :: Target : BroadcasterInterface ,
1882
1880
F :: Target : FeeEstimator ,
1883
1881
L :: Target : Logger ,
1884
1882
{
1885
- for tx in txn_matched {
1883
+ for & ( _ , tx ) in txn_matched {
1886
1884
let mut output_val = 0 ;
1887
1885
for out in tx. output . iter ( ) {
1888
1886
if out. value > 21_000_000_0000_0000 { panic ! ( "Value-overflowing transaction provided to block connected" ) ; }
@@ -1891,10 +1889,12 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1891
1889
}
1892
1890
}
1893
1891
1892
+ let block_hash = header. bitcoin_hash ( ) ;
1894
1893
log_trace ! ( logger, "Block {} at height {} connected with {} txn matched" , block_hash, height, txn_matched. len( ) ) ;
1894
+
1895
1895
let mut watch_outputs = Vec :: new ( ) ;
1896
1896
let mut claimable_outpoints = Vec :: new ( ) ;
1897
- for tx in txn_matched {
1897
+ for & ( _ , tx ) in txn_matched {
1898
1898
if tx. input . len ( ) == 1 {
1899
1899
// Assuming our keys were not leaked (in which case we're screwed no matter what),
1900
1900
// commitment transactions and HTLC transactions will all only ever have one input,
@@ -1968,20 +1968,22 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1968
1968
}
1969
1969
self . onchain_tx_handler . block_connected ( txn_matched, claimable_outpoints, height, & * broadcaster, & * fee_estimator, & * logger) ;
1970
1970
1971
- self . last_block_hash = block_hash. clone ( ) ;
1971
+ self . last_block_hash = block_hash;
1972
1972
for & ( ref txid, ref output_scripts) in watch_outputs. iter ( ) {
1973
1973
self . outputs_to_watch . insert ( txid. clone ( ) , output_scripts. iter ( ) . map ( |o| o. script_pubkey . clone ( ) ) . collect ( ) ) ;
1974
1974
}
1975
1975
1976
1976
watch_outputs
1977
1977
}
1978
1978
1979
- fn block_disconnected < B : Deref , F : Deref , L : Deref > ( & mut self , height : u32 , block_hash : & BlockHash , broadcaster : B , fee_estimator : F , logger : L )
1979
+ fn block_disconnected < B : Deref , F : Deref , L : Deref > ( & mut self , header : & BlockHeader , height : u32 , broadcaster : B , fee_estimator : F , logger : L )
1980
1980
where B :: Target : BroadcasterInterface ,
1981
1981
F :: Target : FeeEstimator ,
1982
1982
L :: Target : Logger ,
1983
1983
{
1984
+ let block_hash = header. bitcoin_hash ( ) ;
1984
1985
log_trace ! ( logger, "Block {} at height {} disconnected" , block_hash, height) ;
1986
+
1985
1987
if let Some ( _) = self . onchain_events_waiting_threshold_conf . remove ( & ( height + ANTI_REORG_DELAY - 1 ) ) {
1986
1988
//We may discard:
1987
1989
//- htlc update there as failure-trigger tx (revoked commitment tx, non-revoked commitment tx, HTLC-timeout tx) has been disconnected
@@ -1990,7 +1992,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1990
1992
1991
1993
self . onchain_tx_handler . block_disconnected ( height, broadcaster, fee_estimator, logger) ;
1992
1994
1993
- self . last_block_hash = block_hash. clone ( ) ;
1995
+ self . last_block_hash = block_hash;
1994
1996
}
1995
1997
1996
1998
pub ( super ) fn would_broadcast_at_height < L : Deref > ( & self , height : u32 , logger : & L ) -> bool where L :: Target : Logger {
0 commit comments