github.com/status-im/status-go@v1.1.0/protocol/requests/set_community_shard.go (about)

     1  package requests
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/status-im/status-go/eth-node/types"
     7  	"github.com/status-im/status-go/protocol/common/shard"
     8  )
     9  
    10  type SetCommunityShard struct {
    11  	CommunityID types.HexBytes  `json:"communityId"`
    12  	Shard       *shard.Shard    `json:"shard,omitempty"`
    13  	PrivateKey  *types.HexBytes `json:"privateKey,omitempty"`
    14  }
    15  
    16  func (s *SetCommunityShard) Validate() error {
    17  	if s == nil {
    18  		return errors.New("invalid request")
    19  	}
    20  	if s.Shard != nil {
    21  		// TODO: for now only MainStatusShard(16) is accepted
    22  		if s.Shard.Cluster != shard.MainStatusShardCluster {
    23  			return errors.New("invalid shard cluster")
    24  		}
    25  		if s.Shard.Index > 1023 {
    26  			return errors.New("invalid shard index. Only 0-1023 is allowed")
    27  		}
    28  	}
    29  	return nil
    30  }