atxsdata

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 10 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(data *ATX, _ lockGuard) bool

func Warmup

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

Types

type ATX

type ATX struct {
	Node               types.NodeID
	Coinbase           types.Address
	Weight             uint64
	BaseHeight, Height uint64
	Nonce              types.VRFPostIndex
	// contains filtered or unexported fields
}

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(*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.Database, keep types.EpochID) (*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) AddFromHeader added in v1.4.0

func (d *Data) AddFromHeader(atx *types.ActivationTxHeader, nonce types.VRFPostIndex, malicious bool) *ATX

AddFromVerified extracts relevant fields from verified atx 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) 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) 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) 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