vm

package
v0.2.17-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateRewards

func CalculateRewards(logger log.Log, cfg RewardConfig, lid types.LayerID, totalFees uint64, rewards []types.AnyReward) ([]*types.Reward, error)

CalculateRewards splits layer rewards and total fees fairly between coinbases recorded in rewards.

Types

type RewardConfig

type RewardConfig struct {
	BaseReward uint64 `mapstructure:"base-reward"`
}

RewardConfig defines the configuration options for Spacemesh rewards.

func DefaultRewardConfig

func DefaultRewardConfig() RewardConfig

DefaultRewardConfig returns the default RewardConfig.

type VM

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

VM manages accounts state.

func New

func New(logger log.Log, db *sql.Database) *VM

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

func (*VM) AddressExists

func (vm *VM) AddressExists(addr types.Address) (bool, error)

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

func (*VM) ApplyLayer

func (vm *VM) ApplyLayer(lid types.LayerID, txs []*types.Transaction, rewards []types.AnyReward) ([]*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 (*VM) GetAllAccounts

func (vm *VM) GetAllAccounts() ([]*types.Account, error)

GetAllAccounts returns a dump of all accounts in global state.

func (*VM) GetBalance

func (vm *VM) GetBalance(addr types.Address) (uint64, error)

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

func (*VM) GetLayerApplied

func (vm *VM) GetLayerApplied(tid types.TransactionID) (types.LayerID, error)

GetLayerApplied returns layer of the applied transaction.

func (*VM) GetLayerStateRoot

func (vm *VM) GetLayerStateRoot(lid types.LayerID) (types.Hash32, error)

GetLayerStateRoot returns the state root at a given layer.

func (*VM) GetNonce

func (vm *VM) GetNonce(addr types.Address) (uint64, error)

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

func (*VM) GetStateRoot

func (vm *VM) GetStateRoot() (types.Hash32, error)

GetStateRoot gets the current state root hash.

func (*VM) Revert

func (vm *VM) Revert(lid types.LayerID) (types.Hash32, error)

Revert all changes that we made after the layer. Returns state hash of the layer.

func (*VM) SetupGenesis

func (vm *VM) SetupGenesis(genesis *config.GenesisConfig) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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