diff --git a/packages/bitcore-node/src/models/transaction.ts b/packages/bitcore-node/src/models/transaction.ts index 5ff50fda448..408e70a14bf 100644 --- a/packages/bitcore-node/src/models/transaction.ts +++ b/packages/bitcore-node/src/models/transaction.ts @@ -224,7 +224,7 @@ export class Transaction extends BaseModel { // TODO: Fee is negative for mempool txs fee = groupedSpends[txid].total - groupedMints[txid].total; if (fee < 0) { - console.error(txid, groupedSpends[txid], groupedMints[txid]); + logger.debug('negative fee', txid, groupedSpends[txid], groupedMints[txid]); } } diff --git a/packages/bitcore-node/test/benchmark/benchmark.ts b/packages/bitcore-node/test/benchmark/benchmark.ts index 07cbcc3fd5f..d074435bfbb 100644 --- a/packages/bitcore-node/test/benchmark/benchmark.ts +++ b/packages/bitcore-node/test/benchmark/benchmark.ts @@ -21,6 +21,14 @@ function* generateBlocks(blockCount: number, blockSizeMb: number) { } } +function preGenerateBlocks(blockCount: number, blockSizeMb: number) { + const blocks = new Array(); + for (let block of generateBlocks(blockCount, blockSizeMb)) { + blocks.push(block); + } + return blocks; +} + function generateBlock(blockSizeMb: number, previousBlock?: BitcoinBlockType): BitcoinBlockType { const txAmount = 100000; const prevHash = previousBlock ? previousBlock.hash : ''; @@ -109,11 +117,15 @@ function startBenchmarkDatabase() { async function benchmark(blockCount: number, blockSizeMb: number) { await resetDatabase(); + console.log('Generating blocks'); + const blocks = preGenerateBlocks(blockCount, blockSizeMb); const startTime = new Date(); - for (let block of generateBlocks(blockCount, blockSizeMb)) { - console.log('Adding block', block.hash); + console.log('Adding blocks'); + for (let block of blocks) { + process.stdout.write('.'); await BlockModel.addBlock({ block, chain: 'BENCH', network: 'MARK', initialSyncComplete: false }); } + process.stdout.write('\n'); const endTime = new Date(); const time = endTime.getTime() - startTime.getTime(); const seconds = time / 1000; @@ -123,6 +135,6 @@ async function benchmark(blockCount: number, blockSizeMb: number) { } startBenchmarkDatabase() - .then(() => benchmark(160, 1)) + .then(() => benchmark(80, 1)) .then(() => benchmark(5, 32)) .then(() => process.exit());