Documentation
¶
Index ¶
- Constants
- type ConservativeState
- func (cs *ConservativeState) AddTxToMemPool(tx *types.Transaction, checkValidity bool) error
- func (cs *ConservativeState) ApplyLayer(lid types.LayerID, bid types.BlockID, txIDs []types.TransactionID, ...) ([]*types.Transaction, error)
- func (cs *ConservativeState) GetMeshTransaction(id types.TransactionID) (*types.MeshTransaction, error)
- func (cs *ConservativeState) GetProjection(addr types.Address) (uint64, uint64, error)
- func (cs *ConservativeState) GetTransactions(ids []types.TransactionID) ([]*types.Transaction, map[types.TransactionID]struct{})
- func (cs *ConservativeState) GetTransactionsByAddress(from, to types.LayerID, address types.Address) ([]*types.MeshTransaction, error)
- func (cs *ConservativeState) ReinsertTxsToMemPool(ids []types.TransactionID) error
- func (cs *ConservativeState) SelectTXsForProposal(numOfTxs int) ([]types.TransactionID, []*types.Transaction, error)
- func (cs *ConservativeState) StoreTransactionsFromMemPool(layerID types.LayerID, blockID types.BlockID, txIDs []types.TransactionID) error
- func (cs *ConservativeState) Transactions() database.Getter
- type TxHandler
Constants ¶
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 ¶
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 ¶
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 ¶
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.