Documentation ¶
Index ¶
- Constants
- type API
- func (api *API) Candidates() map[common.Address]bool
- func (api *API) Discard(address common.Address)
- func (api *API) GetSignersFromBlock(number *rpc.BlockNumber) (*BlockSigners, error)
- func (api *API) GetSignersFromBlockByHash(hash common.Hash) (*BlockSigners, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) IsValidator(blockNum *rpc.BlockNumber) (bool, error)
- func (api *API) NodeAddress() common.Address
- func (api *API) Propose(address common.Address, auth bool)
- func (api *API) Status(startBlockNum *rpc.BlockNumber, endBlockNum *rpc.BlockNumber) (*Status, error)
- type Backend
- func (sb *Backend) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (sb *Backend) Address() common.Address
- func (sb *Backend) Author(header *types.Header) (common.Address, error)
- func (sb *Backend) Broadcast(valSet istanbul.ValidatorSet, code uint64, payload []byte) error
- func (sb *Backend) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (sb *Backend) CheckSignature(data []byte, address common.Address, sig []byte) error
- func (sb *Backend) Close() error
- func (sb *Backend) Commit(proposal istanbul.Proposal, seals [][]byte, round *big.Int) (err error)
- func (sb *Backend) Engine() istanbul.Engine
- func (sb *Backend) EngineForBlockNumber(blockNumber *big.Int) istanbul.Engine
- func (sb *Backend) EventMux() *event.TypeMux
- func (sb *Backend) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (sb *Backend) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (sb *Backend) GetProposer(number uint64) common.Address
- func (sb *Backend) Gossip(valSet istanbul.ValidatorSet, code uint64, payload []byte) error
- func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg) (bool, error)
- func (sb *Backend) HasBadProposal(hash common.Hash) bool
- func (sb *Backend) HasPropsal(hash common.Hash, number *big.Int) bool
- func (sb *Backend) IsQBFTConsensus() bool
- func (sb *Backend) IsQBFTConsensusAt(blockNumber *big.Int) bool
- func (sb *Backend) LastProposal() (istanbul.Proposal, common.Address)
- func (sb *Backend) NewChainHead() error
- func (sb *Backend) ParentValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
- func (sb *Backend) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (sb *Backend) Protocol() consensus.Protocol
- func (sb *Backend) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (sb *Backend) SealHash(header *types.Header) common.Hash
- func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
- func (sb *Backend) Sign(data []byte) ([]byte, error)
- func (sb *Backend) SignWithoutHashing(data []byte) ([]byte, error)
- func (sb *Backend) Signers(header *types.Header) ([]common.Address, error)
- func (sb *Backend) Start(chain consensus.ChainHeaderReader, currentBlock func() *types.Block, ...) error
- func (sb *Backend) StartQBFTConsensus() error
- func (sb *Backend) Stop() error
- func (sb *Backend) Validators(proposal istanbul.Proposal) istanbul.ValidatorSet
- func (sb *Backend) Verify(proposal istanbul.Proposal) (time.Duration, error)
- func (sb *Backend) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (sb *Backend) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (sb *Backend) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
- func (sb *Backend) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type BlockSigners
- type Snapshot
- type Status
- type Tally
- type Vote
Constants ¶
const (
NewBlockMsg = 0x07
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to dump Istanbul state
func (*API) Candidates ¶
Candidates returns the current candidates the node tries to uphold and vote on.
func (*API) Discard ¶
Discard drops a currently running candidate, stopping the validator from casting further votes (either for or against).
func (*API) GetSignersFromBlock ¶
func (api *API) GetSignersFromBlock(number *rpc.BlockNumber) (*BlockSigners, error)
GetSignersFromBlock returns the signers and minter for a given block number, or the latest block available if none is specified
func (*API) GetSignersFromBlockByHash ¶
func (api *API) GetSignersFromBlockByHash(hash common.Hash) (*BlockSigners, error)
GetSignersFromBlockByHash returns the signers and minter for a given block hash
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
func (*API) GetValidators ¶
GetValidators retrieves the list of authorized validators at the specified block.
func (*API) GetValidatorsAtHash ¶
GetValidatorsAtHash retrieves the state snapshot at a given block.
func (*API) IsValidator ¶
func (api *API) IsValidator(blockNum *rpc.BlockNumber) (bool, error)
func (*API) NodeAddress ¶
NodeAddress returns the public address that is used to sign block headers in IBFT
func (*API) Propose ¶
Propose injects a new authorization candidate that the validator will attempt to push through.
func (*API) Status ¶
func (api *API) Status(startBlockNum *rpc.BlockNumber, endBlockNum *rpc.BlockNumber) (*Status, error)
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) APIs ¶
func (sb *Backend) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs returns the RPC APIs this consensus engine provides.
func (*Backend) Author ¶
Author retrieves the Ethereum address of the account that minted the given block, which may be different from the header's coinbase if a consensus engine is based on signatures.
func (*Backend) CalcDifficulty ¶
func (sb *Backend) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
zekun: HACK
func (*Backend) CheckSignature ¶
CheckSignature implements istanbul.Backend.CheckSignature
func (*Backend) EngineForBlockNumber ¶
func (*Backend) Finalize ¶
func (sb *Backend) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)
Finalize runs any post-transaction state modifications (e.g. block rewards) and assembles the final block.
Note, the block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).
func (*Backend) FinalizeAndAssemble ¶
func (sb *Backend) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Backend) GetProposer ¶
GetProposer implements istanbul.Backend.GetProposer
func (*Backend) HasPropsal ¶
HasPropsal implements istanbul.Backend.HashBlock
func (*Backend) IsQBFTConsensus ¶
IsQBFTConsensus returns whether qbft consensus should be used
func (*Backend) IsQBFTConsensusAt ¶
IsQBFTConsensusForHeader checks if qbft consensus is enabled for the block height identified by the given header
func (*Backend) LastProposal ¶
func (*Backend) NewChainHead ¶
func (*Backend) ParentValidators ¶
func (sb *Backend) ParentValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
ParentValidators implements istanbul.Backend.GetParentValidators
func (*Backend) Prepare ¶
Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.
func (*Backend) Seal ¶
func (sb *Backend) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*Backend) SetBroadcaster ¶
func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
SetBroadcaster implements consensus.Handler.SetBroadcaster
func (*Backend) SignWithoutHashing ¶
SignWithoutHashing implements istanbul.Backend.SignWithoutHashing and signs input data with the backend's private key without hashing the input data
func (*Backend) Signers ¶
Signers extracts all the addresses who have signed the given header It will extract for each seal who signed it, regardless of if the seal is repeated
func (*Backend) Start ¶
func (sb *Backend) Start(chain consensus.ChainHeaderReader, currentBlock func() *types.Block, hasBadBlock func(db ethdb.Reader, hash common.Hash) bool) error
Start implements consensus.Istanbul.Start
func (*Backend) StartQBFTConsensus ¶
StartQBFTConsensus stops existing legacy ibft consensus and starts the new qbft consensus
func (*Backend) Validators ¶
func (sb *Backend) Validators(proposal istanbul.Proposal) istanbul.ValidatorSet
Validators implements istanbul.Backend.Validators
func (*Backend) VerifyHeader ¶
func (sb *Backend) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.
func (*Backend) VerifyHeaders ¶
func (sb *Backend) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*Backend) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
func (*Backend) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of a given engine.
type BlockSigners ¶
type BlockSigners struct { Number uint64 Hash common.Hash Author common.Address Committers []common.Address }
BlockSigners is contains who created and who signed a particular block, denoted by its number and hash
type Snapshot ¶
type Snapshot struct { Epoch uint64 // The number of blocks after which to checkpoint and reset the pending votes Number uint64 // Block number where the snapshot was created Hash common.Hash // Block hash where the snapshot was created Votes []*Vote // List of votes cast in chronological order Tally map[common.Address]Tally // Current vote tally to avoid recalculating ValSet istanbul.ValidatorSet // Set of authorized validators at this moment }
Snapshot is the state of the authorization voting at a given point in time.
func (*Snapshot) MarshalJSON ¶
Marshal to a json byte array
func (*Snapshot) UnmarshalJSON ¶
Unmarshal from a json byte array
type Tally ¶
type Tally struct { Authorize bool `json:"authorize"` // Whether the vote it about authorizing or kicking someone Votes int `json:"votes"` // Number of votes until now wanting to pass the proposal }
Tally is a simple vote tally to keep the current score of votes. Votes that go against the proposal aren't counted since it's equivalent to not voting.
type Vote ¶
type Vote struct { Validator common.Address `json:"validator"` // Authorized validator that cast this vote Block uint64 `json:"block"` // Block number the vote was cast in (expire old votes) Address common.Address `json:"address"` // Account being voted on to change its authorization Authorize bool `json:"authorize"` // Whether to authorize or deauthorize the voted account }
Vote represents a single vote that an authorized validator made to modify the list of authorizations.