atxs

package
v1.5.0-alpha.4-nomain Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CacheKindEpochATXs sql.QueryCacheKind = "epoch-atxs"
	CacheKindATXBlob   sql.QueryCacheKind = "atx-blob"
)

Variables

This section is empty.

Functions

func Add

Add adds an ATX for a given ATX ID.

func AddCheckpointed

func AddCheckpointed(db sql.Executor, catx *CheckpointAtx) error

func AddGettingNonce added in v1.5.0

func AddGettingNonce(db sql.Executor, atx *types.VerifiedActivationTx) (*types.VRFPostIndex, error)

AddGettingNonce adds an ATX for a given ATX ID and returns the nonce for the newly added ATX.

func AddMaybeNoNonce added in v1.5.0

func AddMaybeNoNonce(db sql.Executor, atx *types.VerifiedActivationTx) error

AddMaybeNoNonce adds an ATX for a given ATX ID. It doesn't try to set the nonce field if VRFNonce is not set in the ATX. This function is only to be used for testing.

func All

func All(db sql.Executor) ([]types.ATXID, error)

All gets all atx IDs.

func AtxAdded added in v1.4.2

func AtxAdded(db sql.Executor, atx *types.VerifiedActivationTx)

AtxAdded updates epoch query cache with new ATX, if the query cache is enabled.

func CommitmentATX

func CommitmentATX(db sql.Executor, nodeID types.NodeID) (id types.ATXID, err error)

func CountAtxsByOps added in v1.4.0

func CountAtxsByOps(db sql.Executor, operations builder.Operations) (count uint32, err error)

func FilterAll added in v1.4.0

func FilterAll(types.ATXID) bool

func Get

Get gets an ATX by a given ATX ID.

func GetBlobSizes added in v1.4.1

func GetBlobSizes(db sql.Executor, ids [][]byte) (sizes []int, err error)

GetBlobSizes returns the sizes of the blobs corresponding to ATXs with specified ids. For non-existent ATXs, the corresponding items are set to -1.

func GetByEpochAndNodeID

func GetByEpochAndNodeID(
	db sql.Executor,
	epoch types.EpochID,
	nodeID types.NodeID,
) (*types.VerifiedActivationTx, error)

GetByEpochAndNodeID gets any ATX by the specified NodeID published in the given epoch.

func GetFirstIDByNodeID

func GetFirstIDByNodeID(db sql.Executor, nodeID types.NodeID) (id types.ATXID, err error)

GetFirstIDByNodeID gets the initial ATX ID for a given node ID.

func GetIDByEpochAndNodeID

func GetIDByEpochAndNodeID(db sql.Executor, epoch types.EpochID, nodeID types.NodeID) (id types.ATXID, err error)

GetIDByEpochAndNodeID gets an ATX ID for a given epoch and node ID.

func GetIDWithMaxHeight

func GetIDWithMaxHeight(db sql.Executor, pref types.NodeID, filter Filter) (types.ATXID, error)

GetIDWithMaxHeight returns the ID of the atx from the last 2 epoch with the highest (or tied for the highest) tick height. It is possible that some poet servers are faster than others and the network ends up having its highest ticked atx still in previous epoch and the atxs building on top of it have not been published yet. Selecting from the last two epochs to strike a balance between being fair to honest miners while not giving unfair advantage for malicious actors who retroactively publish a high tick atx many epochs back.

func GetIDsByEpoch

func GetIDsByEpoch(ctx context.Context, db sql.Executor, epoch types.EpochID) (ids []types.ATXID, err error)

GetIDsByEpoch gets ATX IDs for a given epoch.

func GetLastIDByNodeID

func GetLastIDByNodeID(db sql.Executor, nodeID types.NodeID) (id types.ATXID, err error)

GetLastIDByNodeID gets the last ATX ID for a given node ID.

func Has

func Has(db sql.Executor, id types.ATXID) (bool, error)

Has checks if an ATX exists by a given ATX ID.

func IterateAtxsData added in v1.4.0

func IterateAtxsData(
	db sql.Executor,
	from, to types.EpochID,
	fn func(
		id types.ATXID,
		node types.NodeID,
		epoch types.EpochID,
		coinbase types.Address,
		weight uint64,
		base uint64,
		height uint64,
		nonce *types.VRFPostIndex,
		isMalicious bool,
	) bool,
) error

IterateAtxsData iterate over data used for consensus.

func IterateAtxsOps added in v1.4.0

func IterateAtxsOps(
	db sql.Executor,
	operations builder.Operations,
	fn func(*types.VerifiedActivationTx) bool,
) error

func IterateForGrading added in v1.4.3

func IterateForGrading(
	db sql.Executor,
	epoch types.EpochID,
	fn func(id types.ATXID, atxtime, prooftime int64, weight uint64) bool,
) error

IterateForGrading selects every atx from publish epoch and joins identities to load malfeasence proofs if they exist.

func IterateIDsByEpoch added in v1.4.1

func IterateIDsByEpoch(
	db sql.Executor,
	epoch types.EpochID,
	callback func(total int, id types.ATXID) error,
) error

IterateIDsByEpoch invokes the specified callback for each ATX ID in a given epoch. It stops if the callback returns an error.

func LatestEpoch

func LatestEpoch(db sql.Executor) (types.EpochID, error)

LatestEpoch with atxs.

func LoadBlob added in v1.4.1

func LoadBlob(ctx context.Context, db sql.Executor, id []byte, blob *sql.Blob) error

LoadBlob loads ATX as an encoded blob, ready to be sent over the wire.

func NonceByID added in v1.5.0

func NonceByID(db sql.Executor, id types.ATXID) (nonce types.VRFPostIndex, err error)

NonceByID retrieves VRFNonce corresponding to the specified ATX ID.

func SetValidity added in v1.4.0

func SetValidity(db sql.Executor, id types.ATXID, validity types.Validity) error

func VRFNonce

func VRFNonce(db sql.Executor, id types.NodeID, epoch types.EpochID) (nonce types.VRFPostIndex, err error)

VRFNonce gets the VRF nonce of a smesher for a given epoch.

Types

type CheckpointAtx

type CheckpointAtx struct {
	ID             types.ATXID
	Epoch          types.EpochID
	CommitmentATX  types.ATXID
	VRFNonce       types.VRFPostIndex
	NumUnits       uint32
	BaseTickHeight uint64
	TickCount      uint64
	SmesherID      types.NodeID
	Sequence       uint64
	Coinbase       types.Address
}

func LatestN

func LatestN(db sql.Executor, n int) ([]CheckpointAtx, error)

LatestN returns the latest N ATXs per smesher.

type Filter added in v1.4.0

type Filter func(types.ATXID) bool

Jump to

Keyboard shortcuts

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