@@ -9,7 +9,7 @@ pub(crate) mod bitcoind;
99mod electrum;
1010mod esplora;
1111
12- use std:: collections:: HashMap ;
12+ use std:: collections:: { HashMap , HashSet } ;
1313use std:: sync:: { Arc , Mutex } ;
1414use std:: time:: Duration ;
1515
@@ -84,7 +84,7 @@ impl WalletSyncStatus {
8484
8585pub ( crate ) struct ChainSource {
8686 kind : ChainSourceKind ,
87- registered_txids : Mutex < Vec < Txid > > ,
87+ registered_txids : Mutex < HashSet < Txid > > ,
8888 tx_broadcaster : Arc < Broadcaster > ,
8989 logger : Arc < Logger > ,
9090}
@@ -113,7 +113,7 @@ impl ChainSource {
113113 node_metrics,
114114 ) ?;
115115 let kind = ChainSourceKind :: Esplora ( esplora_chain_source) ;
116- let registered_txids = Mutex :: new ( Vec :: new ( ) ) ;
116+ let registered_txids = Mutex :: new ( HashSet :: new ( ) ) ;
117117 Ok ( ( Self { kind, registered_txids, tx_broadcaster, logger } , None ) )
118118 }
119119
@@ -133,7 +133,7 @@ impl ChainSource {
133133 node_metrics,
134134 ) ;
135135 let kind = ChainSourceKind :: Electrum ( electrum_chain_source) ;
136- let registered_txids = Mutex :: new ( Vec :: new ( ) ) ;
136+ let registered_txids = Mutex :: new ( HashSet :: new ( ) ) ;
137137 ( Self { kind, registered_txids, tx_broadcaster, logger } , None )
138138 }
139139
@@ -156,7 +156,7 @@ impl ChainSource {
156156 ) ;
157157 let best_block = bitcoind_chain_source. poll_best_block ( ) . await . ok ( ) ;
158158 let kind = ChainSourceKind :: Bitcoind ( bitcoind_chain_source) ;
159- let registered_txids = Mutex :: new ( Vec :: new ( ) ) ;
159+ let registered_txids = Mutex :: new ( HashSet :: new ( ) ) ;
160160 ( Self { kind, registered_txids, tx_broadcaster, logger } , best_block)
161161 }
162162
@@ -180,7 +180,7 @@ impl ChainSource {
180180 ) ;
181181 let best_block = bitcoind_chain_source. poll_best_block ( ) . await . ok ( ) ;
182182 let kind = ChainSourceKind :: Bitcoind ( bitcoind_chain_source) ;
183- let registered_txids = Mutex :: new ( Vec :: new ( ) ) ;
183+ let registered_txids = Mutex :: new ( HashSet :: new ( ) ) ;
184184 ( Self { kind, registered_txids, tx_broadcaster, logger } , best_block)
185185 }
186186
@@ -214,7 +214,7 @@ impl ChainSource {
214214 }
215215 }
216216
217- pub ( crate ) fn registered_txids ( & self ) -> Vec < Txid > {
217+ pub ( crate ) fn registered_txids ( & self ) -> HashSet < Txid > {
218218 self . registered_txids . lock ( ) . expect ( "lock" ) . clone ( )
219219 }
220220
@@ -472,7 +472,7 @@ impl ChainSource {
472472
473473impl Filter for ChainSource {
474474 fn register_tx ( & self , txid : & Txid , script_pubkey : & Script ) {
475- self . registered_txids . lock ( ) . expect ( "lock" ) . push ( * txid) ;
475+ self . registered_txids . lock ( ) . expect ( "lock" ) . insert ( * txid) ;
476476 match & self . kind {
477477 ChainSourceKind :: Esplora ( esplora_chain_source) => {
478478 esplora_chain_source. register_tx ( txid, script_pubkey)
0 commit comments