Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete in activated nodes #12

Merged
merged 2 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ Collection.prototype.removeOldNodes = function()
if( this._items[i].isInactiveAndOld() )
{
deleteList.push(i);
console.log("deleted list : ", deleteList)
}
}

Expand Down
9 changes: 8 additions & 1 deletion lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,16 @@ History.prototype.getCharts = function()
.reverse()
.map(function (item)
{
var interval
if (item.block.time >= 2000) {
// Ignore the time interval since we haven't received the blocks.
interval = 0
} else {
interval = item.block.time
}
return {
height: item.height,
blocktime: item.block.time / 1000,
blocktime: interval / 1000,
difficulty: item.block.difficulty,
uncles: item.block.uncles.length,
transactions: item.block.transactions.length,
Expand Down
4 changes: 2 additions & 2 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var _ = require('lodash');
var trusted = require('./utils/config').trusted;

var MAX_HISTORY = 40;
var MAX_INACTIVE_TIME = 1000*60*60*2;
var MAX_INACTIVE_TIME = 1000*60*5;

var Node = function(data)
{
Expand Down Expand Up @@ -391,7 +391,7 @@ Node.prototype.isInactiveAndOld = function()
// {
// return true;
// }
if(_.now() - this.stats.block.received > MAX_INACTIVE_TIME) {
if(this.stats.block.received > 0 && _.now() - this.stats.block.received > MAX_INACTIVE_TIME) {
return true;
}

Expand Down