Sync, Update_richlist: Fix memory overflow indexing 1000s of TXs
This commit is contained in:
+34
-1
@@ -49,6 +49,9 @@ if (process.argv[2] == 'index') {
|
||||
case 'reindex':
|
||||
mode = 'reindex';
|
||||
break;
|
||||
case 'reindex-rich':
|
||||
mode = 'reindex-rich';
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
@@ -154,10 +157,12 @@ is_locked(function (exists) {
|
||||
}, function(err3) {
|
||||
Stats.updateOne({coin: settings.coin}, {
|
||||
last: 0,
|
||||
count: 0,
|
||||
supply: 0
|
||||
}, function() {
|
||||
console.log('index cleared (reindex)');
|
||||
});
|
||||
db.update_tx_db(settings.coin, 1, stats.count, settings.update_timeout, function(){
|
||||
db.update_tx_db(settings.coin, 1, stats.count, settings.check_timeout, function(){
|
||||
db.update_richlist('received', function(){
|
||||
db.update_richlist('balance', function(){
|
||||
db.get_stats(settings.coin, function(nstats){
|
||||
@@ -198,6 +203,34 @@ is_locked(function (exists) {
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if (mode == 'reindex-rich') {
|
||||
console.log('update started');
|
||||
db.update_tx_db(settings.coin, stats.last, stats.count, settings.check_timeout, function(){
|
||||
console.log('update finished');
|
||||
db.check_richlist(settings.coin, function(exists){
|
||||
if (exists == true) {
|
||||
console.log('richlist entry found, deleting now..');
|
||||
}
|
||||
db.delete_richlist(settings.coin, function(deleted) {
|
||||
if (deleted == true) {
|
||||
console.log('richlist entry deleted');
|
||||
}
|
||||
db.create_richlist(settings.coin, function() {
|
||||
console.log('richlist created.');
|
||||
db.update_richlist('received', function(){
|
||||
console.log('richlist updated received.');
|
||||
db.update_richlist('balance', function(){
|
||||
console.log('richlist updated balance.');
|
||||
db.get_stats(settings.coin, function(nstats){
|
||||
console.log('update complete (block: %s)', nstats.last);
|
||||
exit();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user