svm

package
v0.2.12-beta-0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const IncomingTxProtocol = state.IncomingTxProtocol

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 SVM

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

SVM is an entry point for all SVM operations.

func New

func New(allStates, processorDb database.Database, projector state.Projector, txPool *mempool.TxMempool, logger log.Log) *SVM

New creates a new `SVM` instance from the given `state` and `logger`.

func (*SVM) AddTxToPool

func (svm *SVM) AddTxToPool(tx *types.Transaction) error

AddTxToPool adds the provided transaction to the transaction pool. The caller is responsible for validating tx beforehand with ValidateNonceAndBalance.

func (*SVM) AddressExists

func (svm *SVM) AddressExists(addr types.Address) bool

AddressExists checks if an account address exists in this node's global state.

func (*SVM) ApplyLayer

func (svm *SVM) ApplyLayer(layerID types.LayerID, transactions []*types.Transaction, rewards map[types.Address]uint64) ([]*types.Transaction, error)

ApplyLayer applies the given rewards to some miners as well as a vector of transactions for the given layer. to miners vector for layer. It returns an error on failure, as well as a vector of failed transactions.

func (*SVM) GetAllAccounts

func (svm *SVM) GetAllAccounts() (*types.MultipleAccountsState, error)

GetAllAccounts returns a dump of all accounts in global state.

func (*SVM) GetBalance

func (svm *SVM) GetBalance(addr types.Address) uint64

GetBalance Retrieve the balance from the given address or 0 if object not found.

func (*SVM) GetLayerApplied

func (svm *SVM) GetLayerApplied(txID types.TransactionID) *types.LayerID

GetLayerApplied gets the layer id at which this tx was applied.

func (*SVM) GetLayerStateRoot

func (svm *SVM) GetLayerStateRoot(layer types.LayerID) (types.Hash32, error)

GetLayerStateRoot returns the state root at a given layer.

func (*SVM) GetNonce

func (svm *SVM) GetNonce(addr types.Address) uint64

GetNonce gets the current nonce of the given addr, if the address is not found it returns 0.

func (*SVM) GetStateRoot

func (svm *SVM) GetStateRoot() types.Hash32

GetStateRoot gets the current state root hash.

func (*SVM) HandleGossipTransaction

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

HandleGossipTransaction handles data received on the transactions gossip channel.

func (*SVM) HandleSyncTransaction

func (svm *SVM) HandleSyncTransaction(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.

func (*SVM) Rewind

func (svm *SVM) Rewind(layer types.LayerID) (types.Hash32, error)

Rewind loads the given layer state from persistent storage. On success, it also returns the current state root hash *after* rewinding.

func (*SVM) SetupGenesis

func (svm *SVM) SetupGenesis(conf *config.GenesisConfig) error

SetupGenesis creates new accounts and adds balances as dictated by `conf`.

func (*SVM) ValidateNonceAndBalance

func (svm *SVM) ValidateNonceAndBalance(transaction *types.Transaction) error

ValidateNonceAndBalance validates that the tx origin account has enough balance to apply the tx, also, it checks that nonce in tx is correct, returns error otherwise.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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