Skip to content

Commit 3c61e14

Browse files
committed
Should delete a transaction from the mempool if it is in a block
1 parent 0980b3d commit 3c61e14

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/bitcore-node/test/verification/db-verify.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,22 @@ export async function validateDataForBlock(blockNum: number, log = false) {
2323
const blockTxs = await TransactionStorage.collection.find({ chain, network, blockHeight: blockNum }).toArray();
2424
const blockTxids = blockTxs.map(t => t.txid);
2525
const coinsForTx = await CoinStorage.collection.find({ chain, network, mintTxid: { $in: blockTxids } }).toArray();
26+
const mempoolTxs = await TransactionStorage.collection
27+
.find({ chain, network, blockHeight: -1, txid: { $in: blockTxids } })
28+
.toArray();
2629

2730
const seenTxs = {} as { [txid: string]: ITransaction };
2831
const errors = new Array<ErrorType>();
2932

33+
for (const tx of mempoolTxs) {
34+
success = false;
35+
const error = { model: 'transaction', err: true, type: 'DUPE_TRANSACTION', payload: { tx, blockNum } };
36+
errors.push(error);
37+
if (log) {
38+
console.log(JSON.stringify(error));
39+
}
40+
}
41+
3042
const seenTxCoins = {} as { [txid: string]: ICoin[] };
3143
for (let tx of blockTxs) {
3244
if (tx.fee < 0) {

0 commit comments

Comments
 (0)