js-waku
js-waku copied to clipboard
fix: use correct shard index when creating encoder
Problem
When library consumer specifies a cluster ID and shard index when creating an encoder, it means they are using static sharding and explicitly specifying which shard index (and thus pubsub topic) should be used.
Currently, when an encoder is created this way, it uses the autosharding algorithm to determine the shard index based on content topic, which can lead to unexpected results if it doesn't match the shard index specified by the consumer.
Solution
- Make
shard
property optional inSingleShardInfo
. - Fix conditional that evaluates to falsy when
shard
is set to0
(this was preventing static sharding from being used)
Notes
- Resolves #1874