atxsdata

package
v1.7.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotMalicious added in v1.4.0

func NotMalicious(d *Data, atx *ATX, _ lockGuard) bool

func Warmup

func Warmup(db sql.Executor, cache *Data, keep types.EpochID, logger *zap.Logger) error

Types

type ATX

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

SAFETY: all exported fields are read-only and are safe to read concurrently. Thanks to the fact that ATX is immutable, it is safe to return a pointer to it.

type AtxFilter added in v1.4.0

type AtxFilter func(*Data, *ATX, lockGuard) bool

AtxFilter is a function that filters atxs. The `lockGuard` prevents using the filter functions outside of the allowed context to prevent data races.

type Data

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

func New

func New() *Data

func Warm

func Warm(db sql.StateDatabase, keep types.EpochID, logger *zap.Logger) (*Data, error)

func (*Data) Add

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

Add adds ATX data to the store. Returns the ATX that was added to the store (if any) or `nil` if it wasn't.

func (*Data) AddAtx added in v1.4.0

func (d *Data) AddAtx(target types.EpochID, id types.ATXID, atx *ATX) bool

Add adds ATX data to the store. Returns whether the ATX was added to the store.

func (*Data) AddFromAtx added in v1.6.0

func (d *Data) AddFromAtx(atx *types.ActivationTx, malicious bool) *ATX

AddFromHeader extracts relevant fields from an ActivationTx and adds them together with nonce and malicious flag. Returns the ATX that was added to the store (if any) or `nil` if it wasn't.

func (*Data) EvictEpoch added in v1.4.3

func (d *Data) EvictEpoch(evict types.EpochID)

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

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. SAFETY: The returned pointer MUST NOT be modified.

func (*Data) IsEvicted

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

func (*Data) IsMalicious added in v1.4.0

func (d *Data) IsMalicious(node types.NodeID) bool

func (*Data) IterateHighTicksInEpoch added in v1.5.4

func (d *Data) IterateHighTicksInEpoch(target types.EpochID, fn func(types.ATXID) bool)

func (*Data) IterateInEpoch added in v1.4.0

func (d *Data) IterateInEpoch(epoch types.EpochID, fn func(types.ATXID, *ATX), filters ...AtxFilter)

IterateInEpoch calls `fn` for every ATX in epoch. If filters are provided, only atxs that pass all filters are returned. SAFETY: The returned pointer MUST NOT be modified.

func (*Data) MaliciousIdentities added in v1.6.8

func (d *Data) MaliciousIdentities() []types.NodeID

func (*Data) MissingInEpoch added in v1.4.0

func (d *Data) MissingInEpoch(epoch types.EpochID, atxs []types.ATXID) []types.ATXID

func (*Data) SetMalicious

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

func (*Data) Size added in v1.5.4

func (d *Data) Size(target types.EpochID) int

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.

Jump to

Keyboard shortcuts

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