networksharding

package
v1.0.71 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadParams = errors.New("bad parameters")

ErrBadParams bad parameters

Functions

This section is empty.

Types

type NoSharder added in v1.0.71

type NoSharder struct {
}

NoSharder default sharder, only uses Kademlia distance in sorting

func (*NoSharder) GetDistance added in v1.0.71

func (ns *NoSharder) GetDistance(a, b sortingID) *big.Int

GetDistance Kademlia XOR distance

func (*NoSharder) GetShard added in v1.0.71

func (ns *NoSharder) GetShard(_ peer.ID) uint32

GetShard always 0

func (*NoSharder) IsInterfaceNil added in v1.0.71

func (ns *NoSharder) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*NoSharder) SortList added in v1.0.71

func (ns *NoSharder) SortList(peers []peer.ID, ref peer.ID) ([]peer.ID, bool)

SortList sort the list

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 sortingID) *big.Int
	// SortList sort the provided peers list
	SortList(peers []peer.ID, ref peer.ID) ([]peer.ID, bool)
	IsInterfaceNil() bool
}

Sharder - Main sharder interface

func NewKadSharder added in v1.0.40

func NewKadSharder(prioBits uint32, kgs p2p.PeerShardResolver) (Sharder, error)

NewKadSharder kadSharder constructor prioBits - Number of reseted bits. f - Callback used to get the shard id for a given peer.ID

Jump to

Keyboard shortcuts

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