netsize

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughData   = fmt.Errorf("not enough data")
	ErrWrongNumOfPeers = fmt.Errorf("expected bucket size number of peers")
)
View Source
var (
	MaxMeasurementAge        = 2 * time.Hour
	MinMeasurementsThreshold = 5
	MaxMeasurementsThreshold = 150
)

Functions

func NormedDistance

func NormedDistance(p peer.ID, k ks.Key) float64

NormedDistance calculates the normed XOR distance of the given keys (from 0 to 1).

Types

type Estimator

type Estimator struct {
	// contains filtered or unexported fields
}

func NewEstimator

func NewEstimator(localID peer.ID, rt *kbucket.RoutingTable, bucketSize int) *Estimator

func (*Estimator) NetworkSize

func (e *Estimator) NetworkSize() (int32, error)

NetworkSize instructs the Estimator to calculate the current network size estimate.

func (*Estimator) Track

func (e *Estimator) Track(key string, peers []peer.ID) error

Track tracks the list of peers for the given key to incorporate in the next network size estimate. key is expected **NOT** to be in the kademlia keyspace and peers is expected to be a sorted list of the closest peers to the given key (the closest first). This function expects peers to have the same length as the routing table bucket size. It also strips old and limits the number of data points (favouring new).

Jump to

Keyboard shortcuts

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