generator

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHeightDifference uint64 = 10

Variables

View Source
var (
	ErrGetSnapshotOfReferredBlockFailed = errors.New("get snapshotblock of blocks referred failed")
	ErrGetFittestSnapshotBlockFailed    = errors.New("get fittest snapshotblock failed")
	ErrGetVmContextValueFailed          = errors.New("vmcontext's value is nil")
)

Functions

func GetFittestGeneratorSnapshotHash

func GetFittestGeneratorSnapshotHash(chain vm_context.Chain, accAddr *types.Address,
	referredSnapshotHashList []types.Hash, isRandom bool) (prevSbHash *types.Hash, fittestSbHash *types.Hash, err error)

func RecoverVmContext added in v1.3.0

func RecoverVmContext(chain vm_context.Chain, block *ledger.AccountBlock) (vmContextList []vmctxt_interface.VmDatabase, resultErr error)

Types

type ConsensusMessage

type ConsensusMessage struct {
	SnapshotHash types.Hash
	Timestamp    time.Time
	Producer     types.Address
}

type GenResult

type GenResult struct {
	BlockGenList []*vm_context.VmAccountBlock
	IsRetry      bool
	Err          error
}

type Generator

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

func NewGenerator

func NewGenerator(chain vm_context.Chain, snapshotBlockHash, prevBlockHash *types.Hash, addr *types.Address) (*Generator, error)

func (*Generator) GenerateWithBlock

func (gen *Generator) GenerateWithBlock(block *ledger.AccountBlock, signFunc SignFunc) (*GenResult, error)

func (*Generator) GenerateWithMessage

func (gen *Generator) GenerateWithMessage(message *IncomingMessage, signFunc SignFunc) (*GenResult, error)

func (*Generator) GenerateWithOnroad

func (gen *Generator) GenerateWithOnroad(sendBlock ledger.AccountBlock, consensusMsg *ConsensusMessage, signFunc SignFunc, difficulty *big.Int) (*GenResult, error)

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
}

func (*IncomingMessage) ToSendBlock

func (im *IncomingMessage) ToSendBlock() (*ledger.AccountBlock, error)

type SignFunc

type SignFunc func(addr types.Address, data []byte) (signedData, pubkey []byte, err error)

Jump to

Keyboard shortcuts

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