Documentation ¶
Index ¶
- Variables
- func NewListsSharder(resolver p2p.PeerShardResolver, selfPeerId peer.ID, maxPeerCount int, ...) (*listsSharder, error)
- func NewNilListSharder() *nilListSharder
- func NewOneListSharder(selfPeerId peer.ID, maxPeerCount int) (*oneListSharder, error)
- func NewPrioBitsSharder(prioBits uint32, psp p2p.PeerShardResolver) (*prioBitsSharder, error)
- type Sharder
- type SimplePrioBitsSharder
- func (spbs *SimplePrioBitsSharder) GetDistance(a, b sorting.SortedID) *big.Int
- func (spbs *SimplePrioBitsSharder) GetShard(_ peer.ID) uint32
- func (spbs *SimplePrioBitsSharder) IsInterfaceNil() bool
- func (spbs *SimplePrioBitsSharder) SetPeerShardResolver(_ p2p.PeerShardResolver) error
- func (spbs *SimplePrioBitsSharder) SortList(peers []peer.ID, ref peer.ID) ([]peer.ID, bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBadParams = errors.New("bad parameters")
ErrBadParams bad parameters
Functions ¶
func NewListsSharder ¶
func NewListsSharder( resolver p2p.PeerShardResolver, selfPeerId peer.ID, maxPeerCount int, maxIntraShardValidators int, maxCrossShardValidators int, maxIntraShardObservers int, maxCrossShardObservers int, ) (*listsSharder, error)
NewListsSharder creates a new kad list based kad sharder instance
func NewNilListSharder ¶
func NewNilListSharder() *nilListSharder
NewNilListSharder returns a disabled sharder implementation
func NewOneListSharder ¶
NewOneListSharder creates a new sharder instance that is shard agnostic and uses one list
func NewPrioBitsSharder ¶
func NewPrioBitsSharder(prioBits uint32, psp p2p.PeerShardResolver) (*prioBitsSharder, error)
NewPrioBitsSharder kadSharder constructor prioBits - Number of bits to reset psp - peer shard resolver used to get the shard id for a given peer.ID
Types ¶
type Sharder ¶
type Sharder interface { // GetShard get the shard id of the peer GetShard(id peer.ID) uint32 // GetDistance get the distance between a and b GetDistance(a, b sorting.SortedID) *big.Int // SortList sort the provided peers list SortList(peers []peer.ID, ref peer.ID) ([]peer.ID, bool) IsInterfaceNil() bool }
Sharder - Main sharder interface
type SimplePrioBitsSharder ¶
type SimplePrioBitsSharder struct { }
SimplePrioBitsSharder only uses Kademlia distance in sorting
func (*SimplePrioBitsSharder) GetDistance ¶
func (spbs *SimplePrioBitsSharder) GetDistance(a, b sorting.SortedID) *big.Int
GetDistance Kademlia XOR distance
func (*SimplePrioBitsSharder) GetShard ¶
func (spbs *SimplePrioBitsSharder) GetShard(_ peer.ID) uint32
GetShard always 0
func (*SimplePrioBitsSharder) IsInterfaceNil ¶
func (spbs *SimplePrioBitsSharder) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*SimplePrioBitsSharder) SetPeerShardResolver ¶
func (spbs *SimplePrioBitsSharder) SetPeerShardResolver(_ p2p.PeerShardResolver) error
SetPeerShardResolver will do nothing
Source Files ¶
Click to show internal directories.
Click to hide internal directories.