Help us shape the future of Go! Take the 2026 Go Developer Survey

subnets

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allower

type Allower interface {
	// IsAllowed filters out nodes that are not allowed to connect to this subnet
	IsAllowed(nodeID ids.NodeID, isValidator bool) bool
}
var NoOpAllower Allower = noOpAllower{}

NoOpAllower is an Allower that always returns true

type Config

type Config struct {
	// ValidatorOnly indicates that this Subnet's Chains are available to only subnet validators.
	// No chain related messages will go out to non-validators.
	// Validators will drop messages received from non-validators.
	// Also see [AllowedNodes] to allow non-validators to connect to this Subnet.
	ValidatorOnly bool `json:"validatorOnly" yaml:"validatorOnly"`
	// AllowedNodes is the set of node IDs that are explicitly allowed to connect to this Subnet when
	// ValidatorOnly is enabled.
	AllowedNodes        set.Set[ids.NodeID]   `json:"allowedNodes"        yaml:"allowedNodes"`
	ConsensusParameters binaryvote.Parameters `json:"consensusParameters" yaml:"consensusParameters"`

	// ProposerMinBlockDelay is the minimum delay this node will enforce when
	// building a chain++ block.
	//
	// TODO: Remove this flag once all VMs throttle their own block production.
	ProposerMinBlockDelay time.Duration `json:"proposerMinBlockDelay" yaml:"proposerMinBlockDelay"`
	// ProposerNumHistoricalBlocks is the number of historical chain++ blocks
	// this node will index per chain. If set to 0, the node will index all
	// chain++ blocks.
	//
	// Note: The last accepted block is not considered a historical block. This
	// prevents the user from only storing the last accepted block, which can
	// never be safe due to the non-atomic commits between the proposervm
	// database and the innerVM's database.
	//
	// Invariant: This value must be set such that the proposervm never needs to
	// rollback more blocks than have been deleted. On startup, the proposervm
	// rolls back its accepted chain to match the innerVM's accepted chain. If
	// the innerVM is not persisting its last accepted block quickly enough, the
	// database can become corrupted.
	//
	// TODO: Move this flag once the proposervm is configurable on a per-chain
	// basis.
	ProposerNumHistoricalBlocks uint64 `json:"proposerNumHistoricalBlocks" yaml:"proposerNumHistoricalBlocks"`
}

func (*Config) Valid

func (c *Config) Valid() error

type Subnet

type Subnet interface {
	core.BootstrapTracker

	// AddChain adds a chain to this Subnet
	AddChain(chainID ids.ID) bool

	// Config returns config of this Subnet
	Config() Config

	// AllBootstrapped returns a channel that is closed when all chains are bootstrapped
	AllBootstrapped() <-chan struct{}

	Allower
}

Subnet keeps track of the currently bootstrapping chains in a subnet. If no chains in the subnet are currently bootstrapping, the subnet is considered bootstrapped.

func New

func New(myNodeID ids.NodeID, config Config) Subnet

type Tracker

type Tracker interface {
	// GetSubnet returns the subnet configuration for a given subnet ID
	GetSubnet(subnetID ids.ID) (Subnet, bool)

	// Tracked returns true if the subnet is being tracked
	Tracked(subnetID ids.ID) bool

	// OnFinishedBootstrapping returns a channel that is closed when
	// the subnet finishes bootstrapping
	OnFinishedBootstrapping(subnetID ids.ID) chan struct{}

	// AddSubnet adds a subnet to track
	AddSubnet(subnetID ids.ID, subnet Subnet) error

	// RemoveSubnet removes a subnet from tracking
	RemoveSubnet(subnetID ids.ID) error
}

Tracker tracks information about subnets

func NewTracker

func NewTracker() Tracker

NewTracker creates a new subnet tracker

Jump to

Keyboard shortcuts

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