diff --git a/packages/backend/src/Chain.ts b/packages/backend/src/Chain.ts index 2eed69e..35c18ae 100644 --- a/packages/backend/src/Chain.ts +++ b/packages/backend/src/Chain.ts @@ -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; }