Documentation ¶
Index ¶
- Variables
- func ConnectBlock(hs component.ICompSyncRequester, block *types.Block, ...) error
- func FetchTXs(hs component.ICompSyncRequester, maxBlockBodySize uint32) []types.Transaction
- func GetBestBlock(hs component.ICompSyncRequester) *types.Block
- func Lock()
- func LockNonblock() error
- func MaxBlockBodySize() uint32
- func SyncChain(hs *component.ComponentHub, targetHash []byte, targetNo types.BlockNo, ...) error
- func Unlock()
- type BlockGenerator
- func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error)
- func (g *BlockGenerator) GenerateBlock() (*types.Block, error)
- func (g *BlockGenerator) Rejected() *RejTxInfo
- func (g *BlockGenerator) SetNoTTE(noTTE bool) *BlockGenerator
- func (g *BlockGenerator) SetTimeoutTx(tx types.Transaction)
- func (g *BlockGenerator) WithDeco(fn FetchDeco) *BlockGenerator
- type ErrBlockConnect
- type ErrTimeout
- type FetchDeco
- type FetchFn
- type RejTxInfo
- type TxOp
- type TxOpFn
Constants ¶
This section is empty.
Variables ¶
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") )
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. This method is called only when this node produced a block.
func FetchTXs ¶
func FetchTXs(hs component.ICompSyncRequester, maxBlockBodySize uint32) []types.Transaction
FetchTXs requests to mempool and returns types.Tx array.
func GetBestBlock ¶
func GetBestBlock(hs component.ICompSyncRequester) *types.Block
GetBestBlock returns the current best block from chainservice
func LockNonblock ¶
func LockNonblock() error
LockNonblock acquires the chain lock in a non-blocking mode. It returns ErrBestBlock upon failure.
func MaxBlockBodySize ¶
func MaxBlockBodySize() uint32
MaxBlockBodySize returns the maximum block body size.
Types ¶
type BlockGenerator ¶
type BlockGenerator struct {
// contains filtered or unexported fields
}
func NewBlockGenerator ¶
func NewBlockGenerator(hs component.ICompSyncRequester, ctx context.Context, bi *types.BlockHeaderInfo, bState *state.BlockState, txOp TxOp, skipEmpty bool) *BlockGenerator
func (*BlockGenerator) GatherTXs ¶
func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error)
GatherTXs returns transactions from txIn. The selection is done by applying txDo.
func (*BlockGenerator) GenerateBlock ¶
func (g *BlockGenerator) GenerateBlock() (*types.Block, error)
GenerateBlock generate & return a new block.
func (*BlockGenerator) Rejected ¶
func (g *BlockGenerator) Rejected() *RejTxInfo
func (*BlockGenerator) SetNoTTE ¶
func (g *BlockGenerator) SetNoTTE(noTTE bool) *BlockGenerator
func (*BlockGenerator) SetTimeoutTx ¶
func (g *BlockGenerator) SetTimeoutTx(tx types.Transaction)
SetTimeoutTx set bState.timeoutTx to tx.
func (*BlockGenerator) WithDeco ¶
func (g *BlockGenerator) WithDeco(fn FetchDeco) *BlockGenerator
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 ¶
ErrTimeout can be used to indicate for any kind of timeout.
func (ErrTimeout) Error ¶
func (e ErrTimeout) Error() string
type FetchFn ¶
type FetchFn = func(component.ICompSyncRequester, uint32) []types.Transaction
type RejTxInfo ¶
type RejTxInfo struct {
// contains filtered or unexported fields
}
func (*RejTxInfo) Tx ¶
func (r *RejTxInfo) Tx() types.Transaction
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 ¶
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.