@@ -143,7 +143,7 @@ where
143
143
}
144
144
145
145
match maybe_await ! ( self . get_confirmed_transactions( & sync_state) ) {
146
- Ok ( ( confirmed_txs, spent_outputs ) ) => {
146
+ Ok ( confirmed_txs) => {
147
147
// Double-check the tip hash. If if it changed, a reorg happened since
148
148
// we started syncing and we need to restart last-minute.
149
149
let check_tip_hash = maybe_await ! ( self . client. get_tip_hash( ) ) ?;
@@ -156,7 +156,6 @@ where
156
156
& mut sync_state,
157
157
& confirmables,
158
158
confirmed_txs,
159
- spent_outputs,
160
159
) ;
161
160
}
162
161
Err ( InternalError :: Inconsistency ) => {
@@ -202,7 +201,6 @@ where
202
201
203
202
fn sync_confirmed_transactions (
204
203
& self , sync_state : & mut SyncState , confirmables : & Vec < & ( dyn Confirm + Sync + Send ) > , confirmed_txs : Vec < ConfirmedTx > ,
205
- spent_outputs : HashSet < WatchedOutput > ,
206
204
) {
207
205
for ctx in confirmed_txs {
208
206
for c in confirmables {
@@ -214,15 +212,17 @@ where
214
212
}
215
213
216
214
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
+ }
217
219
}
218
-
219
- sync_state. watched_outputs = & sync_state. watched_outputs - & spent_outputs;
220
220
}
221
221
222
222
#[ maybe_async]
223
223
fn get_confirmed_transactions (
224
224
& self , sync_state : & SyncState ,
225
- ) -> Result < ( Vec < ConfirmedTx > , HashSet < WatchedOutput > ) , InternalError > {
225
+ ) -> Result < Vec < ConfirmedTx > , InternalError > {
226
226
227
227
// First, check the confirmation status of registered transactions as well as the
228
228
// status of dependent transactions of registered outputs.
@@ -235,10 +235,7 @@ where
235
235
}
236
236
}
237
237
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 {
242
239
if let Some ( output_status) = maybe_await ! ( self . client
243
240
. get_output_status( & output. outpoint. txid, output. outpoint. index as u64 ) ) ?
244
241
{
@@ -252,8 +249,6 @@ where
252
249
) ) ?
253
250
{
254
251
confirmed_txs. push ( confirmed_tx) ;
255
- spent_outputs. insert ( output. clone ( ) ) ;
256
- continue ;
257
252
}
258
253
}
259
254
}
@@ -266,7 +261,7 @@ where
266
261
tx1. block_height . cmp ( & tx2. block_height ) . then_with ( || tx1. pos . cmp ( & tx2. pos ) )
267
262
} ) ;
268
263
269
- Ok ( ( confirmed_txs, spent_outputs ) )
264
+ Ok ( confirmed_txs)
270
265
}
271
266
272
267
#[ maybe_async]
@@ -378,6 +373,6 @@ where
378
373
379
374
fn register_output ( & self , output : WatchedOutput ) {
380
375
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 ) ;
382
377
}
383
378
}
0 commit comments