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
This commit is contained in:
Joe Uhren
2021-11-21 18:09:06 -07:00
parent 930b9c4eca
commit e5e1887401
3 changed files with 8 additions and 6 deletions
+4 -2
View File
@@ -955,7 +955,7 @@ module.exports = {
}, },
// updates tx, address & richlist db's; called by sync.js // 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 complete = false;
var blocks_to_scan = []; var blocks_to_scan = [];
var task_limit_blocks = settings.sync.block_parallel_tasks; var task_limit_blocks = settings.sync.block_parallel_tasks;
@@ -972,11 +972,13 @@ module.exports = {
blocks_to_scan.push(i); blocks_to_scan.push(i);
async.eachLimit(blocks_to_scan, task_limit_blocks, function(block_height, next_block) { 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}, { Stats.updateOne({coin: coin}, {
last: block_height - 1, last: block_height - 1,
txes: txes txes: txes
}, function() {}); }, function() {});
} else if (check_only) {
console.log('checking block ' + block_height + '...');
} }
lib.get_blockhash(block_height, function(blockhash) { lib.get_blockhash(block_height, function(blockhash) {
+1 -1
View File
@@ -28,7 +28,7 @@ mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUni
Address.deleteMany({}, function(err2) { Address.deleteMany({}, function(err2) {
var s_timer = new Date().getTime(); 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(); var e_timer = new Date().getTime();
Tx.countDocuments({}, function(txerr, txcount) { Tx.countDocuments({}, function(txerr, txcount) {
+3 -3
View File
@@ -308,7 +308,7 @@ if (database == 'peers') {
// Check if the sync msg should be shown // Check if the sync msg should be shown
check_show_sync_message(stats.count); 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('received', function() {
db.update_richlist('balance', function() { db.update_richlist('balance', function() {
db.get_stats(settings.coin.name, function(nstats) { db.get_stats(settings.coin.name, function(nstats) {
@@ -333,7 +333,7 @@ if (database == 'peers') {
} else if (mode == 'check') { } else if (mode == 'check') {
console.log('starting check.. please wait..'); 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) { db.get_stats(settings.coin.name, function(nstats) {
console.log('check complete (block: %s)', nstats.last); console.log('check complete (block: %s)', nstats.last);
exit(); exit();
@@ -347,7 +347,7 @@ if (database == 'peers') {
// Check if the sync msg should be shown // Check if the sync msg should be shown
check_show_sync_message(count - last); 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('received', function() {
db.update_richlist('balance', function() { db.update_richlist('balance', function() {
db.get_stats(settings.coin.name, function(nstats) { db.get_stats(settings.coin.name, function(nstats) {