Documentation ¶
Index ¶
- Variables
- func IncomingMessageToBlock(vmDb vm_db.VmDb, im *IncomingMessage) (*ledger.AccountBlock, error)
- type Consensus
- type EnvPrepareForGenerator
- type GenResult
- type Generator
- func (gen *Generator) GenerateWithBlock(block *ledger.AccountBlock, fromBlock *ledger.AccountBlock) (*GenResult, error)
- func (gen *Generator) GenerateWithMessage(message *IncomingMessage, producer *types.Address, signFunc SignFunc) (*GenResult, error)
- func (gen *Generator) GenerateWithOnRoad(sendBlock *ledger.AccountBlock, producer *types.Address, signFunc SignFunc, ...) (*GenResult, error)
- func (gen *Generator) GetVMDB() vm_db.VmDb
- type IncomingMessage
- type SignFunc
- type VMGlobalStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrGetLatestAccountBlock defines the error about failing to get latest account block from chain db ErrGetLatestAccountBlock = errors.New("get latest account block failed") // ErrGetLatestSnapshotBlock defines the error about failing to get latest snapshot block from chain db ErrGetLatestSnapshotBlock = errors.New("get latest snapshot block failed") )
Functions ¶
func IncomingMessageToBlock ¶
func IncomingMessageToBlock(vmDb vm_db.VmDb, im *IncomingMessage) (*ledger.AccountBlock, error)
IncomingMessageToBlock returns a complete block by a IncomingMessage.
Types ¶
type Consensus ¶
type Consensus interface {
SBPReader() core.SBPStatReader
}
Consensus is for Vm to read the SBP information
type EnvPrepareForGenerator ¶
type EnvPrepareForGenerator struct { LatestSnapshotHash *types.Hash LatestAccountHash *types.Hash LatestAccountHeight uint64 }
EnvPrepareForGenerator carries the info about the latest state of the world.
func GetAddressStateForGenerator ¶
func GetAddressStateForGenerator(chain stateChain, addr *types.Address) (*EnvPrepareForGenerator, error)
GetAddressStateForGenerator returns the latest state of the world including the account's and snapshot's.
type GenResult ¶
type GenResult struct { VMBlock *vm_db.VmAccountBlock IsRetry bool Err error }
GenResult represents the result of a block being validated by vm.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator implements the logic to generate a account transaction block.
func NewGenerator ¶
func NewGenerator(chain vm_db.Chain, consensus Consensus, addr types.Address, latestSnapshotBlockHash, prevBlockHash *types.Hash) (*Generator, error)
NewGenerator needs to new a vm_db.VmDb with state of the world and SBP information for Vm,
the third "addr" needs to be filled with the address of the account chain to be blocked, and the last needs to be filled with the previous/latest block's hash on the account chain.
func (*Generator) GenerateWithBlock ¶
func (gen *Generator) GenerateWithBlock(block *ledger.AccountBlock, fromBlock *ledger.AccountBlock) (*GenResult, error)
GenerateWithBlock implements the method to generate a transaction with VM execution results from a block which contains the complete transaction info.
func (*Generator) GenerateWithMessage ¶
func (gen *Generator) GenerateWithMessage(message *IncomingMessage, producer *types.Address, signFunc SignFunc) (*GenResult, error)
GenerateWithMessage implements the method to generate a transaction with VM execution results from a IncomingMessage which contains the necessary transaction info.
func (*Generator) GenerateWithOnRoad ¶
func (gen *Generator) GenerateWithOnRoad(sendBlock *ledger.AccountBlock, producer *types.Address, signFunc SignFunc, difficulty *big.Int) (*GenResult, error)
GenerateWithOnRoad implements the method to generate a transaction with VM execution results from a sendBlock(onroad block).
type IncomingMessage ¶
type IncomingMessage struct { BlockType byte AccountAddress types.Address ToAddress *types.Address FromBlockHash *types.Hash TokenId *types.TokenTypeId Amount *big.Int Fee *big.Int Data []byte Difficulty *big.Int }
IncomingMessage carries the necessary transaction info.
type SignFunc ¶
SignFunc is the function type defining the callback when a block requires a method to sign the transaction in generator.
type VMGlobalStatus ¶
type VMGlobalStatus struct {
// contains filtered or unexported fields
}
VMGlobalStatus provides data about random seed.
func NewVMGlobalStatus ¶
func NewVMGlobalStatus(c chain, sb *ledger.SnapshotBlock, fromHash types.Hash) *VMGlobalStatus
NewVMGlobalStatus needs method to get the seed from the snapshot block.
func (*VMGlobalStatus) Seed ¶
func (g *VMGlobalStatus) Seed() (uint64, error)
Seed return the random seed.
func (*VMGlobalStatus) SnapshotBlock ¶
func (g *VMGlobalStatus) SnapshotBlock() *ledger.SnapshotBlock
SnapshotBlock returns the SnapshotBlock to which the seed referred.