epoch

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package epoch provides deterministic epoch coordination and swarm assignment for the service node network. It uses consensus-level randomness to assign accounts to swarms in a verifiable manner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentProof

type AssignmentProof struct {
	AccountID      [32]byte     `json:"accountID"`
	EpochID        uint64       `json:"epochID"`
	SwarmID        uint64       `json:"swarmID"`
	NodeIDs        []ids.NodeID `json:"nodeIDs"`
	Randomness     [32]byte     `json:"randomness"`
	AssignmentRoot [32]byte     `json:"assignmentRoot"`
	MerkleProof    [][]byte     `json:"merkleProof"`
}

AssignmentProof is a proof of swarm assignment for a client

func (*AssignmentProof) Hash

func (p *AssignmentProof) Hash() [32]byte

Hash returns a hash of the assignment proof

type Coordinator

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

Coordinator manages epoch transitions and swarm assignments

func NewCoordinator

func NewCoordinator(db database.Database, registry *servicenodevm.Registry, config *servicenodevm.Config) *Coordinator

NewCoordinator creates a new epoch coordinator

func (*Coordinator) GenerateAssignmentProof

func (c *Coordinator) GenerateAssignmentProof(accountID [32]byte) (*AssignmentProof, error)

GenerateAssignmentProof generates a proof of swarm assignment

func (*Coordinator) GetCurrentEpoch

func (c *Coordinator) GetCurrentEpoch() *servicenodevm.Epoch

GetCurrentEpoch returns the current epoch

func (*Coordinator) GetEpoch

func (c *Coordinator) GetEpoch(epochID uint64) (*servicenodevm.Epoch, error)

GetEpoch retrieves an epoch by ID

func (*Coordinator) GetNodesForAccount

func (c *Coordinator) GetNodesForAccount(accountID [32]byte) ([]ids.NodeID, error)

GetNodesForAccount returns the service nodes for an account

func (*Coordinator) GetSwarm

func (c *Coordinator) GetSwarm(swarmID uint64) (*servicenodevm.Swarm, error)

GetSwarm returns a swarm by ID

func (*Coordinator) GetSwarmForAccount

func (c *Coordinator) GetSwarmForAccount(accountID [32]byte) (uint64, error)

GetSwarmForAccount returns the swarm ID for an account

func (*Coordinator) GetSwarmNodes

func (c *Coordinator) GetSwarmNodes(swarmID uint64) ([]ids.NodeID, error)

GetSwarmNodes returns the nodes in a swarm

func (*Coordinator) Load

func (c *Coordinator) Load(ctx context.Context) error

Load loads the current epoch state from database

func (*Coordinator) TransitionEpoch

func (c *Coordinator) TransitionEpoch(ctx context.Context, blockHeight uint64, blockHash [32]byte) (*servicenodevm.Epoch, error)

TransitionEpoch transitions to a new epoch

func (*Coordinator) VerifyAssignmentProof

func (c *Coordinator) VerifyAssignmentProof(proof *AssignmentProof) bool

VerifyAssignmentProof verifies an assignment proof

Jump to

Keyboard shortcuts

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