@@ -400,21 +400,21 @@ export class Transaction extends BaseModel<ITransaction> {
400
400
if ( ! initialSyncComplete || ! spendOps . length ) {
401
401
return ;
402
402
}
403
- const spentCoinsQuery = {
404
- chain, network, spentHeight : SpentHeightIndicators . pending , $or : spendOps . map ( spendOp => {
405
- return {
406
- mintTxid : spendOp . updateOne . filter . mintTxid ,
407
- mintIndex : spendOp . updateOne . filter . mintIndex ,
408
- spentTxid : { $ne : spendOp . updateOne . update . $set . spentTxid }
409
- }
410
- } )
411
- } ;
412
- const spendingCoins = await CoinModel . collection . find ( spentCoinsQuery ) . toArray ( ) ;
413
- if ( spendingCoins . length ) {
414
- let prunedTxs = { } ;
415
- for ( const coin of spendingCoins ) {
403
+ let prunedTxs = { } ;
404
+ for ( const spendOp of spendOps ) {
405
+ let coin = await CoinModel . collection . findOne ( {
406
+ chain,
407
+ network,
408
+ spentHeight : SpentHeightIndicators . pending ,
409
+ mintTxid : spendOp . updateOne . filter . mintTxid ,
410
+ mintIndex : spendOp . updateOne . filter . mintIndex ,
411
+ spentTxid : { $ne : spendOp . updateOne . update . $set . spentTxid }
412
+ } , { projection : { spentTxid : 1 } } ) ;
413
+ if ( coin ) {
416
414
prunedTxs [ coin . spentTxid ] = true ;
417
415
}
416
+ }
417
+ if ( Object . keys ( prunedTxs ) . length ) {
418
418
prunedTxs = Object . keys ( prunedTxs ) ;
419
419
await Promise . all ( [
420
420
this . collection . update ( { txid : { $in : prunedTxs } } , { $set : { blockHeight : SpentHeightIndicators . conflicting } } , { w : 0 , j : false , multi : true } ) ,
0 commit comments