Documentation
¶
Index ¶
- Variables
- type Acceptor
- type BCLookup
- type Block
- type ConsensusContext
- type Context
- type Decidable
- type EngineState
- type EngineStateManager
- type EngineStateType
- type EngineType
- type Keystore
- type MemoryState
- func (s *MemoryState) AddBlock(blk Block) error
- func (s *MemoryState) AddVertex(vtx Vertex) error
- func (s *MemoryState) GetBlock(blkID ids.ID) (Block, error)
- func (s *MemoryState) GetVertex(vtxID ids.ID) (Vertex, error)
- func (s *MemoryState) IsAccepted(id ids.ID) (bool, error)
- func (s *MemoryState) IsQuantum(id ids.ID) (bool, error)
- func (s *MemoryState) LastAccepted() (ids.ID, error)
- func (s *MemoryState) Preference() []ids.ID
- func (s *MemoryState) RemoveBlock(blkID ids.ID) error
- func (s *MemoryState) RemoveVertex(vtxID ids.ID) error
- func (s *MemoryState) SetLastAccepted(id ids.ID) error
- func (s *MemoryState) SetPreference(ids []ids.ID) error
- func (s *MemoryState) SetQuantum(id ids.ID) error
- type QuasarBlock
- type QuasarVertex
- type SharedMemory
- type State
- type SubnetTracker
- type Vertex
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when an element is not found ErrNotFound = errors.New("not found") // ErrAlreadyExists is returned when an element already exists ErrAlreadyExists = errors.New("already exists") // ErrInvalidStatus is returned when a status transition is invalid ErrInvalidStatus = errors.New("invalid status transition") // ErrMissingCertificate is returned when a required certificate is missing ErrMissingCertificate = errors.New("missing certificate") )
Functions ¶
This section is empty.
Types ¶
type Acceptor ¶
type Acceptor interface {
Accept(*ConsensusContext, ids.ID, []byte) error
}
Acceptor is a function that is called when an element is accepted
type BCLookup ¶
type BCLookup interface {
Lookup(alias string) (ids.ID, error)
PrimaryAlias(id ids.ID) (string, error)
}
BCLookup is the interface for looking up chain IDs by alias
type Block ¶
type Block interface {
Decidable
// Parent returns the ID of this block's parent
Parent() ids.ID
// Verify that the state transition this block would make is valid
Verify() error
// Bytes returns the binary representation of this block
Bytes() []byte
// Height returns the height of this block
Height() uint64
// Timestamp returns the timestamp of this block
Timestamp() int64
}
Block represents a block that can be decided by consensus
type ConsensusContext ¶
type ConsensusContext struct {
// PrimaryAlias is the primary alias of the chain this context is for
PrimaryAlias string
// Registerer is used to register metrics
Registerer prometheus.Registerer
// Context is the context this consensus is running in
*Context
// BlockAcceptor is called when a block is accepted
BlockAcceptor Acceptor
// TxAcceptor is called when a transaction is accepted
TxAcceptor Acceptor
// VertexAcceptor is called when a vertex is accepted
VertexAcceptor Acceptor
}
ConsensusContext is the minimum information a consensus engine needs to run
func (*ConsensusContext) IsBootstrapped ¶
func (ctx *ConsensusContext) IsBootstrapped() bool
IsBootstrapped returns true if the chain is done bootstrapping
type Context ¶
type Context struct {
// NetworkID is the ID of the network this node is connected to
NetworkID uint32
// SubnetID is the ID of the subnet this node validates
SubnetID ids.ID
// ChainID is the ID of the chain this node validates
ChainID ids.ID
// NodeID is the ID of this node
NodeID ids.NodeID
// PublicKey is the BLS public key of this node
PublicKey *bls.PublicKey
// XChainID is the ID of the X-Chain
XChainID ids.ID
// CChainID is the ID of the C-Chain
CChainID ids.ID
// LUXAssetID is the ID of the LUX asset
LUXAssetID ids.ID
// Log is the logger for this consensus
Log log.Logger
// Lock is a general-purpose lock for consensus
Lock sync.RWMutex
// Keystore is the keystore for this node
Keystore Keystore
SharedMemory SharedMemory
// BCLookup maps aliases to chain IDs
BCLookup BCLookup
// Metrics is the metrics registry
Metrics prometheus.Gatherer
// SubnetTracker tracks subnet membership
SubnetTracker SubnetTracker
// ValidatorState is the validator set state
// The primary network's validator set is the union of all subnets' validator sets
ValidatorState validators.State
// ChainDataDir is the directory where chain data is stored
ChainDataDir string
// Quantum-specific fields
QuasarEnabled bool
RingtailSK []byte // Ringtail secret key
RingtailPK []byte // Ringtail public key
}
Context is the shared context for Quasar consensus
type Decidable ¶
type Decidable interface {
// ID returns the unique ID of this element
ID() ids.ID
// Accept marks this element as accepted
Accept() error
// Reject marks this element as rejected
Reject() error
// Status returns the current status
Status() choices.Status
}
Decidable represents an element that can be decided by consensus
type EngineState ¶
type EngineState struct {
Type EngineType
State EngineStateType
}
EngineState is the state of a consensus engine
type EngineStateManager ¶
type EngineStateManager struct {
// contains filtered or unexported fields
}
EngineStateManager manages consensus state
func (*EngineStateManager) Get ¶
func (s *EngineStateManager) Get() EngineState
Get returns the current state
func (*EngineStateManager) Set ¶
func (s *EngineStateManager) Set(state EngineState)
Set sets the current state
type EngineStateType ¶
type EngineStateType uint8
EngineStateType is the state of the consensus engine
const ( // Bootstrapping means the engine is bootstrapping Bootstrapping EngineStateType = iota // NormalOp means the engine is operating normally NormalOp )
type EngineType ¶
type EngineType uint8
EngineType is the type of consensus engine
const ( // EngineTypeUnknown is an unknown engine type EngineTypeUnknown EngineType = iota // EngineTypeBeam is the Beam linear consensus engine EngineTypeBeam // EngineTypeNova is the Nova DAG consensus engine EngineTypeNova // EngineTypeQuasar is the Quasar quantum-secure engine EngineTypeQuasar )
type Keystore ¶
type Keystore interface {
GetUser(username string) (string, error)
AddUser(username string, password string) error
}
Keystore is the interface for the keystore
type MemoryState ¶
type MemoryState struct {
// contains filtered or unexported fields
}
MemoryState is an in-memory implementation of State
func NewMemoryState ¶
func NewMemoryState() *MemoryState
NewMemoryState creates a new in-memory state
func (*MemoryState) AddBlock ¶
func (s *MemoryState) AddBlock(blk Block) error
AddBlock adds a block to the state
func (*MemoryState) AddVertex ¶
func (s *MemoryState) AddVertex(vtx Vertex) error
AddVertex adds a vertex to the state
func (*MemoryState) GetBlock ¶
func (s *MemoryState) GetBlock(blkID ids.ID) (Block, error)
GetBlock returns the block with the given ID
func (*MemoryState) GetVertex ¶
func (s *MemoryState) GetVertex(vtxID ids.ID) (Vertex, error)
GetVertex returns the vertex with the given ID
func (*MemoryState) IsAccepted ¶
func (s *MemoryState) IsAccepted(id ids.ID) (bool, error)
IsAccepted returns true if the block/vertex is accepted
func (*MemoryState) IsQuantum ¶
func (s *MemoryState) IsQuantum(id ids.ID) (bool, error)
IsQuantum returns true if the block/vertex has quantum finality
func (*MemoryState) LastAccepted ¶
func (s *MemoryState) LastAccepted() (ids.ID, error)
LastAccepted returns the last accepted block/vertex
func (*MemoryState) Preference ¶
func (s *MemoryState) Preference() []ids.ID
Preference returns the current preferred frontier
func (*MemoryState) RemoveBlock ¶
func (s *MemoryState) RemoveBlock(blkID ids.ID) error
RemoveBlock removes a block from the state
func (*MemoryState) RemoveVertex ¶
func (s *MemoryState) RemoveVertex(vtxID ids.ID) error
RemoveVertex removes a vertex from the state
func (*MemoryState) SetLastAccepted ¶
func (s *MemoryState) SetLastAccepted(id ids.ID) error
SetLastAccepted sets the last accepted block/vertex
func (*MemoryState) SetPreference ¶
func (s *MemoryState) SetPreference(ids []ids.ID) error
SetPreference sets the preferred frontier
func (*MemoryState) SetQuantum ¶
func (s *MemoryState) SetQuantum(id ids.ID) error
SetQuantum marks a block/vertex as having quantum finality
type QuasarBlock ¶
type QuasarBlock interface {
Block
// HasDualCert returns true if both BLS and RT certificates are present
HasDualCert() bool
// BLSSignature returns the aggregated BLS signature
BLSSignature() []byte
// RTCertificate returns the Ringtail certificate
RTCertificate() []byte
// SetQuantum marks this block as having quantum-secure finality
SetQuantum() error
}
QuasarBlock extends Block with quantum-secure features
type QuasarVertex ¶
type QuasarVertex interface {
Vertex
// HasDualCert returns true if both BLS and RT certificates are present
HasDualCert() bool
// BLSSignature returns the aggregated BLS signature
BLSSignature() []byte
// RTCertificate returns the Ringtail certificate
RTCertificate() []byte
// SetQuantum marks this vertex as having quantum-secure finality
SetQuantum() error
}
QuasarVertex extends Vertex with quantum-secure features
type State ¶
type State interface {
// GetBlock returns the block with the given ID
GetBlock(blkID ids.ID) (Block, error)
// AddBlock adds a block to the state
AddBlock(blk Block) error
// RemoveBlock removes a block from the state
RemoveBlock(blkID ids.ID) error
// GetVertex returns the vertex with the given ID
GetVertex(vtxID ids.ID) (Vertex, error)
// AddVertex adds a vertex to the state
AddVertex(vtx Vertex) error
// RemoveVertex removes a vertex from the state
RemoveVertex(vtxID ids.ID) error
// SetPreference sets the preferred frontier
SetPreference(ids []ids.ID) error
// Preference returns the current preferred frontier
Preference() []ids.ID
// IsAccepted returns true if the block/vertex is accepted
IsAccepted(id ids.ID) (bool, error)
// LastAccepted returns the last accepted block/vertex
LastAccepted() (ids.ID, error)
// SetLastAccepted sets the last accepted block/vertex
SetLastAccepted(id ids.ID) error
// IsQuantum returns true if the block/vertex has quantum finality
IsQuantum(id ids.ID) (bool, error)
// SetQuantum marks a block/vertex as having quantum finality
SetQuantum(id ids.ID) error
}
State represents the consensus state
type SubnetTracker ¶
type SubnetTracker interface {
Tracked(subnetID ids.ID) bool
OnFinishedBootstrapping(subnetID ids.ID) chan struct{}
}
SubnetTracker tracks subnet membership
type Vertex ¶
type Vertex interface {
Decidable
// Parents returns the IDs of this vertex's parents
Parents() []ids.ID
// Verify that the state transition this vertex would make is valid
Verify() error
// Bytes returns the binary representation of this vertex
Bytes() []byte
// Height returns the height of this vertex
Height() uint64
// Epoch returns the epoch of this vertex
Epoch() uint32
// Txs returns the transactions in this vertex
Txs() [][]byte
}
Vertex represents a vertex in a DAG that can be decided by consensus