Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBlockInvalidHeight is returned when block nonce is invalid ErrBlockNonceInvalid = errors.New("invalid block nonce") // ErrBlockInvalidHeight is returned when inserting a new header with invalid block height. ErrBlockInvalidHeight = errors.New("invalid block height") // ErrBlockCreateTimeOld is returned when block create time is previous of parent block time ErrBlockCreateTimeOld = errors.New("block time must be later than parent block time") // ErrBlockInvalidParentHash is returned when inserting a new header with invalid parent block hash. ErrBlockInvalidParentHash = errors.New("invalid parent block hash") // ErrBlockDifficultInvalid is returned when block difficult is invalid ErrBlockDifficultInvalid = errors.New("block difficult is invalid") )
Functions ¶
Types ¶
type Broadcaster ¶
type Broadcaster interface { // Enqueue add a block into fetcher queue Enqueue(id string, block *types.Block) // FindPeers retrives peers by addresses FindPeers(map[common.Address]bool) map[common.Address]Peer }
Broadcaster defines the interface to enqueue blocks to fetcher and find peer
type ChainReader ¶
type ChainReader interface { // CurrentHeader retrieves the current header from the local chain. CurrentHeader() *types.BlockHeader // GetHeaderByNumber retrieves a block header from the database by number. GetHeaderByHeight(height uint64) *types.BlockHeader // GetHeaderByHash retrieves a block header from the database by its hash. GetHeaderByHash(hash common.Hash) *types.BlockHeader // GetBlock retrieves a block from the database by hash and number. GetBlockByHash(hash common.Hash) *types.Block }
ChainReader defines a small collection of methods needed to access the local blockchain during header and/or uncle verification.
type Engine ¶
type Engine interface { // Prepare header before generate block Prepare(chain ChainReader, header *types.BlockHeader) error // VerifyHeader verify block header VerifyHeader(chain ChainReader, header *types.BlockHeader) error // Seal generate block Seal(chain ChainReader, block *types.Block, stop <-chan struct{}, results chan<- *types.Block) error // APIs returns the RPC APIs this consensus engine provides. APIs(chain ChainReader) []rpc.API // SetThreads set miner threads SetThreads(thread int) }
type Handler ¶
type Handler interface { // NewChainHead handles a new head block comes NewChainHead() error // HandleMsg handles a message from peer HandleMsg(address common.Address, msg interface{}) (bool, error) // SetBroadcaster sets the broadcaster to send message to peers SetBroadcaster(Broadcaster) }
Handler should be implemented is the consensus needs to handle and send peer's message
type Istanbul ¶
type Istanbul interface { Engine // Start starts the engine Start(chain ChainReader, currentBlock func() *types.Block, hasBadBlock func(hash common.Hash) bool) error // Stop stops the engine Stop() error }
Istanbul is a consensus engine to avoid byzantine failure
type Peer ¶
type Peer interface { // Send sends the message to this peer Send(msgcode uint16, data interface{}) error }
Peer defines the interface to communicate with peer
type Protocol ¶
type Protocol struct { // Official short name of the protocol used during capability negotiation. Name string // Supported versions of the eth protocol (first is primary). Versions []uint // Height of implemented message corresponding to different protocol versions. Lengths []uint64 }
Protocol defines the protocol of the consensus
Click to show internal directories.
Click to hide internal directories.