File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
key-wallet-manager/src/wallet_manager Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ pub struct WalletManager<T: WalletInfoInterface = ManagedWalletInfo> {
9090 network_states : BTreeMap < Network , NetworkState > ,
9191 /// Filter match cache (per network) - caches whether a filter matched
9292 /// This is used for SPV operations to avoid rechecking filters
93- filter_matches : BTreeMap < Network , BTreeMap < BlockHash , bool > > ,
93+ filter_matches : BTreeMap < Network , BTreeMap < BlockHash , Vec < [ u8 ; 32 ] > > > ,
9494}
9595
9696impl < T : WalletInfoInterface > Default for WalletManager < T >
Original file line number Diff line number Diff line change @@ -90,6 +90,13 @@ impl<T: WalletInfoInterface + Send + Sync + 'static> WalletInterface for WalletM
9090 block_hash : & BlockHash ,
9191 network : Network ,
9292 ) -> Vec < [ u8 ; 32 ] > {
93+ // Check if we've already evaluated this filter
94+ if let Some ( network_cache) = self . filter_matches . get ( & network) {
95+ if let Some ( matched) = network_cache. get ( block_hash) {
96+ return matched. clone ( ) ;
97+ }
98+ }
99+
93100 let mut matched_wallet_ids = Vec :: new ( ) ;
94101
95102 // Check each wallet individually to track which ones match
@@ -115,9 +122,11 @@ impl<T: WalletInfoInterface + Send + Sync + 'static> WalletInterface for WalletM
115122 }
116123 }
117124
118- // Cache the result (true if any wallet matched)
119- let any_match = !matched_wallet_ids. is_empty ( ) ;
120- self . filter_matches . entry ( network) . or_default ( ) . insert ( * block_hash, any_match) ;
125+ // Cache the result
126+ self . filter_matches
127+ . entry ( network)
128+ . or_default ( )
129+ . insert ( * block_hash, matched_wallet_ids. clone ( ) ) ;
121130
122131 matched_wallet_ids
123132 }
You can’t perform that action at this time.
0 commit comments