From 834729afeecfce6349ad71b5b88f3d6e77b74405 Mon Sep 17 00:00:00 2001 From: Micah Riggan Date: Tue, 17 Jul 2018 14:38:36 -0400 Subject: [PATCH] Cleanup script --- packages/bitcore-node/src/utils/cleanup.ts | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/bitcore-node/src/utils/cleanup.ts diff --git a/packages/bitcore-node/src/utils/cleanup.ts b/packages/bitcore-node/src/utils/cleanup.ts new file mode 100644 index 00000000000..e533b4f03ae --- /dev/null +++ b/packages/bitcore-node/src/utils/cleanup.ts @@ -0,0 +1,23 @@ +import { BlockModel } from '../models/block'; +import { TransactionModel } from '../models/transaction'; +import { CoinModel } from '../models/coin'; +import { Storage } from '../services/storage'; + +Storage.start({}).then(() => { + BlockModel.collection + .find({}) + .sort({ height: -1 }) + .stream({ + transform: async block => { + const txs = await TransactionModel.collection.find({ blockHash: block.hash }).toArray(); + for(let tx of txs) { + let mints = await CoinModel.collection.find({ mintTxid: tx.txid }).toArray(); + for (let mint of mints) { + if (mint.mintHeight != block.height && block.height > mint.mintHeight) { + console.log(mint); + } + } + } + } + }) +});