networksharding

package
v1.0.116 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

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

func NewOneListSharder(
	selfPeerId peer.ID,
	maxPeerCount int,
) (*oneListSharder, error)

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

func (*SimplePrioBitsSharder) SortList

func (spbs *SimplePrioBitsSharder) SortList(peers []peer.ID, ref peer.ID) ([]peer.ID, bool)

SortList sort the list

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL