@@ -143,7 +143,7 @@ where
143143 }
144144
145145 match maybe_await ! ( self . get_confirmed_transactions( & sync_state) ) {
146- Ok ( ( confirmed_txs, spent_outputs ) ) => {
146+ Ok ( confirmed_txs) => {
147147 // Double-check the tip hash. If if it changed, a reorg happened since
148148 // we started syncing and we need to restart last-minute.
149149 let check_tip_hash = maybe_await ! ( self . client. get_tip_hash( ) ) ?;
@@ -156,7 +156,6 @@ where
156156 & mut sync_state,
157157 & confirmables,
158158 confirmed_txs,
159- spent_outputs,
160159 ) ;
161160 }
162161 Err ( InternalError :: Inconsistency ) => {
@@ -202,7 +201,6 @@ where
202201
203202 fn sync_confirmed_transactions (
204203 & self , sync_state : & mut SyncState , confirmables : & Vec < & ( dyn Confirm + Sync + Send ) > , confirmed_txs : Vec < ConfirmedTx > ,
205- spent_outputs : HashSet < WatchedOutput > ,
206204 ) {
207205 for ctx in confirmed_txs {
208206 for c in confirmables {
@@ -214,15 +212,17 @@ where
214212 }
215213
216214 sync_state. watched_transactions . remove ( & ctx. tx . txid ( ) ) ;
215+
216+ for input in ctx. tx . input {
217+ sync_state. watched_outputs . remove ( & input. previous_output ) ;
218+ }
217219 }
218-
219- sync_state. watched_outputs = & sync_state. watched_outputs - & spent_outputs;
220220 }
221221
222222 #[ maybe_async]
223223 fn get_confirmed_transactions (
224224 & self , sync_state : & SyncState ,
225- ) -> Result < ( Vec < ConfirmedTx > , HashSet < WatchedOutput > ) , InternalError > {
225+ ) -> Result < Vec < ConfirmedTx > , InternalError > {
226226
227227 // First, check the confirmation status of registered transactions as well as the
228228 // status of dependent transactions of registered outputs.
@@ -235,10 +235,7 @@ where
235235 }
236236 }
237237
238- // Remember all registered outputs that have been spent.
239- let mut spent_outputs = HashSet :: new ( ) ;
240-
241- for output in & sync_state. watched_outputs {
238+ for ( _, output) in & sync_state. watched_outputs {
242239 if let Some ( output_status) = maybe_await ! ( self . client
243240 . get_output_status( & output. outpoint. txid, output. outpoint. index as u64 ) ) ?
244241 {
@@ -252,8 +249,6 @@ where
252249 ) ) ?
253250 {
254251 confirmed_txs. push ( confirmed_tx) ;
255- spent_outputs. insert ( output. clone ( ) ) ;
256- continue ;
257252 }
258253 }
259254 }
@@ -266,7 +261,7 @@ where
266261 tx1. block_height . cmp ( & tx2. block_height ) . then_with ( || tx1. pos . cmp ( & tx2. pos ) )
267262 } ) ;
268263
269- Ok ( ( confirmed_txs, spent_outputs ) )
264+ Ok ( confirmed_txs)
270265 }
271266
272267 #[ maybe_async]
@@ -378,6 +373,6 @@ where
378373
379374 fn register_output ( & self , output : WatchedOutput ) {
380375 let mut locked_queue = self . queue . lock ( ) . unwrap ( ) ;
381- locked_queue. outputs . insert ( output) ;
376+ locked_queue. outputs . insert ( output. outpoint . into_bitcoin_outpoint ( ) , output ) ;
382377 }
383378}
0 commit comments