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:
@@ -29,6 +29,8 @@ db.heavies.remove({})
|
||||
db.heavies.drop()
|
||||
db.markets.remove({})
|
||||
db.markets.drop()
|
||||
db.masternodes.remove({})
|
||||
db.masternodes.drop()
|
||||
db.peers.remove({})
|
||||
db.peers.drop()
|
||||
db.richlists.remove({})
|
||||
|
||||
@@ -42,6 +42,8 @@ db.heavies.remove({})
|
||||
db.heavies.drop()
|
||||
db.markets.remove({})
|
||||
db.markets.drop()
|
||||
db.masternodes.remove({})
|
||||
db.masternodes.drop()
|
||||
db.peers.remove({})
|
||||
db.peers.drop()
|
||||
db.richlists.remove({})
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+10
-2
@@ -34,6 +34,10 @@ if [ -n "${1}" ]; then
|
||||
# Peers update
|
||||
MODE="peers"
|
||||
;;
|
||||
"masternodes")
|
||||
# Masternodes update
|
||||
MODE="masternodes"
|
||||
;;
|
||||
*)
|
||||
# Check if this is a file that exists on the filesystem
|
||||
if [ -f ${1} ]; then
|
||||
@@ -75,7 +79,11 @@ if [ -n "${1}" ]; then
|
||||
"peers")
|
||||
# Peers update
|
||||
MODE="peers"
|
||||
;;
|
||||
;;
|
||||
"masternodes")
|
||||
# Masternodes update
|
||||
MODE="masternodes"
|
||||
;;
|
||||
esac
|
||||
elif [ -n "${NODE_PATH}" ]; then
|
||||
# Node path was specified but no mode, so default to 'index update' mode
|
||||
@@ -90,7 +98,7 @@ fi
|
||||
if [ -n "${MODE}" ]; then
|
||||
# Mode is set
|
||||
# Check if the desired mode requires a lock
|
||||
if [ "${MODE}" != "peers" ]; then
|
||||
if [ "${MODE}" != "peers" ] && [ "${MODE}" != "masternodes" ]; then
|
||||
# A lock is required
|
||||
# Check if the script is already running (tmp/index.pid file already exists)
|
||||
if [ -f "${EXPLORER_PATH}/tmp/index.pid" ]; then
|
||||
|
||||
Reference in New Issue
Block a user