From d875994908f3e62239cded2c0235e702dd7d82e8 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 24 Sep 2021 10:36:19 +1000 Subject: [PATCH] Fix hearbeat tick handler rounding issue https://github.com/ChainSafe/js-libp2p-gossipsub/pull/166/commits/807bf282c5289252e9181109ef109ba2d367ff72 --- src/lib/waku_relay/relay_heartbeat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/waku_relay/relay_heartbeat.ts b/src/lib/waku_relay/relay_heartbeat.ts index dc28b2996c..e879f33429 100644 --- a/src/lib/waku_relay/relay_heartbeat.ts +++ b/src/lib/waku_relay/relay_heartbeat.ts @@ -276,7 +276,7 @@ export class RelayHeartbeat extends Heartbeat { const peersList = Array.from(peers).sort( (a, b) => getScore(a) - getScore(b) ); - const medianIndex = peers.size / 2; + const medianIndex = Math.floor(peers.size / 2); const medianScore = getScore(peersList[medianIndex]); // if the median score is below the threshold, select a better peer (if any) and GRAFT