js-waku icon indicating copy to clipboard operation
js-waku copied to clipboard

fix: use correct shard index when creating encoder

Open adklempner opened this issue 5 months ago • 2 comments

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 in SingleShardInfo.
  • Fix conditional that evaluates to falsy when shard is set to 0 (this was preventing static sharding from being used)

Notes

  • Resolves #1874

adklempner avatar Mar 05 '24 02:03 adklempner