Documentation ¶
Index ¶
- Variables
- type ActivityLog
- func (a *ActivityLog) Active(nodeID identity.ID) (active bool)
- func (a *ActivityLog) Add(nodeID identity.ID) (added bool)
- func (a *ActivityLog) Clone() *ActivityLog
- func (a *ActivityLog) ForEach(callback func(nodeID identity.ID) (err error)) (err error)
- func (a *ActivityLog) Remove(nodeID identity.ID) (removed bool)
- func (a *ActivityLog) Size() int
- func (a *ActivityLog) String() string
- type CommitmentRoots
- type EC
- type ECR
- type ECRecord
- func (e *ECRecord) Bytes() (bytes []byte, err error)
- func (e *ECRecord) ComputeEC() (ec EC)
- func (e *ECRecord) ECR() ECR
- func (e *ECRecord) EI() Index
- func (e *ECRecord) FromBytes(bytes []byte) (err error)
- func (e *ECRecord) PrevEC() EC
- func (e *ECRecord) Roots() *CommitmentRoots
- func (e *ECRecord) SetECR(ecr ECR)
- func (e *ECRecord) SetEI(ei Index)
- func (e *ECRecord) SetPrevEC(prevEC EC)
- func (e *ECRecord) SetRoots(roots *CommitmentRoots)
- type Index
- type MerkleRoot
- type NodesActivityLog
- type SnapshotEpochActivity
- type SnapshotNodeActivity
Constants ¶
This section is empty.
Variables ¶
var ( // GenesisTime is the time (Unix in seconds) of the genesis. GenesisTime int64 = 1662385954 // Duration is the default epoch duration in seconds. Duration int64 = 10 )
Functions ¶
This section is empty.
Types ¶
type ActivityLog ¶
type ActivityLog struct { model.Mutable[ActivityLog, *ActivityLog, activityLogModel] `serix:"0"` }
ActivityLog is a time-based log of node activity. It stores information when a node is active and provides functionality to query for certain timeframes.
func NewActivityLog ¶
func NewActivityLog() *ActivityLog
NewActivityLog is the constructor for ActivityLog.
func (*ActivityLog) Active ¶
func (a *ActivityLog) Active(nodeID identity.ID) (active bool)
Active returns true if the provided node was active.
func (*ActivityLog) Add ¶
func (a *ActivityLog) Add(nodeID identity.ID) (added bool)
Add adds a node to the activity log.
func (*ActivityLog) Clone ¶
func (a *ActivityLog) Clone() *ActivityLog
Clone clones the ActivityLog.
func (*ActivityLog) ForEach ¶
func (a *ActivityLog) ForEach(callback func(nodeID identity.ID) (err error)) (err error)
ForEach iterates through the activity set and calls the callback for every element.
func (*ActivityLog) Remove ¶
func (a *ActivityLog) Remove(nodeID identity.ID) (removed bool)
Remove removes a node from the activity log.
func (*ActivityLog) Size ¶
func (a *ActivityLog) Size() int
Size returns the size of the activity log.
func (*ActivityLog) String ¶
func (a *ActivityLog) String() string
String returns a human-readable version of ActivityLog.
type CommitmentRoots ¶
type CommitmentRoots struct { MeshRoot MerkleRoot `serix:"0"` StateMutationRoot MerkleRoot `serix:"1"` StateRoot MerkleRoot `serix:"2"` ManaRoot MerkleRoot `serix:"3"` }
CommitmentRoots contains roots of trees of an epoch.
type EC ¶
type EC = MerkleRoot
type ECR ¶
type ECR = MerkleRoot
func ComputeECR ¶
func ComputeECR(meshRoot, stateMutationRoot, stateRoot, manaRoot MerkleRoot) ECR
ComputeECR calculates an ECR from the tree roots.
type ECRecord ¶
ECRecord is a storable object represents the ecRecord of an epoch.
func NewECRecord ¶
NewECRecord creates and returns a ECRecord of the given EI.
func (*ECRecord) ComputeEC ¶
ComputeEC calculates the epoch commitment hash from the given ECRecord.
func (*ECRecord) Roots ¶
func (e *ECRecord) Roots() *CommitmentRoots
Roots returns the CommitmentRoots of an ECRecord.
func (*ECRecord) SetRoots ¶
func (e *ECRecord) SetRoots(roots *CommitmentRoots)
SetRoots sets the CommitmentRoots of an ECRecord.
type Index ¶
type Index int64
Index is the ID of an epoch.
func IndexFromTime ¶
IndexFromTime calculates the EI for the given time.
type MerkleRoot ¶
func NewMerkleRoot ¶
func NewMerkleRoot(bytes []byte) MerkleRoot
func (MerkleRoot) Base58 ¶
func (m MerkleRoot) Base58() string
func (MerkleRoot) Bytes ¶
func (m MerkleRoot) Bytes() []byte
type NodesActivityLog ¶
type NodesActivityLog struct { shrinkingmap.ShrinkingMap[Index, *ActivityLog] `serix:"0,lengthPrefixType=uint32"` }
func NewNodesActivityLog ¶
func NewNodesActivityLog() *NodesActivityLog
func (*NodesActivityLog) Bytes ¶
func (al *NodesActivityLog) Bytes() []byte
func (*NodesActivityLog) FromBytes ¶
func (al *NodesActivityLog) FromBytes(data []byte) (err error)
type SnapshotEpochActivity ¶
type SnapshotEpochActivity map[Index]*SnapshotNodeActivity
SnapshotEpochActivity is the data structure to store node activity for the snapshot.
func NewSnapshotEpochActivity ¶
func NewSnapshotEpochActivity() SnapshotEpochActivity
NewSnapshotEpochActivity creates a new SnapshotEpochActivity instance.
type SnapshotNodeActivity ¶
type SnapshotNodeActivity struct { model.Mutable[SnapshotNodeActivity, *SnapshotNodeActivity, nodeActivityModel] `serix:"0"` }
SnapshotNodeActivity is structure to store nodes activity for an epoch.
func NewSnapshotNodeActivity ¶
func NewSnapshotNodeActivity() *SnapshotNodeActivity
NewSnapshotNodeActivity creates a new SnapshotNodeActivity instance.
func (*SnapshotNodeActivity) NodeActivity ¶
func (s *SnapshotNodeActivity) NodeActivity(nodeID identity.ID) uint64
NodeActivity returns activity counter for a given node.
func (*SnapshotNodeActivity) NodesLog ¶
func (s *SnapshotNodeActivity) NodesLog() map[identity.ID]uint64
NodesLog returns its activity map of nodes.
func (*SnapshotNodeActivity) SetNodeActivity ¶
func (s *SnapshotNodeActivity) SetNodeActivity(nodeID identity.ID, activity uint64)
SetNodeActivity adds a node activity record to the activity log.