[mod] head-watcher: add pubkey in messages

This commit is contained in:
2020-04-30 16:18:23 +02:00
parent 23fbdb458e
commit 1577230a12

View File

@@ -4,7 +4,7 @@ import {WS2PHead} from "duniter/app/modules/ws2p/lib/WS2PCluster";
function handleLateness(confHead: ConfHead, mainHeads: HeadMetric[], observedHead?: TrameWS2P) { function handleLateness(confHead: ConfHead, mainHeads: HeadMetric[], observedHead?: TrameWS2P) {
if (!mainHeads.length) { if (!mainHeads.length) {
throw 'No consensus found' throw 'Observed pubkey ${confHead.observedPubkey}: no consensus found'
} }
if (!observedHead) { if (!observedHead) {
throw `Observed pubkey ${confHead.observedPubkey} not found in heads` throw `Observed pubkey ${confHead.observedPubkey} not found in heads`
@@ -14,7 +14,7 @@ function handleLateness(confHead: ConfHead, mainHeads: HeadMetric[], observedHea
// Check how much late is the node // Check how much late is the node
const farAwayHeads = mainHeads.filter(h => h.blockNumber - observedHead.blockNumber >= confHead.maxLateBlocks) const farAwayHeads = mainHeads.filter(h => h.blockNumber - observedHead.blockNumber >= confHead.maxLateBlocks)
if (farAwayHeads.length) { if (farAwayHeads.length) {
throw `Observed pubkey is too late for ${farAwayHeads.length} consensus by at least ${confHead.maxLateBlocks}` throw `Observed pubkey ${confHead.observedPubkey} is too late for ${farAwayHeads.length} consensus by at least ${confHead.maxLateBlocks}`
} }
} }
} }