nodeconf

package
v0.13.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartitionCount    = 3000
	ReplicationFactor = 3
	// FileV2ReplicationFactor is the replication factor of the v2 file node pool (07c: RF=2)
	FileV2ReplicationFactor = 2
)
View Source
const CName = "common.nodeconf"
View Source
const CNameSource = "common.nodeconf.source"
View Source
const CNameStore = "common.nodeconf.store"

Variables

View Source
var (
	ErrConfigurationNotChanged = errors.New("configuration not changed")
)
View Source
var (
	ErrConfigurationNotFound = errors.New("node nodeConf not found")
)

Functions

func ReplKey

func ReplKey(spaceId string) (replKey string)

Types

type ChangeObserver

type ChangeObserver func(prev, cur NodeConf)

ChangeObserver is called with the previous and the new active configuration.

type ConfigGetter

type ConfigGetter interface {
	GetNodeConf() Configuration
}

type ConfigUpdateGetter

type ConfigUpdateGetter interface {
	GetNodeConfUpdateInterval() int
}

type Configuration

type Configuration struct {
	Id        string `yaml:"id"`
	NetworkId string `yaml:"networkId"`
	// FileNetworkId is the identity of the NodeTypeFileV2 fleet's shared
	// signing key (network string encoding, crypto.DecodeNetworkId) —
	// the key fileV2 durability receipts (networkSign) verify against.
	// Empty on networks without a fileV2 fleet.
	FileNetworkId string    `yaml:"fileNetworkId,omitempty"`
	Nodes         []Node    `yaml:"nodes"`
	CreationTime  time.Time `yaml:"creationTime"`
	// Epoch is a monotonically increasing version of the network configuration.
	// It is incremented on every published topology change and is 0 for
	// configurations that predate epoch support.
	Epoch uint64 `yaml:"epoch,omitempty"`
}

type HistoryStore

type HistoryStore interface {
	Store
	// GetByEpoch returns a previously saved configuration of the given network.
	// Returns ErrConfigurationNotFound if the epoch is not retained.
	GetByEpoch(ctx context.Context, netId string, epoch uint64) (c Configuration, err error)
	// Epochs returns the retained epochs for the given network in ascending order.
	Epochs(ctx context.Context, netId string) (epochs []uint64, err error)
}

HistoryStore is an optional extension of Store that additionally retains previously applied configurations keyed by epoch. It allows a node restarted mid-migration to recompute the ring of an earlier epoch.

type NetworkCompatibilityStatus

type NetworkCompatibilityStatus int
const (
	NetworkCompatibilityStatusUnknown NetworkCompatibilityStatus = iota
	NetworkCompatibilityStatusOk
	NetworkCompatibilityStatusError
	NetworkCompatibilityStatusIncompatible
	NetworkCompatibilityStatusNeedsUpdate
)

type NetworkProtoVersionChecker added in v0.4.28

type NetworkProtoVersionChecker interface {
	IsNetworkNeedsUpdate(ctx context.Context) (bool, error)
}

type Node

type Node struct {
	PeerId    string     `yaml:"peerId" bson:"peerId"`
	Addresses []string   `yaml:"addresses" bson:"addresses"`
	Types     []NodeType `yaml:"types,omitempty" bson:"types"`
}

func (Node) Capacity

func (n Node) Capacity() float64

func (Node) HasType

func (n Node) HasType(t NodeType) bool

func (Node) Id

func (n Node) Id() string

type NodeConf

type NodeConf interface {
	// Id returns current nodeconf id
	Id() string
	// Configuration returns configuration struct
	Configuration() Configuration
	// NodeIds returns list of peerId for given spaceId
	NodeIds(spaceId string) []string
	// IsResponsible checks if current account responsible for given spaceId
	IsResponsible(spaceId string) bool
	// FilePeers returns list of filenodes
	FilePeers() []string
	// FileV2Peers returns the list of v2 filenodes (the NodeTypeFileV2 pool)
	FileV2Peers() []string
	// FileV2NodeIds returns the RF=2 responsible v2 filenodes for a given spaceId.
	// Unlike NodeIds, the current account is NOT excluded: the full responsible pair is
	// returned so a v2 filenode can see its partner (e.g. to derive the leader).
	FileV2NodeIds(spaceId string) []string
	// ConsensusPeers returns list of consensusnodes
	ConsensusPeers() []string
	// CoordinatorPeers returns list of coordinator nodes
	CoordinatorPeers() []string
	// Please see any-ns-node repo for details
	// Usually one network has only 1 naming node, but we support array of NNs
	NamingNodePeers() []string
	// Please see any-pp-node repo for details
	PaymentProcessingNodePeers() []string
	// PeerAddresses returns peer addresses by peer id
	PeerAddresses(peerId string) (addrs []string, ok bool)
	// CHash returns nodes consistent table
	CHash() chash.CHash
	// Partition returns partition number by spaceId
	Partition(spaceId string) (part int)
	// NodeTypes returns list of known nodeTypes by nodeId, if node not registered in configuration will return empty list
	NodeTypes(nodeId string) []NodeType
}

type NodeType

type NodeType string
const (
	NodeTypeTree      NodeType = "tree"
	NodeTypeConsensus NodeType = "consensus"
	NodeTypeFile      NodeType = "file"
	NodeTypeFileV2    NodeType = "fileV2"

	NodeTypeCoordinator           NodeType = "coordinator"
	NodeTypeNamingNode            NodeType = "namingNode"
	NodeTypePaymentProcessingNode NodeType = "paymentProcessingNode"
)

type Service

type Service interface {
	NodeConf
	NetworkCompatibilityStatus() NetworkCompatibilityStatus
	// ObserveChanges registers an observer called every time the active network
	// configuration is replaced. It is not called for the initial configuration.
	// Observers are called sequentially from the configuration update flow and
	// must not block for long.
	ObserveChanges(observer ChangeObserver)
	app.ComponentRunnable
}

func New

func New() Service

type Source

type Source interface {
	GetLast(ctx context.Context, currentId string) (c Configuration, err error)
}

type Store

type Store interface {
	GetLast(ctx context.Context, netId string) (c Configuration, err error)
	SaveLast(ctx context.Context, c Configuration) (err error)
}

Directories

Path Synopsis
Package mock_nodeconf is a generated GoMock package.
Package mock_nodeconf is a generated GoMock package.

Jump to

Keyboard shortcuts

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