Display block propagation time

This commit is contained in:
maciejhirsz
2018-07-08 16:04:55 +02:00
parent 3259bc67a3
commit 47b80ad30e
10 changed files with 127 additions and 68 deletions
+3
View File
@@ -77,10 +77,13 @@ export default class Chain {
if (node.height > this.height) {
this.height = node.height;
this.blockTimestamp = node.blockTimestamp;
node.propagationTime = 0 as Types.PropagationTime;
this.feeds.broadcast(Feed.bestBlock(this.height, this.blockTimestamp));
console.log(`[${this.label}] New block ${this.height}`);
} else if (node.height === this.height) {
node.propagationTime = (node.blockTimestamp - this.blockTimestamp) as Types.PropagationTime;
}
this.feeds.broadcast(Feed.imported(node));
+2 -1
View File
@@ -25,6 +25,7 @@ export default class Node {
public latency = 0 as Types.Milliseconds;
public blockTime = 0 as Types.Milliseconds;
public blockTimestamp = 0 as Types.Timestamp;
public propagationTime: Maybe<Types.PropagationTime> = null;
private peers = 0 as Types.PeerCount;
private txcount = 0 as Types.TransactionCount;
@@ -132,7 +133,7 @@ export default class Node {
}
public blockDetails(): Types.BlockDetails {
return [this.height, this.best, this.blockTime, this.blockTimestamp];
return [this.height, this.best, this.blockTime, this.blockTimestamp, this.propagationTime];
}
public get average(): number {