atxsdata

package
v1.3.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Warmup

func Warmup(db sql.Executor, cache *Data) error

Types

type ATX

type ATX struct {
	Node               types.NodeID
	Weight             uint64
	BaseHeight, Height uint64
	Nonce              types.VRFPostIndex
	Malicious          bool
}

type Data

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

func New

func New(opts ...Opt) *Data

func Warm

func Warm(db *sql.Database, opts ...Opt) (*Data, error)

func (*Data) Add

func (d *Data) Add(
	epoch types.EpochID,
	node types.NodeID,
	atx types.ATXID,
	weight, baseHeight, height uint64,
	nonce types.VRFPostIndex,
	malicious bool,
)

func (*Data) Evicted

func (d *Data) Evicted() types.EpochID

func (*Data) Get

func (d *Data) Get(epoch types.EpochID, atx types.ATXID) *ATX

Get returns atx data.

func (*Data) IsEvicted

func (d *Data) IsEvicted(epoch types.EpochID) bool

func (*Data) OnEpoch

func (d *Data) OnEpoch(applied types.EpochID)

OnEpoch is a notification for cache to evict epochs that are not useful to keep in memory.

func (*Data) SetMalicious

func (d *Data) SetMalicious(node types.NodeID)

func (*Data) WeightForSet

func (d *Data) WeightForSet(epoch types.EpochID, set []types.ATXID) (uint64, []bool)

WeightForSet computes total weight of atxs in the set and returned array with atxs in the set that weren't used.

type Opt

type Opt func(*Data)

func WithCapacity

func WithCapacity(capacity types.EpochID) Opt

WithCapacity sets the number of epochs from the latest applied that cache will maintain in memory.

func WithCapacityFromLayers

func WithCapacityFromLayers(window, epochSize uint32) Opt

WithCapacityFromLayers sets capacity to include all layers in the window.

Jump to

Keyboard shortcuts

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