@@ -82,10 +82,13 @@ where C::Target: chain::Filter,
82
82
/// descendants of such transactions. It is not necessary to re-fetch the block to obtain
83
83
/// updated `txdata`.
84
84
pub fn block_connected ( & self , header : & BlockHeader , txdata : & TransactionData , height : u32 ) {
85
+ let mut dependent_txdata = Vec :: new ( ) ;
85
86
let monitors = self . monitors . read ( ) . unwrap ( ) ;
86
87
for monitor in monitors. values ( ) {
87
88
let mut txn_outputs = monitor. block_connected ( header, txdata, height, & * self . broadcaster , & * self . fee_estimator , & * self . logger ) ;
88
89
90
+ // Register any new outputs with the chain source for filtering, storing any dependent
91
+ // transactions from within the block that previously had not been included in txdata.
89
92
if let Some ( ref chain_source) = self . chain_source {
90
93
let block_hash = header. block_hash ( ) ;
91
94
for ( txid, outputs) in txn_outputs. drain ( ..) {
@@ -98,13 +101,21 @@ where C::Target: chain::Filter,
98
101
outpoint : OutPoint { txid, index : * idx as u16 } ,
99
102
script_pubkey : output. script_pubkey . clone ( ) ,
100
103
} ;
101
- if let Some ( ( index , tx ) ) = chain_source. register_output ( output) {
102
- self . block_connected ( header , & [ ( index , & tx ) ] , height ) ;
104
+ if let Some ( tx ) = chain_source. register_output ( output) {
105
+ dependent_txdata . push ( tx ) ;
103
106
}
104
107
}
105
108
}
106
109
}
107
110
}
111
+
112
+ // Recursively call for any dependent transactions that were identified by the chain source.
113
+ if !dependent_txdata. is_empty ( ) {
114
+ dependent_txdata. sort_unstable_by_key ( |( index, _tx) | * index) ;
115
+ dependent_txdata. dedup_by_key ( |( index, _tx) | * index) ;
116
+ let txdata: Vec < _ > = dependent_txdata. iter ( ) . map ( |( index, tx) | ( * index, tx) ) . collect ( ) ;
117
+ self . block_connected ( header, & txdata, height) ;
118
+ }
108
119
}
109
120
110
121
/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view
0 commit comments