Documentation ¶
Index ¶
- Constants
- Variables
- func Init(maxBlockSize uint32, coinbaseAccountStr string, coinbaseFee uint64, isBp bool, ...) error
- func InitGenesisBPs(states *state.StateDB, genesis *types.Genesis) error
- func SendRewardCoinbase(bState *state.BlockState, coinbaseAccount []byte) error
- type BlockValidator
- func (bv *BlockValidator) Stop()
- func (bv *BlockValidator) ValidateBlock(block *types.Block) error
- func (bv *BlockValidator) ValidateBody(block *types.Block) error
- func (bv *BlockValidator) ValidateHeader(header *types.BlockHeader) error
- func (bv *BlockValidator) ValidatePost(sdbRoot []byte, receipts types.Receipts, block *types.Block) error
- type ChainAnchor
- type ChainDB
- func (cdb *ChainDB) Close()
- func (cdb *ChainDB) Get(key []byte) []byte
- func (cdb *ChainDB) GetBestBlock() (*types.Block, error)
- func (cdb *ChainDB) GetBlockByNo(blockNo types.BlockNo) (*types.Block, error)
- func (cdb *ChainDB) GetChainTree() ([]byte, error)
- func (cdb *ChainDB) Init(dbType string, dataDir string) error
- type ChainInfo
- type ChainService
- func (cs *ChainService) AfterStart()
- func (cs *ChainService) BeforeStart()
- func (cs *ChainService) BeforeStop()
- func (cs *ChainService) ChainSync(peerID peer.ID, remoteBestHash []byte)
- func (cs *ChainService) CloseDB()
- func (cs *ChainService) CountTxsInChain() int
- func (cs *ChainService) GetBestBlock() (*types.Block, error)
- func (cs *ChainService) GetBlock(blockHash []byte) (*types.Block, error)
- func (cs *ChainService) GetChainTree() ([]byte, error)
- func (cs *ChainService) GetHashByNo(blockNo types.BlockNo) ([]byte, error)
- func (cs *ChainService) InitGenesisBlock(gb *types.Genesis, dbType string, dataDir string) error
- func (cs *ChainService) Receive(context actor.Context)
- func (cs *ChainService) Statistics() *map[string]interface{}
- type ChainTree
- type ErrBlock
- type ErrNoBlock
- type ErrReorgBlock
- type ErrTx
- type OrphanBlock
- type OrphanPool
- type SignVerifier
- type TxExecFn
- type ValidatePostFn
- type VerifyResult
Constants ¶
const ( //MaxAnchors = 32 MaxAnchors = 1000000 //FIXME modify after implementing finder.fullscan Skip = 8 )
const HashNumberUnknown = math.MaxUint64
TODO adhoc flag refactor it
const (
TxBatchMax = 10000
)
Variables ¶
var ( ErrorBlockVerifySign = errors.New("Block verify failed, because Tx sign is invalid") ErrorBlockVerifyTxRoot = errors.New("Block verify failed, because Tx root hash is invaild") ErrorBlockVerifyStateRoot = errors.New("Block verify failed, because state root hash is not equal") )
var ( // ErrNoChainDB reports chaindb is not prepared. ErrNoChainDB = fmt.Errorf("chaindb not prepared") ErrorLoadBestBlock = errors.New("failed to load latest block from DB") )
var ( ErrTxInvalidNonce = errors.New("invalid nonce") ErrTxInsufficientBalance = errors.New("insufficient balance") ErrTxInvalidType = errors.New("invalid type") ErrorNoAncestor = errors.New("not found ancestor") InAddBlock = make(chan struct{}, 1) )
var ( // MaxBlockSize is the maximum size of a block. MaxBlockSize uint32 CoinbaseAccount []byte CoinbaseFee uint64 MaxAnchorCount int UseFastSyncer bool )
var ( ErrInvalidBranchRoot = errors.New("best block can't be branch root block") ErrGatherChain = errors.New("new/old blocks must exist") ErrNotExistBranchRoot = errors.New("branch root block doesn't exist") ErrInvalidSwapChain = errors.New("New chain is not longer than old chain") )
var ( ErrTxFormatInvalid = errors.New("tx invalid format") DefaultVerifierCnt = runtime.NumCPU() )
var (
ErrBlockExist = errors.New("error! block already exist")
)
var (
ErrInvalidCoinbaseAccount = errors.New("invalid coinbase account in config")
)
Functions ¶
func Init ¶
func Init(maxBlockSize uint32, coinbaseAccountStr string, coinbaseFee uint64, isBp bool, maxAnchorCount int, useFastSyncer bool) error
Init initializes the blockchain-related parameters.
func InitGenesisBPs ¶
InitGenesisBPs opens system contract and put initial voting result it also set *State in Genesis to use statedb
func SendRewardCoinbase ¶
func SendRewardCoinbase(bState *state.BlockState, coinbaseAccount []byte) error
Types ¶
type BlockValidator ¶
type BlockValidator struct {
// contains filtered or unexported fields
}
func NewBlockValidator ¶
func NewBlockValidator(sdb *state.ChainStateDB) *BlockValidator
func (*BlockValidator) Stop ¶
func (bv *BlockValidator) Stop()
func (*BlockValidator) ValidateBlock ¶
func (bv *BlockValidator) ValidateBlock(block *types.Block) error
func (*BlockValidator) ValidateBody ¶
func (bv *BlockValidator) ValidateBody(block *types.Block) error
func (*BlockValidator) ValidateHeader ¶
func (bv *BlockValidator) ValidateHeader(header *types.BlockHeader) error
func (*BlockValidator) ValidatePost ¶
type ChainAnchor ¶
type ChainAnchor []([]byte)
type ChainDB ¶
type ChainDB struct {
// contains filtered or unexported fields
}
func NewChainDB ¶
func NewChainDB(cc consensus.ChainConsensus) *ChainDB
func (*ChainDB) GetBlockByNo ¶
GetBlockByNo returns the block with its block number as blockNo.
func (*ChainDB) GetChainTree ¶
type ChainService ¶
type ChainService struct { *component.BaseComponent consensus.ChainConsensus // contains filtered or unexported fields }
ChainService manage connectivity of blocks
func NewChainService ¶
func NewChainService(cfg *cfg.Config, cc consensus.ChainConsensus, pool *mempool.MemPool) *ChainService
NewChainService create instance of ChainService
func (*ChainService) BeforeStart ¶
func (cs *ChainService) BeforeStart()
BeforeStart initialize chain database and generate empty genesis block if necessary
func (*ChainService) BeforeStop ¶
func (cs *ChainService) BeforeStop()
BeforeStop close chain database and stop BlockValidator
func (*ChainService) ChainSync ¶
func (cs *ChainService) ChainSync(peerID peer.ID, remoteBestHash []byte)
ChainSync synchronize with peer
func (*ChainService) CountTxsInChain ¶
func (cs *ChainService) CountTxsInChain() int
func (*ChainService) GetBestBlock ¶
func (cs *ChainService) GetBestBlock() (*types.Block, error)
func (*ChainService) GetBlock ¶
func (cs *ChainService) GetBlock(blockHash []byte) (*types.Block, error)
func (*ChainService) GetChainTree ¶
func (cs *ChainService) GetChainTree() ([]byte, error)
func (*ChainService) GetHashByNo ¶ added in v0.8.1
func (cs *ChainService) GetHashByNo(blockNo types.BlockNo) ([]byte, error)
func (*ChainService) InitGenesisBlock ¶
InitGenesisBlock initialize chain database and generate specified genesis block if necessary
func (*ChainService) Receive ¶
func (cs *ChainService) Receive(context actor.Context)
Receive actor message
func (*ChainService) Statistics ¶
func (cs *ChainService) Statistics() *map[string]interface{}
type ErrNoBlock ¶
type ErrNoBlock struct {
// contains filtered or unexported fields
}
ErrNoBlock reports there is no such a block with id (hash or block number).
func (ErrNoBlock) Error ¶
func (e ErrNoBlock) Error() string
type ErrReorgBlock ¶
type ErrReorgBlock struct {
// contains filtered or unexported fields
}
func (*ErrReorgBlock) Error ¶
func (ec *ErrReorgBlock) Error() string
type OrphanBlock ¶
type OrphanBlock struct {
// contains filtered or unexported fields
}
type OrphanPool ¶
func NewOrphanPool ¶
func NewOrphanPool() *OrphanPool
type SignVerifier ¶
type SignVerifier struct {
// contains filtered or unexported fields
}
func NewSignVerifier ¶
func NewSignVerifier(workerCnt int) *SignVerifier
func (*SignVerifier) Stop ¶
func (sv *SignVerifier) Stop()
type ValidatePostFn ¶
type ValidatePostFn func() error
type VerifyResult ¶
type VerifyResult struct {
// contains filtered or unexported fields
}