From e5e1887401f633963a3141154232de0085b64cc4 Mon Sep 17 00:00:00 2001 From: Joe Uhren Date: Sun, 21 Nov 2021 18:09:06 -0700 Subject: [PATCH] Check mode no longer updates the last block height -Also add output displaying which block is currently being checked as before it was almost impossible to determine what, if anything was happening in check mode --- lib/database.js | 6 ++++-- scripts/benchmark.js | 2 +- scripts/sync.js | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/database.js b/lib/database.js index 6ea273f..a80d55e 100644 --- a/lib/database.js +++ b/lib/database.js @@ -955,7 +955,7 @@ module.exports = { }, // updates tx, address & richlist db's; called by sync.js - update_tx_db: function(coin, start, end, txes, timeout, cb) { + update_tx_db: function(coin, start, end, txes, timeout, check_only, cb) { var complete = false; var blocks_to_scan = []; var task_limit_blocks = settings.sync.block_parallel_tasks; @@ -972,11 +972,13 @@ module.exports = { blocks_to_scan.push(i); async.eachLimit(blocks_to_scan, task_limit_blocks, function(block_height, next_block) { - if (block_height % settings.sync.save_stats_after_sync_blocks === 0) { + if (!check_only && block_height % settings.sync.save_stats_after_sync_blocks === 0) { Stats.updateOne({coin: coin}, { last: block_height - 1, txes: txes }, function() {}); + } else if (check_only) { + console.log('checking block ' + block_height + '...'); } lib.get_blockhash(block_height, function(blockhash) { diff --git a/scripts/benchmark.js b/scripts/benchmark.js index e4eb7b2..618cb1d 100644 --- a/scripts/benchmark.js +++ b/scripts/benchmark.js @@ -28,7 +28,7 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni Address.deleteMany({}, function(err2) { var s_timer = new Date().getTime(); - db.update_tx_db(settings.coin.name, 1, COUNT, 0, settings.sync.update_timeout, function() { + db.update_tx_db(settings.coin.name, 1, COUNT, 0, settings.sync.update_timeout, false, function() { var e_timer = new Date().getTime(); Tx.countDocuments({}, function(txerr, txcount) { diff --git a/scripts/sync.js b/scripts/sync.js index 0a79ebc..534bc9c 100644 --- a/scripts/sync.js +++ b/scripts/sync.js @@ -308,7 +308,7 @@ if (database == 'peers') { // Check if the sync msg should be shown check_show_sync_message(stats.count); - db.update_tx_db(settings.coin.name, 1, stats.count, stats.txes, settings.sync.update_timeout, function() { + db.update_tx_db(settings.coin.name, 1, stats.count, stats.txes, settings.sync.update_timeout, false, function() { db.update_richlist('received', function() { db.update_richlist('balance', function() { db.get_stats(settings.coin.name, function(nstats) { @@ -333,7 +333,7 @@ if (database == 'peers') { } else if (mode == 'check') { console.log('starting check.. please wait..'); - db.update_tx_db(settings.coin.name, 1, stats.count, stats.txes, settings.sync.check_timeout, function() { + db.update_tx_db(settings.coin.name, 1, stats.count, stats.txes, settings.sync.check_timeout, true, function() { db.get_stats(settings.coin.name, function(nstats) { console.log('check complete (block: %s)', nstats.last); exit(); @@ -347,7 +347,7 @@ if (database == 'peers') { // Check if the sync msg should be shown check_show_sync_message(count - last); - db.update_tx_db(settings.coin.name, last, count, stats.txes, settings.sync.update_timeout, function() { + db.update_tx_db(settings.coin.name, last, count, stats.txes, settings.sync.update_timeout, false, function() { db.update_richlist('received', function() { db.update_richlist('balance', function() { db.get_stats(settings.coin.name, function(nstats) {