From f68d79996ea7e32565f6c60787349a173140c8d3 Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Sun, 3 Aug 2025 17:28:28 +0200 Subject: [PATCH] fix: apply modulus in sharding (#3530) --- waku/waku_core/topics/sharding.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/waku/waku_core/topics/sharding.nim b/waku/waku_core/topics/sharding.nim index d2f652161..006850acf 100644 --- a/waku/waku_core/topics/sharding.nim +++ b/waku/waku_core/topics/sharding.nim @@ -25,8 +25,7 @@ proc getGenZeroShard*(s: Sharding, topic: NsContentTopic, count: int): RelayShar # We only use the last 64 bits of the hash as having more shards is unlikely. let hashValue = uint64.fromBytesBE(hash.data[24 .. 31]) - # This is equilavent to modulo shard count but faster - let shard = hashValue and uint64((count - 1)) + let shard = hashValue mod uint64(count) RelayShard(clusterId: s.clusterId, shardId: uint16(shard))