File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -877,13 +877,19 @@ impl ChainQuery {
877877 self . store . txstore_db . get ( & TxRow :: key ( & txid[ ..] ) )
878878 } ;
879879 if let Some ( result) = result. as_ref ( ) {
880- if let Ok ( mut cache) = self . txs_cache . lock ( ) {
881- let _ = cache. insert ( txid. clone ( ) , result) ;
882- }
880+ self . add_txs_to_cache ( & [ ( * txid, result) ] ) ;
883881 }
884882 result
885883 }
886884
885+ pub fn add_txs_to_cache < T : AsRef < [ u8 ] > > ( & self , txs : & [ ( Txid , T ) ] ) {
886+ if let Ok ( mut cache) = self . txs_cache . lock ( ) {
887+ for ( txid, tx) in txs {
888+ let _ = cache. insert ( * txid, & tx. as_ref ( ) ) ;
889+ }
890+ }
891+ }
892+
887893 pub fn lookup_txo ( & self , outpoint : & OutPoint ) -> Option < TxOut > {
888894 let _timer = self . start_timer ( "lookup_txo" ) ;
889895 lookup_txo ( & self . store . txstore_db , outpoint)
You can’t perform that action at this time.
0 commit comments