pendingtxs

package
v0.1.10-docs-prerelease Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pendingtxs exposes the AccountPendingTxs type, which keeps track of transactions that haven't been applied to global state yet. If also provides projectors that predict an account's nonce and balance after those transactions would be applied.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountPendingTxs

type AccountPendingTxs struct {
	PendingTxs map[uint64]map[types.TransactionID]nanoTx // nonce -> TxID -> nanoTx
	// contains filtered or unexported fields
}

AccountPendingTxs indexes the pending transactions (those that are in the mesh, but haven't been applied yet) of a specific account.

func NewAccountPendingTxs

func NewAccountPendingTxs() *AccountPendingTxs

NewAccountPendingTxs returns a new, initialized AccountPendingTxs structure.

func (*AccountPendingTxs) Add

func (apt *AccountPendingTxs) Add(layer types.LayerID, txs ...*types.Transaction)

Add adds transactions to a specific layer. It also updates the highest layer each transaction is included in, if this transaction is already indexed.

func (*AccountPendingTxs) GetProjection

func (apt *AccountPendingTxs) GetProjection(prevNonce, prevBalance uint64) (nonce, balance uint64)

GetProjection provides projected nonce and balance after valid transactions in the AccountPendingTxs would be applied. Since determining which transactions are valid depends on the previous nonce and balance, those must be provided.

func (*AccountPendingTxs) IsEmpty

func (apt *AccountPendingTxs) IsEmpty() bool

IsEmpty is true if there are no transactions in this object.

func (*AccountPendingTxs) RemoveAccepted

func (apt *AccountPendingTxs) RemoveAccepted(accepted []*types.Transaction)

RemoveAccepted removes a list of accepted transactions from the AccountPendingTxs. Since the given transactions were accepted, any other version of the transaction with the same nonce is also discarded.

func (*AccountPendingTxs) RemoveNonce

func (apt *AccountPendingTxs) RemoveNonce(nonce uint64, deleteTx func(id types.TransactionID))

RemoveNonce removes any transaction with the given nonce from AccountPendingTxs. For each transaction removed it also calls the given deleteTx function with the corresponding transaction ID.

func (*AccountPendingTxs) RemoveRejected

func (apt *AccountPendingTxs) RemoveRejected(rejected []*types.Transaction, layer types.LayerID)

RemoveRejected removes a list of rejected transactions from the AccountPendingTxs, assuming they were rejected in the given layer. If any of the listed transactions also appears in a higher layer than the one given, it will not be removed.

func (*AccountPendingTxs) ValidTxs

func (apt *AccountPendingTxs) ValidTxs(prevNonce, prevBalance uint64) (txIds []types.TransactionID, nonce, balance uint64)

ValidTxs provides a list of valid transaction IDs that can be applied from the AccountPendingTxs and a final nonce and balance if they would be applied. The validity of transactions depends on the previous nonce and balance, so those must be provided.

type MeshAndPoolProjector

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

MeshAndPoolProjector provides nonce and balance projections based on unapplied transactions from the mesh and the mempool.

func NewMeshAndPoolProjector

func NewMeshAndPoolProjector(mesh meshProjector, pool poolProjector) *MeshAndPoolProjector

NewMeshAndPoolProjector returns a new MeshAndPoolProjector.

func (*MeshAndPoolProjector) GetProjection

func (p *MeshAndPoolProjector) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64, err error)

GetProjection returns a projected nonce and balance after applying transactions from the mesh and mempool, given the previous values. Errors can stem from database errors in the mesh (IO or deserialization errors).

type StateAndMeshProjector

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

StateAndMeshProjector provides nonce and balance projections based on the global state and unapplied transactions on the mesh.

func NewStateAndMeshProjector

func NewStateAndMeshProjector(state globalState, mesh meshProjector) *StateAndMeshProjector

NewStateAndMeshProjector returns a new StateAndMeshProjector.

func (*StateAndMeshProjector) GetProjection

func (p *StateAndMeshProjector) GetProjection(addr types.Address) (nonce, balance uint64, err error)

GetProjection returns a projected nonce and balance after applying transactions from the mesh on top of the global state. Errors can stem from database errors in the mesh (IO or deserialization errors).

Jump to

Keyboard shortcuts

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