networksharding

package
v1.0.52 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadySet = errors.New("already set")

ErrAlreadySet a sharder is already set

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

ErrBadParams bad parameters

View Source
var ErrNilSharder = errors.New("nil sharder")

ErrNilSharder the sharder is nil

Functions

func Set added in v1.0.40

func Set(s Sharder) error

Set the sharder, can only be done once

Types

type KadPeerShardResolver added in v1.0.40

type KadPeerShardResolver interface {
	ByID(p2p.PeerID) uint32 //ByID get the shard id of the given peer.ID
	IsInterfaceNil() bool   //IsInterfaceNil returns true if there is no value under the interface
}

KadPeerShardResolver peer to shard mapping interface

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
}

Sharder - Main sharder interface

func Get added in v1.0.40

func Get() Sharder

Get the sharder

func NewKadSharder added in v1.0.40

func NewKadSharder(prioBits uint32, kgs KadPeerShardResolver) (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