Skip to content

Commit

Permalink
Merge pull request bitpay#1950 from micahriggan/fix/set-on-insert-empty
Browse files Browse the repository at this point in the history
fix(node): setOnInsert empty from in memory spends
  • Loading branch information
micahriggan authored Jan 26, 2019
2 parents 0dd7303 + 8f67c03 commit 9082d3d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/bitcore-node/src/models/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ export class TransactionModel extends BaseModel<ITransaction> {
.map(wallet => wallet.wallet);
mintOp.updateOne.update.$set.wallets = transformedWallets;
delete mintOp.updateOne.update.$setOnInsert.wallets;
if (!Object.keys(mintOp.updateOne.update.$setOnInsert).length) {
delete mintOp.updateOne.update.$setOnInsert;
}
return mintOp;
});
}
Expand Down Expand Up @@ -436,6 +439,9 @@ export class TransactionModel extends BaseModel<ITransaction> {
if (sameBlockSpend) {
sameBlockSpend.updateOne.update.$set.spentHeight = height;
delete sameBlockSpend.updateOne.update.$setOnInsert.spentHeight;
if (!Object.keys(sameBlockSpend.updateOne.update.$setOnInsert).length) {
delete sameBlockSpend.updateOne.update.$setOnInsert;
}
sameBlockSpend.updateOne.update.$set.spentTxid = tx._hash;
continue;
}
Expand Down

0 comments on commit 9082d3d

Please sign in to comment.