Skip to content

Commit

Permalink
Cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
micahriggan committed Jul 17, 2018
1 parent 0c2edee commit 834729a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/bitcore-node/src/utils/cleanup.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
})
});

1 comment on commit 834729a

@leonmende
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leonmendez

Please sign in to comment.