packer

package
v1.2.0-fix7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadTx

func IsBadTx(err error) bool

IsBadTx not a valid tx.

func IsGasLimitReached

func IsGasLimitReached(err error) bool

IsGasLimitReached block if full of txs.

func IsKnownTx

func IsKnownTx(err error) bool

IsKnownTx tx is already adopted, or in the chain.

func IsTxNotAdoptableNow

func IsTxNotAdoptableNow(err error) bool

IsTxNotAdoptableNow tx can not be adopted now.

func SetGlobPackerInst

func SetGlobPackerInst(p *Packer) bool

Types

type Flow

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

Flow the flow of packing a new block.

func (*Flow) Adopt

func (f *Flow) Adopt(tx *tx.Transaction) error

Adopt try to execute the given transaction. If the tx is valid and can be executed on current state (regardless of VM error), it will be adopted by the new block.

func (*Flow) Pack

func (f *Flow) Pack(privateKey *ecdsa.PrivateKey, blockType uint32, lastKBlock uint32) (*block.Block, *state.Stage, tx.Receipts, error)

Pack build and sign the new block.

func (*Flow) ParentHeader

func (f *Flow) ParentHeader() *block.Header

ParentHeader returns parent block header.

func (*Flow) When

func (f *Flow) When() uint64

When the target time to do packing.

type Packer

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

Packer to pack txs and build new blocks.

var (
	GlobPackerInst *Packer
)

func GetGlobPackerInst

func GetGlobPackerInst() *Packer

func New

func New(
	chain *chain.Chain,
	stateCreator *state.Creator,
	nodeMaster meter.Address,
	beneficiary *meter.Address) *Packer

New create a new Packer instance. The beneficiary is optional, it defaults to endorsor if not set.

func (*Packer) GasLimit

func (p *Packer) GasLimit(parentGasLimit uint64) uint64

func (*Packer) Mock

func (p *Packer) Mock(parent *block.Header, targetTime uint64, gasLimit uint64, candAddr *meter.Address) (*Flow, error)

Mock create a packing flow upon given parent, but with a designated timestamp.

func (*Packer) SetTargetGasLimit

func (p *Packer) SetTargetGasLimit(gl uint64)

SetTargetGasLimit set target gas limit, the Packer will adjust block gas limit close to it as it can.

Jump to

Keyboard shortcuts

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