netsize

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughData   = fmt.Errorf("数据不足")
	ErrWrongNumOfPeers = fmt.Errorf("预期的对等节点数量错误")
)
View Source
var (
	MaxMeasurementAge        = 2 * time.Hour // 测量数据的最大有效期
	MinMeasurementsThreshold = 5             // 最小测量数据阈值
	MaxMeasurementsThreshold = 150           // 最大测量数据阈值

)

Functions

func NormedDistance

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

NormedDistance 计算给定键的归一化XOR距离(范围0到1) 参数:

  • p: peer.ID 节点ID
  • k: ks.Key 目标键

返回值:

  • float64 归一化距离

Types

type Estimator

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

Estimator 网络规模估计器

func NewEstimator

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

NewEstimator 创建新的网络规模估计器 参数:

  • localID: peer.ID 本地节点ID
  • rt: *kbucket.RoutingTable 路由表
  • bucketSize: int 桶大小

返回值:

  • *Estimator 网络规模估计器实例

func (*Estimator) NetworkSize

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

NetworkSize 计算当前网络规模估计 返回值:

  • int32 网络规模估计值
  • error 错误信息

func (*Estimator) Track

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

Track 跟踪给定键的对等节点列表以纳入下一次网络规模估计 参数:

  • key: string 目标键(预期不在kademlia键空间中)
  • peers: []peer.ID 对给定键最近的对等节点列表(按距离排序)

返回值:

  • error 错误信息

Jump to

Keyboard shortcuts

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