Documentation ¶
Index ¶
- func ValidSateRootForTest(preStateRoot common.Hash, economyModel economy_model.EconomyModel, ...) error
- func ValidTxSender(tx model.AbstractTransaction, chain ChainInterface, blockHeight uint64) error
- func ValidTxSize(tx model.AbstractTransaction) error
- type BftBlockContext
- type BftBlockContextWithoutVotes
- type BftBlockValidator
- type BlockContext
- type BlockProcessor
- type ChainHelper
- type ChainInterface
- type Middleware
- func InsertBlock(c *BlockContext) Middleware
- func NextRoundVerifier(c *BlockContext) Middleware
- func UpdateBlockVerifier(c *BlockContext) Middleware
- func UpdateStateRoot(c *BlockContext) Middleware
- func ValidBlockVerifier(c *BlockContext) Middleware
- func ValidStateRoot(c *BlockContext) Middleware
- func ValidTxByType(tx model.AbstractTransaction, chain ChainInterface, blockHeight uint64) Middleware
- func ValidateBlockCoinBase(c *BlockContext) Middleware
- func ValidateBlockDifficulty(c *BlockContext) Middleware
- func ValidateBlockHash(c *BlockContext) Middleware
- func ValidateBlockNumber(c *BlockContext) Middleware
- func ValidateBlockSize(c *BlockContext) Middleware
- func ValidateBlockTime(c *BlockContext) Middleware
- func ValidateBlockTxs(c *BlockContext) Middleware
- func ValidateBlockVersion(c *BlockContext) Middleware
- func ValidateSeed(c *BlockContext) Middleware
- func ValidateVotes(c *BftBlockContext) Middleware
- func ValidateVotesForBFT(c *BlockContext) Middleware
- type MiddlewareChain
- type MiddlewareContext
- type StateHelper
- type StateReader
- type StateWriter
- type TxValidatorForRpcService
- type VerifierHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidSateRootForTest ¶
func ValidSateRootForTest(preStateRoot common.Hash, economyModel economy_model.EconomyModel, blockProcess BlockProcessor, processBlock model.AbstractBlock) error
func ValidTxSender ¶
func ValidTxSender(tx model.AbstractTransaction, chain ChainInterface, blockHeight uint64) error
valid sender and amount
func ValidTxSize ¶
func ValidTxSize(tx model.AbstractTransaction) error
Types ¶
type BftBlockContext ¶
type BftBlockContext struct { BlockContext Votes []model.AbstractVerification }
func NewBftBlockContext ¶
func NewBftBlockContext(b model.AbstractBlock, votes []model.AbstractVerification, chain ChainInterface) *BftBlockContext
type BftBlockContextWithoutVotes ¶
type BftBlockContextWithoutVotes struct {
BlockContext
}
func NewBftBlockContextWithoutVotes ¶
func NewBftBlockContextWithoutVotes(b model.AbstractBlock, chain ChainInterface) *BftBlockContextWithoutVotes
type BftBlockValidator ¶
type BftBlockValidator struct {
Chain ChainInterface
}
func NewBftBlockValidator ¶
func NewBftBlockValidator(chain ChainInterface) *BftBlockValidator
func (*BftBlockValidator) FullValid ¶
func (v *BftBlockValidator) FullValid(b model.AbstractBlock) error
func (*BftBlockValidator) Valid ¶
func (v *BftBlockValidator) Valid(b model.AbstractBlock) error
type BlockContext ¶
type BlockContext struct { MiddlewareContext // the block to be handled Block model.AbstractBlock // chain Chain ChainInterface }
visit chain, db, state_root through processor
func NewBlockContext ¶
func NewBlockContext(block model.AbstractBlock, chain ChainInterface) *BlockContext
type BlockProcessor ¶
type BlockProcessor func(root common.Hash) (*chain.BlockProcessor, error)
type ChainHelper ¶
type ChainInterface ¶
type ChainInterface interface { StateReader StateWriter VerifierHelper StateHelper ChainHelper }
type Middleware ¶
type Middleware func() error
func InsertBlock ¶
func InsertBlock(c *BlockContext) Middleware
func NextRoundVerifier ¶
func NextRoundVerifier(c *BlockContext) Middleware
func UpdateBlockVerifier ¶
func UpdateBlockVerifier(c *BlockContext) Middleware
func UpdateStateRoot ¶
func UpdateStateRoot(c *BlockContext) Middleware
func ValidBlockVerifier ¶
func ValidBlockVerifier(c *BlockContext) Middleware
func ValidStateRoot ¶
func ValidStateRoot(c *BlockContext) Middleware
func ValidTxByType ¶
func ValidTxByType(tx model.AbstractTransaction, chain ChainInterface, blockHeight uint64) Middleware
do checking for different types of transactions
func ValidateBlockCoinBase ¶
func ValidateBlockCoinBase(c *BlockContext) Middleware
func ValidateBlockDifficulty ¶
func ValidateBlockDifficulty(c *BlockContext) Middleware
func ValidateBlockHash ¶
func ValidateBlockHash(c *BlockContext) Middleware
func ValidateBlockNumber ¶
func ValidateBlockNumber(c *BlockContext) Middleware
validate_block typical usage: bc := InitBlockContext(block) m := &BlockProcessor{bc, chain} m.Use(ValidateBlockNumber(bc), ValidateBlockDifficulty(bc), ValidateBlockTxs(bc), ) m.Use(VrfCheckCommits(bc), ) m.Use(UpdateState(bc)) m.Use(InsertBlock(bc))
func ValidateBlockSize ¶
func ValidateBlockSize(c *BlockContext) Middleware
func ValidateBlockTime ¶
func ValidateBlockTime(c *BlockContext) Middleware
func ValidateBlockTxs ¶
func ValidateBlockTxs(c *BlockContext) Middleware
func ValidateBlockVersion ¶
func ValidateBlockVersion(c *BlockContext) Middleware
func ValidateSeed ¶
func ValidateSeed(c *BlockContext) Middleware
type MiddlewareChain ¶
type MiddlewareChain []Middleware
func (MiddlewareChain) Last ¶
func (c MiddlewareChain) Last() Middleware
type MiddlewareContext ¶
type MiddlewareContext struct {
// contains filtered or unexported fields
}
basic middleware, can be comprised by other middleware
func (*MiddlewareContext) Middleware ¶
func (mc *MiddlewareContext) Middleware() Middleware
func (*MiddlewareContext) Next ¶
func (mc *MiddlewareContext) Next() error
the core function of middleware, called only once after the registration of each middleware
func (*MiddlewareContext) Process ¶
func (mc *MiddlewareContext) Process(m ...Middleware) error
func (*MiddlewareContext) Use ¶
func (mc *MiddlewareContext) Use(m ...Middleware)
type StateHelper ¶
type StateHelper interface { GetStateStorage() state_processor.StateStorage CurrentState() (*state_processor.AccountStateDB, error) StateAtByBlockNumber(num uint64) (*state_processor.AccountStateDB, error) StateAtByStateRoot(root common.Hash) (*state_processor.AccountStateDB, error) BuildStateProcessor(preAccountStateRoot common.Hash) (*state_processor.AccountStateDB, error) }
type StateReader ¶
type StateReader interface { Genesis() model.AbstractBlock CurrentBlock() model.AbstractBlock CurrentHeader() model.AbstractHeader GetBlock(hash common.Hash, number uint64) model.AbstractBlock GetBlockByHash(hash common.Hash) model.AbstractBlock GetBlockByNumber(number uint64) model.AbstractBlock HasBlock(hash common.Hash, number uint64) bool GetBody(hash common.Hash) model.AbstractBody GetBodyRLP(hash common.Hash) rlp.RawValue GetHeader(hash common.Hash, number uint64) model.AbstractHeader GetHeaderByHash(hash common.Hash) model.AbstractHeader GetHeaderByNumber(number uint64) model.AbstractHeader GetHeaderRLP(hash common.Hash) rlp.RawValue HasHeader(hash common.Hash, number uint64) bool GetBlockNumber(hash common.Hash) *uint64 GetTransaction(txHash common.Hash) (model.AbstractTransaction, common.Hash, uint64, uint64) GetLatestNormalBlock() model.AbstractBlock BlockProcessor(root common.Hash) (*chain.BlockProcessor, error) BlockProcessorByNumber(num uint64) (*chain.BlockProcessor, error) }
type StateWriter ¶
type TxValidatorForRpcService ¶
type TxValidatorForRpcService struct {
Chain ChainInterface
}
func NewTxValidatorForRpcService ¶
func NewTxValidatorForRpcService(chain ChainInterface) *TxValidatorForRpcService
NewValidatorTx create a validator for transactions
func (*TxValidatorForRpcService) Valid ¶
func (v *TxValidatorForRpcService) Valid(tx model.AbstractTransaction) error
Valid valid transactions
type VerifierHelper ¶
type VerifierHelper interface { CurrentSeed() (common.Hash, uint64) IsChangePoint(block model.AbstractBlock, isProcessPackageBlock bool) bool GetLastChangePoint(block model.AbstractBlock) *uint64 GetSlotByNum(num uint64) *uint64 GetSlot(block model.AbstractBlock) *uint64 GetCurrVerifiers() []common.Address GetVerifiers(round uint64) []common.Address GetNextVerifiers() []common.Address NumBeforeLastBySlot(slot uint64) *uint64 BuildRegisterProcessor(preRoot common.Hash) (*registerdb.RegisterDB, error) }
Click to show internal directories.
Click to hide internal directories.