@@ -87,9 +87,20 @@ pub trait Access {
8787/// sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`].
8888/// Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers
8989/// when needed.
90+ ///
91+ /// By using [`Listen::filtered_block_connected`] this interface supports clients fetching the
92+ /// entire header chain and only blocks with matching transaction data using BIP 157 filters or
93+ /// other similar filtering.
9094pub trait Listen {
95+ /// Notifies the listener that a block was added at the given height, with the transaction data
96+ /// possibly filtered.
97+ fn filtered_block_connected ( & self , header : & BlockHeader , txdata : & TransactionData , height : u32 ) ;
98+
9199 /// Notifies the listener that a block was added at the given height.
92- fn block_connected ( & self , block : & Block , height : u32 ) ;
100+ fn block_connected ( & self , block : & Block , height : u32 ) {
101+ let txdata: Vec < _ > = block. txdata . iter ( ) . enumerate ( ) . collect ( ) ;
102+ self . filtered_block_connected ( & block. header , & txdata, height) ;
103+ }
93104
94105 /// Notifies the listener that a block was removed at the given height.
95106 fn block_disconnected ( & self , header : & BlockHeader , height : u32 ) ;
@@ -355,8 +366,8 @@ pub struct WatchedOutput {
355366}
356367
357368impl < T : Listen > Listen for core:: ops:: Deref < Target = T > {
358- fn block_connected ( & self , block : & Block , height : u32 ) {
359- ( * * self ) . block_connected ( block , height) ;
369+ fn filtered_block_connected ( & self , header : & BlockHeader , txdata : & TransactionData , height : u32 ) {
370+ ( * * self ) . filtered_block_connected ( header , txdata , height) ;
360371 }
361372
362373 fn block_disconnected ( & self , header : & BlockHeader , height : u32 ) {
@@ -369,9 +380,9 @@ where
369380 T :: Target : Listen ,
370381 U :: Target : Listen ,
371382{
372- fn block_connected ( & self , block : & Block , height : u32 ) {
373- self . 0 . block_connected ( block , height) ;
374- self . 1 . block_connected ( block , height) ;
383+ fn filtered_block_connected ( & self , header : & BlockHeader , txdata : & TransactionData , height : u32 ) {
384+ self . 0 . filtered_block_connected ( header , txdata , height) ;
385+ self . 1 . filtered_block_connected ( header , txdata , height) ;
375386 }
376387
377388 fn block_disconnected ( & self , header : & BlockHeader , height : u32 ) {
0 commit comments