Merge pull request #310 from matiu/feature/time-on-sync-api

add endTs to status
This commit is contained in:
Matias Alejo Garcia 2014-02-14 11:00:14 -02:00
commit 89f69be119
1 changed files with 11 additions and 1 deletions

View File

@ -91,6 +91,9 @@ function spec() {
return cb(err); return cb(err);
} }
else { else {
self.startTs = parseInt(Date.now()/1000);
// check testnet? // check testnet?
self.rpc.getBlockHash(0, function(err, res){ self.rpc.getBlockHash(0, function(err, res){
if (!err && ( res && res.result !== self.genesis)) { if (!err && ( res && res.result !== self.genesis)) {
@ -121,6 +124,8 @@ function spec() {
syncTipHash: this.sync.tip, syncTipHash: this.sync.tip,
error: this.error, error: this.error,
type: this.type, type: this.type,
startTs: this.startTs,
endTs: this.endTs,
}; };
}; };
@ -199,6 +204,8 @@ function spec() {
} }
if ( self.found && self.syncedBlocks >= self.blockChainHeight ) { if ( self.found && self.syncedBlocks >= self.blockChainHeight ) {
self.endTs = parseInt(Date.now()/1000);
self.status = 'finished'; self.status = 'finished';
p('DONE. Height: ' , self.syncedBlocks); p('DONE. Height: ' , self.syncedBlocks);
return cb(err); return cb(err);
@ -290,8 +297,11 @@ function spec() {
if (blockInfo && blockInfo.hash) { if (blockInfo && blockInfo.hash) {
self.syncedBlocks++; self.syncedBlocks++;
} else }
else {
self.endTs = parseInt(Date.now()/1000);
self.status = 'finished'; self.status = 'finished';
}
return cb(err); return cb(err);
}); });