mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
Two packages were named for the same word and meant different things. network/ dialed peers, exchanged keys, throttled and tracked them; nets/ tracked which chains share a validator set and when they have all bootstrapped. One letter apart, and neither name said which was which. The peer layer is mesh — the word this estate already uses for it, in lux-rs/node's own mesh.rs. That frees network for the thing that is actually a network: a set of chains sharing a validator set. A network holds chains; a chain belongs to one network. github.com/luxfi/p2p stays what it is, the gossip library the VMs use. Three concerns, three names, none of them borrowed from another. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
1011 B
Go
35 lines
1011 B
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package tracker
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// Tracker tracks system resource usage caused by each peer
|
|
type Tracker interface {
|
|
// Usage returns the current usage for a given node at the given time
|
|
Usage(nodeID ids.NodeID, now time.Time) float64
|
|
// TimeUntilUsage returns the duration until the usage drops to the given value
|
|
TimeUntilUsage(nodeID ids.NodeID, now time.Time, value float64) time.Duration
|
|
// TotalUsage returns the total usage across all nodes
|
|
TotalUsage() float64
|
|
}
|
|
|
|
// Targeter determines target resource usage thresholds
|
|
type Targeter interface {
|
|
// TargetUsage returns the target usage threshold
|
|
TargetUsage() uint64
|
|
}
|
|
|
|
// ResourceTracker manages CPU and disk resource tracking
|
|
type ResourceTracker interface {
|
|
// CPUTracker returns the CPU usage tracker
|
|
CPUTracker() Tracker
|
|
// DiskTracker returns the disk usage tracker
|
|
DiskTracker() Tracker
|
|
}
|