txs

package
v0.2.14-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const IncomingTxProtocol = "TxGossip"

IncomingTxProtocol is the protocol identifier for tx received by gossip that is used by the p2p.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConservativeState

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

ConservativeState provides the conservative version of the SVM state by taking into accounts of nonce and balances for pending transactions in un-applied blocks and mempool.

func NewConservativeState

func NewConservativeState(state svmState, db *sql.Database, logger log.Log) *ConservativeState

NewConservativeState returns a ConservativeState.

func (*ConservativeState) AddTxToMemPool

func (cs *ConservativeState) AddTxToMemPool(tx *types.Transaction, checkValidity bool) error

AddTxToMemPool adds the provided transaction to the mempool after checking nonce and balance.

func (*ConservativeState) ApplyLayer

func (cs *ConservativeState) ApplyLayer(lid types.LayerID, bid types.BlockID, txIDs []types.TransactionID, rewardByMiner map[types.Address]uint64) ([]*types.Transaction, error)

ApplyLayer applies the transactions specified by the ids to the state.

func (*ConservativeState) GetMeshTransaction

func (cs *ConservativeState) GetMeshTransaction(id types.TransactionID) (*types.MeshTransaction, error)

GetMeshTransaction retrieves a tx by its id.

func (*ConservativeState) GetProjection

func (cs *ConservativeState) GetProjection(addr types.Address) (uint64, uint64, error)

GetProjection returns the projected nonce and balance for the address with pending transactions in un-applied blocks and mempool.

func (*ConservativeState) GetTransactions

func (cs *ConservativeState) GetTransactions(ids []types.TransactionID) ([]*types.Transaction, map[types.TransactionID]struct{})

GetTransactions retrieves a list of txs by their id's.

func (*ConservativeState) GetTransactionsByAddress

func (cs *ConservativeState) GetTransactionsByAddress(from, to types.LayerID, address types.Address) ([]*types.MeshTransaction, error)

GetTransactionsByAddress retrieves txs for a single address in between layers [from, to]. Guarantees that transaction will appear exactly once, even if origin and recipient is the same, and in insertion order.

func (*ConservativeState) ReinsertTxsToMemPool

func (cs *ConservativeState) ReinsertTxsToMemPool(ids []types.TransactionID) error

ReinsertTxsToMemPool reinserts transactions into mempool.

func (*ConservativeState) SelectTXsForProposal

func (cs *ConservativeState) SelectTXsForProposal(numOfTxs int) ([]types.TransactionID, []*types.Transaction, error)

SelectTXsForProposal picks a specific number of random txs for miner to pack in a proposal.

func (*ConservativeState) StoreTransactionsFromMemPool

func (cs *ConservativeState) StoreTransactionsFromMemPool(layerID types.LayerID, blockID types.BlockID, txIDs []types.TransactionID) error

StoreTransactionsFromMemPool takes declared txs from provided proposal and writes them to DB and invalidates the transactions from the mempool.

func (*ConservativeState) Transactions

func (cs *ConservativeState) Transactions() database.Getter

Transactions exports the transactions DB.

type TxHandler

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

TxHandler handles the transactions received via gossip or sync.

func NewTxHandler

func NewTxHandler(s conservativeState, l log.Log) *TxHandler

NewTxHandler returns a new TxHandler.

func (*TxHandler) HandleGossipTransaction

func (th *TxHandler) HandleGossipTransaction(ctx context.Context, _ p2p.Peer, msg []byte) pubsub.ValidationResult

HandleGossipTransaction handles data received on the transactions gossip channel.

func (*TxHandler) HandleSyncTransaction

func (th *TxHandler) HandleSyncTransaction(ctx context.Context, data []byte) error

HandleSyncTransaction handles transactions received via sync. Unlike HandleGossipTransaction, which only stores valid transactions, HandleSyncTransaction only deserializes transactions and stores them regardless of validity. This is because transactions received via sync are necessarily referenced somewhere meaning that we must have them stored, even if they're invalid, for the data availability of the referencing block.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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