mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-27 14:05:18 +00:00
fix: remove max number of shards verif (#1081)
This commit is contained in:
parent
e29cf0d191
commit
3f69fb3776
@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/waku-org/go-waku/waku/v2/hash"
|
"github.com/waku-org/go-waku/waku/v2/hash"
|
||||||
@ -20,7 +19,6 @@ const ClusterIndex = 1
|
|||||||
const GenerationZeroShardsCount = 8
|
const GenerationZeroShardsCount = 8
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrTooManyShards = errors.New("too many shards")
|
|
||||||
ErrInvalidShard = errors.New("invalid shard")
|
ErrInvalidShard = errors.New("invalid shard")
|
||||||
ErrInvalidShardCount = errors.New("invalid shard count")
|
ErrInvalidShardCount = errors.New("invalid shard count")
|
||||||
ErrExpected130Bytes = errors.New("invalid data: expected 130 bytes")
|
ErrExpected130Bytes = errors.New("invalid data: expected 130 bytes")
|
||||||
@ -32,10 +30,6 @@ type RelayShards struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRelayShards(clusterID uint16, shardIDs ...uint16) (RelayShards, error) {
|
func NewRelayShards(clusterID uint16, shardIDs ...uint16) (RelayShards, error) {
|
||||||
if len(shardIDs) > math.MaxUint8 {
|
|
||||||
return RelayShards{}, ErrTooManyShards
|
|
||||||
}
|
|
||||||
|
|
||||||
shardIDSet := make(map[uint16]struct{})
|
shardIDSet := make(map[uint16]struct{})
|
||||||
for _, index := range shardIDs {
|
for _, index := range shardIDs {
|
||||||
if index > MaxShardIndex {
|
if index > MaxShardIndex {
|
||||||
@ -142,10 +136,6 @@ func (rs RelayShards) ContainsTopic(topic string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rs RelayShards) ShardList() ([]byte, error) {
|
func (rs RelayShards) ShardList() ([]byte, error) {
|
||||||
if len(rs.ShardIDs) > math.MaxUint8 {
|
|
||||||
return nil, ErrTooManyShards
|
|
||||||
}
|
|
||||||
|
|
||||||
var result []byte
|
var result []byte
|
||||||
|
|
||||||
result = binary.BigEndian.AppendUint16(result, rs.ClusterID)
|
result = binary.BigEndian.AppendUint16(result, rs.ClusterID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user