epoch

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 added in v0.9.5

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 added in v0.9.5

func NewActivityLog() *ActivityLog

NewActivityLog is the constructor for ActivityLog.

func (*ActivityLog) Active added in v0.9.5

func (a *ActivityLog) Active(nodeID identity.ID) (active bool)

Active returns true if the provided node was active.

func (*ActivityLog) Add added in v0.9.5

func (a *ActivityLog) Add(nodeID identity.ID) (added bool)

Add adds a node to the activity log.

func (*ActivityLog) Clone added in v0.9.5

func (a *ActivityLog) Clone() *ActivityLog

Clone clones the ActivityLog.

func (*ActivityLog) ForEach added in v0.9.5

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 added in v0.9.5

func (a *ActivityLog) Remove(nodeID identity.ID) (removed bool)

Remove removes a node from the activity log.

func (*ActivityLog) Size added in v0.9.5

func (a *ActivityLog) Size() int

Size returns the size of the activity log.

func (*ActivityLog) String added in v0.9.5

func (a *ActivityLog) String() string

String returns a human-readable version of ActivityLog.

type CommitmentRoots added in v0.9.5

type CommitmentRoots struct {
	TangleRoot        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 added in v0.9.5

func ComputeECR(tangleRoot, stateMutationRoot, stateRoot, manaRoot MerkleRoot) ECR

ComputeECR calculates an ECR from the tree roots.

type ECRecord

type ECRecord struct {
	model.Storable[Index, ECRecord, *ECRecord, ecRecord] `serix:"0"`
}

ECRecord is a storable object represents the ecRecord of an epoch.

func NewECRecord

func NewECRecord(ei Index) (new *ECRecord)

NewECRecord creates and returns a ECRecord of the given EI.

func (*ECRecord) Bytes

func (e *ECRecord) Bytes() (bytes []byte, err error)

func (*ECRecord) ComputeEC added in v0.9.5

func (e *ECRecord) ComputeEC() (ec EC)

ComputeEC calculates the epoch commitment hash from the given ECRecord.

func (*ECRecord) ECR

func (e *ECRecord) ECR() ECR

ECR returns the ECR of an ECRecord.

func (*ECRecord) EI

func (e *ECRecord) EI() Index

func (*ECRecord) FromBytes

func (e *ECRecord) FromBytes(bytes []byte) (err error)

func (*ECRecord) PrevEC

func (e *ECRecord) PrevEC() EC

PrevEC returns the EC of an ECRecord.

func (*ECRecord) Roots added in v0.9.5

func (e *ECRecord) Roots() *CommitmentRoots

Roots returns the CommitmentRoots of an ECRecord.

func (*ECRecord) SetECR

func (e *ECRecord) SetECR(ecr ECR)

SetECR sets the ECR of an ECRecord.

func (*ECRecord) SetEI

func (e *ECRecord) SetEI(ei Index)

func (*ECRecord) SetPrevEC

func (e *ECRecord) SetPrevEC(prevEC EC)

SetPrevEC sets the PrevEC of an ECRecord.

func (*ECRecord) SetRoots added in v0.9.5

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 IndexFromBytes

func IndexFromBytes(bytes []byte) (ei Index, consumedBytes int, err error)

func IndexFromTime

func IndexFromTime(t time.Time) Index

IndexFromTime calculates the EI for the given time.

func (Index) Bytes

func (i Index) Bytes() []byte

func (Index) EndTime

func (i Index) EndTime() time.Time

EndTime calculates the end time of the given epoch.

func (Index) StartTime

func (i Index) StartTime() time.Time

StartTime calculates the start time of the given epoch.

func (Index) String

func (i Index) String() string

type MerkleRoot

type MerkleRoot [blake2b.Size256]byte

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 added in v0.9.5

type NodesActivityLog struct {
	shrinkingmap.ShrinkingMap[Index, *ActivityLog] `serix:"0,lengthPrefixType=uint32"`
}

func NewNodesActivityLog added in v0.9.5

func NewNodesActivityLog() *NodesActivityLog

func (*NodesActivityLog) Bytes added in v0.9.5

func (al *NodesActivityLog) Bytes() []byte

func (*NodesActivityLog) FromBytes added in v0.9.5

func (al *NodesActivityLog) FromBytes(data []byte) (err error)

type SnapshotEpochActivity added in v0.9.5

type SnapshotEpochActivity map[Index]*SnapshotNodeActivity

SnapshotEpochActivity is the data structure to store node activity for the snapshot.

func NewSnapshotEpochActivity added in v0.9.5

func NewSnapshotEpochActivity() SnapshotEpochActivity

NewSnapshotEpochActivity creates a new SnapshotEpochActivity instance.

type SnapshotNodeActivity added in v0.9.5

type SnapshotNodeActivity struct {
	model.Mutable[SnapshotNodeActivity, *SnapshotNodeActivity, nodeActivityModel] `serix:"0"`
}

SnapshotNodeActivity is structure to store nodes activity for an epoch.

func NewSnapshotNodeActivity added in v0.9.5

func NewSnapshotNodeActivity() *SnapshotNodeActivity

NewSnapshotNodeActivity creates a new SnapshotNodeActivity instance.

func (*SnapshotNodeActivity) NodeActivity added in v0.9.5

func (s *SnapshotNodeActivity) NodeActivity(nodeID identity.ID) uint64

NodeActivity returns activity counter for a given node.

func (*SnapshotNodeActivity) NodesLog added in v0.9.5

func (s *SnapshotNodeActivity) NodesLog() map[identity.ID]uint64

NodesLog returns its activity map of nodes.

func (*SnapshotNodeActivity) SetNodeActivity added in v0.9.5

func (s *SnapshotNodeActivity) SetNodeActivity(nodeID identity.ID, activity uint64)

SetNodeActivity adds a node activity record to the activity log.

Jump to

Keyboard shortcuts

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