Fix propagation time for best block

This commit is contained in:
maciejhirsz
2018-07-14 15:10:11 +02:00
parent ba9931738b
commit 9ea67d716b
+6
View File
@@ -80,12 +80,17 @@ export default class Chain {
private updateBlock(node: Node) {
if (node.height > this.height) {
// New best block
const { height, blockTimestamp } = node;
if (this.blockTimestamp) {
this.updateAverageBlockTime(height, blockTimestamp);
}
for (const otherNode of this.nodes) {
node.propagationTime = null;
}
this.height = height;
this.blockTimestamp = blockTimestamp;
node.propagationTime = 0 as Types.PropagationTime;
@@ -94,6 +99,7 @@ export default class Chain {
console.log(`[${this.label}] New block ${this.height}`);
} else if (node.height === this.height) {
// Caught up to best block
node.propagationTime = (node.blockTimestamp - this.blockTimestamp) as Types.PropagationTime;
}