@@ -55,6 +55,15 @@ pub trait ChainWatchInterface: Sync + Send {
55
55
/// bytes are the block height, the next 3 the transaction index within the block, and the
56
56
/// final two the output within the transaction.
57
57
fn get_chain_utxo ( & self , genesis_hash : Sha256dHash , unspent_tx_output_identifier : u64 ) -> Result < ( Script , u64 ) , ChainError > ;
58
+
59
+ /// Gets the list of transactions and transaction indices that the ChainWatchInterface is
60
+ /// watching for.
61
+ fn get_watched_txs ( & self , block : & Block ) -> ( Vec < Transaction > , Vec < u32 > ) ;
62
+
63
+ /// Provides a way for users of the ChainWatchInterface to determine whether its watched
64
+ /// data has been modified since the last time it was read. This is useful for triggering
65
+ /// block rescans.
66
+ fn reentered ( & self ) -> usize ;
58
67
}
59
68
60
69
/// An interface to send a transaction to the Bitcoin network.
@@ -312,6 +321,25 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
312
321
}
313
322
Err ( ChainError :: NotSupported )
314
323
}
324
+
325
+ fn get_watched_txs ( & self , block : & Block ) -> ( Vec < Transaction > , Vec < u32 > ) {
326
+ let mut matched = Vec :: new ( ) ;
327
+ let mut matched_index = Vec :: new ( ) ;
328
+ {
329
+ let watched = self . watched . lock ( ) . unwrap ( ) ;
330
+ for ( index, transaction) in block. txdata . iter ( ) . enumerate ( ) {
331
+ if self . does_match_tx_unguarded ( transaction, & watched) {
332
+ matched. push ( transaction. clone ( ) ) ;
333
+ matched_index. push ( index as u32 ) ;
334
+ }
335
+ }
336
+ }
337
+ ( matched, matched_index)
338
+ }
339
+
340
+ fn reentered ( & self ) -> usize {
341
+ self . reentered . load ( Ordering :: Relaxed )
342
+ }
315
343
}
316
344
317
345
impl ChainWatchInterfaceUtil {
0 commit comments