added uptime functionality

This commit is contained in:
Marian Oancea
2015-02-05 13:05:21 +02:00
parent 281a5d7f5b
commit 71ae336715
4 changed files with 31 additions and 4 deletions

View File

@@ -15,6 +15,11 @@ var Node = function Node(options, id)
height: 0,
hash: '?',
timestamp: 0
},
uptime: {
down: 0,
inc: 0,
total: 0
}
}
@@ -46,8 +51,12 @@ Node.prototype.update = function()
this.info.stats.active = true;
} else {
this.info.stats.active = false;
this.info.stats.uptime.down++;
}
this.info.stats.uptime.inc++;
this.info.stats.uptime.total = ((this.info.stats.uptime.inc - this.info.stats.uptime.down) / this.info.stats.uptime.inc) * 100;
return this.info;
};