Add masternodes page/feature

-Added a new "Masternodes" page which displays the current list of masternodes on the network
-/api/getmasternodelist is no longer publicly accessible and has been replaced by /ext/getmasternodelist which returns the masternode list from local collection instead of directly from wallet
-Added new masternode sync options to sync.js and sync.sh
-Added new masternodes_last_updated field to the Stats collection
-Updated delete_database.sh and restore_backup.sh to include support for the new masternodes collection
-Network header menu icon changed to allow the new Masternodes menu item to use the old network icon
This commit is contained in:
joeuhren
2020-12-30 18:22:02 -07:00
parent d787a03fe2
commit be1205d90a
17 changed files with 494 additions and 62 deletions
+39
View File
@@ -23,6 +23,7 @@ function usage() {
console.log('reindex-txcount Rescan and flatten the tx count value for faster access');
console.log('market Updates market summaries, orderbooks, trade history + charts');
console.log('peers Updates peer info based on local wallet connections');
console.log('masternodes Updates the list of active masternodes on the network');
console.log('');
console.log('Notes:');
console.log('- \'current block\' is the latest created block when script is executed.');
@@ -63,6 +64,8 @@ if (process.argv[2] == 'index') {
database = 'market';
} else if (process.argv[2] == 'peers') {
database = 'peers';
} else if (process.argv[2] == 'masternodes') {
database = 'masternodes';
} else {
usage();
}
@@ -236,6 +239,42 @@ if (database == 'peers') {
});
}
});
} else if (database == 'masternodes') {
console.log('syncing masternodes.. please wait..');
// syncing masternodes does not require a lock
mongoose.connect(dbString, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true, useFindAndModify: false }, function(err) {
if (err) {
console.log('Unable to connect to database: %s', dbString);
console.log('Aborting');
exit();
} else {
lib.get_masternodelist(function (body) {
if (body != null) {
lib.syncLoop(body.length, function (loop) {
var i = loop.iteration();
db.save_masternode(body[i], function (success) {
if (success)
loop.next();
else {
console.log('error: cannot save masternode %s.', (body[i].addr ? body[i].addr : 'UNKNOWN'));
exit();
}
});
}, function () {
db.remove_old_masternodes(function (cb) {
db.update_last_updated_stats(settings.coin, { masternodes_last_updated: Math.floor(new Date() / 1000) }, function (cb) {
console.log('masternode sync complete');
exit();
});
});
});
} else {
console.log('no masternodes found');
exit();
}
});
}
});
} else {
// index and market sync requires locking
is_locked(function (exists) {