chain

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQuit indicates that shutdown is initiated.
	ErrQuit = errors.New("shutdown initiated")

	ErrBlockEmpty = errors.New("no transactions in block")
	ErrSyncChain  = errors.New("failed to sync request")
)
View Source
var (
	// ErrBestBlock indicates that the best block is being changed in
	// chainservice soon.
	ErrBestBlock = errors.New("best block changed in chainservice")
)

Functions

func ConnectBlock

func ConnectBlock(hs component.ICompSyncRequester, block *types.Block, blockState *state.BlockState, timeout time.Duration) error

ConnectBlock send an AddBlock request to the chain service.

func FetchTXs

func FetchTXs(hs component.ICompSyncRequester, maxBlockBodySize uint32) []types.Transaction

FetchTXs requests to mempool and returns types.Tx array.

func GatherTXs

func GatherTXs(hs component.ICompSyncRequester, bState *state.BlockState, txOp TxOp, maxBlockBodySize uint32) ([]types.Transaction, error)

GatherTXs returns transactions from txIn. The selection is done by applying txDo.

func GenerateBlock

func GenerateBlock(hs component.ICompSyncRequester, prevBlock *types.Block, bState *state.BlockState, txOp TxOp, ts int64, skipEmpty bool) (*types.Block, error)

GenerateBlock generate & return a new block

func GetBestBlock

func GetBestBlock(hs component.ICompSyncRequester) *types.Block

GetBestBlock returns the current best block from chainservice

func LockChain added in v0.9.0

func LockChain() error

LockChain aquires the chain lock in a non-blocking mode.

func MaxBlockBodySize

func MaxBlockBodySize() uint32

MaxBlockBodySize returns the maximum block body size.

func SyncChain added in v0.9.0

func SyncChain(hs *component.ComponentHub, targetHash []byte, targetNo types.BlockNo, peerID types.PeerID) error

func UnlockChain added in v0.9.0

func UnlockChain()

UnlockChain release the chain lock.

Types

type ErrBlockConnect

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

ErrBlockConnect indicates a error indicating a failed block connected request.

func (ErrBlockConnect) Error

func (e ErrBlockConnect) Error() string

type ErrTimeout

type ErrTimeout struct {
	Kind    string
	Timeout int64
}

ErrTimeout can be used to indicatefor any kind of timeout.

func (ErrTimeout) Error

func (e ErrTimeout) Error() string

type TxOp

type TxOp interface {
	Apply(bState *state.BlockState, tx types.Transaction) error
}

TxOp is an interface used by GatherTXs for apply some transaction related operation.

func NewCompTxOp

func NewCompTxOp(fn ...TxOp) TxOp

NewCompTxOp returns a function which applies each function in fn.

type TxOpFn

type TxOpFn func(bState *state.BlockState, tx types.Transaction) error

TxOpFn is the type of arguments for CompositeTxDo.

func (TxOpFn) Apply

func (f TxOpFn) Apply(bState *state.BlockState, tx types.Transaction) error

Apply applies f to tx.

Jump to

Keyboard shortcuts

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