Documentation ¶
Index ¶
- Constants
- func AppendValidatorsToGenesisBlock(genesis *core.Genesis, validators []istanbul.ValidatorData)
- func New(config *istanbul.Config, db ethdb.Database) consensus.Istanbul
- type API
- func (api *API) AddProxy(url, externalUrl string) (bool, error)
- func (api *API) ForceRoundChange() (bool, error)
- func (api *API) GetCurrentRoundState() (*core.RoundStateSummary, error)
- func (api *API) GetProposer(sequence *rpc.BlockNumber, round *uint64) (common.Address, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetValEnodeTable() (map[string]*vet.ValEnodeEntryInfo, error)
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) RemoveProxy(url string) (bool, error)
- type AnnounceFrequencyState
- type AnnounceGossipTimestamp
- type Backend
- func (sb *Backend) APIs(chain consensus.ChainReader) []rpc.API
- func (sb *Backend) Address() common.Address
- func (sb *Backend) Author(header *types.Header) (common.Address, error)
- func (sb *Backend) AuthorForBlock(number uint64) common.Address
- func (sb *Backend) Authorize(address common.Address, signFn istanbul.SignerFn, ...)
- func (sb *Backend) BroadcastConsensusMsg(destAddresses []common.Address, payload []byte) error
- func (sb *Backend) CalcDifficulty(chain consensus.ChainReader, 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, aggregatedSeal types.IstanbulAggregatedSeal, ...) error
- func (sb *Backend) ConnectToVals()
- func (sb *Backend) EpochSize() uint64
- func (sb *Backend) EventMux() *event.TypeMux
- func (sb *Backend) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (sb *Backend) GetCurrentHeadBlock() istanbul.Proposal
- func (sb *Backend) GetCurrentHeadBlockAndAuthor() (istanbul.Proposal, common.Address)
- func (sb *Backend) GetValidators(blockNumber *big.Int, headerHash common.Hash) []istanbul.Validator
- func (sb *Backend) Gossip(destAddresses []common.Address, payload []byte, ethMsgCode uint64, ...) error
- func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg, peer consensus.Peer) (bool, error)
- func (sb *Backend) HasBlock(hash common.Hash, number *big.Int) bool
- func (sb *Backend) IsLastBlockOfEpoch(header *types.Header) bool
- func (sb *Backend) IsProxiedValidator() bool
- func (sb *Backend) IsProxy() bool
- func (sb *Backend) LastSubject() (istanbul.Subject, error)
- func (sb *Backend) LookbackWindow() uint64
- func (sb *Backend) NewChainHead(newBlock *types.Block)
- func (sb *Backend) NewWork() error
- func (sb *Backend) NextBlockValidators(proposal istanbul.Proposal) (istanbul.ValidatorSet, error)
- func (sb *Backend) ParentBlockValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
- func (sb *Backend) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (sb *Backend) Protocol() consensus.Protocol
- func (sb *Backend) RefreshValPeers(valset istanbul.ValidatorSet)
- func (sb *Backend) RegisterPeer(peer consensus.Peer, isProxiedPeer bool)
- func (sb *Backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (sb *Backend) SealHash(header *types.Header) common.Hash
- func (sb *Backend) SendDelegateSignMsgToProxiedValidator(msg []byte) error
- func (sb *Backend) SendDelegateSignMsgToProxy(msg []byte) error
- func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
- func (sb *Backend) SetChain(chain consensus.ChainReader, currentBlock func() *types.Block)
- func (sb *Backend) SetP2PServer(p2pserver consensus.P2PServer)
- func (sb *Backend) Sign(data []byte) ([]byte, error)
- func (sb *Backend) SignBLSWithCompositeHash(data []byte) (blscrypto.SerializedSignature, error)
- func (sb *Backend) SignBlockHeader(data []byte) (blscrypto.SerializedSignature, error)
- func (sb *Backend) Start(hasBadBlock func(common.Hash) bool, ...) error
- func (sb *Backend) Stop() error
- func (sb *Backend) SubscribeNewDelegateSignEvent(ch chan<- istanbul.MessageEvent) event.Subscription
- func (sb *Backend) UnregisterPeer(peer consensus.Peer, isProxiedPeer bool)
- func (sb *Backend) UpdateValSetDiff(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
- func (sb *Backend) ValidatorAddress() common.Address
- 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.ChainReader, header *types.Header, seal bool) error
- func (sb *Backend) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (sb *Backend) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (sb *Backend) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Snapshot
Constants ¶
const ( HighFreqTickerDuration = 1 * time.Minute LowFreqTickerDuration = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func AppendValidatorsToGenesisBlock ¶
func AppendValidatorsToGenesisBlock(genesis *core.Genesis, validators []istanbul.ValidatorData)
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to dump Istanbul state
func (*API) AddProxy ¶
AddProxy peers with a remote node that acts as a proxy, even if slots are full
func (*API) ForceRoundChange ¶
GetCurrentRoundState retrieves the current IBFT RoundState
func (*API) GetCurrentRoundState ¶
func (api *API) GetCurrentRoundState() (*core.RoundStateSummary, error)
GetCurrentRoundState retrieves the current IBFT RoundState
func (*API) GetProposer ¶
GetProposer retrieves the proposer for a given block number (i.e. sequence) and round.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetValEnodeTable ¶
func (api *API) GetValEnodeTable() (map[string]*vet.ValEnodeEntryInfo, error)
Retrieve the Validator Enode Table
func (*API) GetValidators ¶
GetValidators retrieves the list validators that must sign a given block.
type AnnounceFrequencyState ¶
type AnnounceFrequencyState int
const ( // In this state, send out an announce message every 1 minute until the first peer is established HighFreqBeforeFirstPeerState AnnounceFrequencyState = iota // In this state, send out an announce message every 1 minute for the first 10 announce messages after the first peer is established. // This is on the assumption that when this node first establishes a peer, the p2p network that this node is in may // be partitioned with the broader p2p network. We want to give that p2p network some time to connect to the broader p2p network. HighFreqAfterFirstPeerState // In this state, send out an announce message every 10 minutes LowFreqState )
type AnnounceGossipTimestamp ¶
type AnnounceGossipTimestamp struct {
// contains filtered or unexported fields
}
Entries for the recent announce messages
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) APIs ¶
func (sb *Backend) APIs(chain consensus.ChainReader) []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) AuthorForBlock ¶
AuthorForBlock implements istanbul.Backend.AuthorForBlock
func (*Backend) Authorize ¶
func (sb *Backend) Authorize(address common.Address, signFn istanbul.SignerFn, signHashBLSFn istanbul.BLSSignerFn, signMessageBLSFn istanbul.MessageSignerFn)
Authorize implements istanbul.Backend.Authorize
func (*Backend) BroadcastConsensusMsg ¶
Broadcast implements istanbul.Backend.BroadcastConsensusMsg
func (*Backend) CalcDifficulty ¶
func (sb *Backend) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.
func (*Backend) CheckSignature ¶
CheckSignature implements istanbul.Backend.CheckSignature
func (*Backend) Commit ¶
func (sb *Backend) Commit(proposal istanbul.Proposal, aggregatedSeal types.IstanbulAggregatedSeal, aggregatedEpochValidatorSetSeal types.IstanbulEpochValidatorSetSeal) error
Commit implements istanbul.Backend.Commit
func (*Backend) ConnectToVals ¶
func (sb *Backend) ConnectToVals()
func (*Backend) Finalize ¶
func (sb *Backend) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, randomness *types.Randomness) (*types.Block, error)
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) GetCurrentHeadBlock ¶
GetCurrentHeadBlock retrieves the last block
func (*Backend) GetCurrentHeadBlockAndAuthor ¶
GetCurrentHeadBlockAndAuthor retrieves the last block alongside the coinbase address for it
func (*Backend) GetValidators ¶
func (*Backend) Gossip ¶
func (sb *Backend) Gossip(destAddresses []common.Address, payload []byte, ethMsgCode uint64, ignoreCache bool) error
Gossip implements istanbul.Backend.Gossip
func (*Backend) IsLastBlockOfEpoch ¶
Returns whether or not a particular header represents the last block in the epoch.
func (*Backend) IsProxiedValidator ¶
func (*Backend) LookbackWindow ¶
Returns the size of the lookback window for calculating uptime (in blocks)
func (*Backend) NewChainHead ¶
This function is called by all nodes. At the end of each epoch, this function will
- Output if it is or isn't an elected validator if it has mining turned on.
- Refresh the validator connections if it's a proxy or non proxied validator
func (*Backend) NewWork ¶
This function is called by miner/worker.go whenever it's mainLoop gets a newWork event.
func (*Backend) NextBlockValidators ¶
func (*Backend) ParentBlockValidators ¶
func (sb *Backend) ParentBlockValidators(proposal istanbul.Proposal) istanbul.ValidatorSet
ParentBlockValidators implements istanbul.Backend.ParentBlockValidators
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) RefreshValPeers ¶
func (sb *Backend) RefreshValPeers(valset istanbul.ValidatorSet)
RefreshValPeers will create 'validator' type peers to all the valset validators, and disconnect from the peers that are not part of the valset. It will also disconnect all validator connections if this node is not a validator. Note that adding and removing validators are idempotent operations. If the validator being added or removed is already added or removed, then a no-op will be done.
func (*Backend) RegisterPeer ¶
func (*Backend) Seal ¶
func (sb *Backend) Seal(chain consensus.ChainReader, 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) SendDelegateSignMsgToProxiedValidator ¶
SendDelegateSignMsgToProxiedValidator sends an istanbulDelegateSign message to a proxied validator if one exists
func (*Backend) SendDelegateSignMsgToProxy ¶
SendDelegateSignMsgToProxy sends an istanbulDelegateSign message to a proxy if one exists
func (*Backend) SetBroadcaster ¶
func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
SetBroadcaster implements consensus.Handler.SetBroadcaster
func (*Backend) SetChain ¶
func (sb *Backend) SetChain(chain consensus.ChainReader, currentBlock func() *types.Block)
func (*Backend) SetP2PServer ¶
SetP2PServer implements consensus.Handler.SetP2PServer
func (*Backend) SignBLSWithCompositeHash ¶
func (sb *Backend) SignBLSWithCompositeHash(data []byte) (blscrypto.SerializedSignature, error)
func (*Backend) SignBlockHeader ¶
func (sb *Backend) SignBlockHeader(data []byte) (blscrypto.SerializedSignature, error)
func (*Backend) Start ¶
func (sb *Backend) Start(hasBadBlock func(common.Hash) bool, stateAt func(common.Hash) (*state.StateDB, error), processBlock func(*types.Block, *state.StateDB) (types.Receipts, []*types.Log, uint64, error), validateState func(*types.Block, *state.StateDB, types.Receipts, uint64) error) error
Start implements consensus.Istanbul.Start
func (*Backend) SubscribeNewDelegateSignEvent ¶
func (sb *Backend) SubscribeNewDelegateSignEvent(ch chan<- istanbul.MessageEvent) event.Subscription
SubscribeNewDelegateSignEvent subscribes a channel to any new delegate sign messages
func (*Backend) UnregisterPeer ¶
func (*Backend) UpdateValSetDiff ¶
func (sb *Backend) UpdateValSetDiff(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
UpdateValSetDiff will update the validator set diff in the header, if the mined header is the last block of the epoch
func (*Backend) ValidatorAddress ¶
func (*Backend) Validators ¶
func (sb *Backend) Validators(proposal istanbul.Proposal) istanbul.ValidatorSet
Validators implements istanbul.Backend.Validators
func (*Backend) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifies the seal regardless of given "seal" argument.
func (*Backend) VerifyHeaders ¶
func (sb *Backend) VerifyHeaders(chain consensus.ChainReader, 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 Snapshot ¶
type Snapshot struct { Epoch uint64 // The number of blocks for each epoch Number uint64 // Block number where the snapshot was created Hash common.Hash // Block hash where the snapshot was created 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 ¶
MarshalJSON to a json byte array
func (*Snapshot) UnmarshalJSON ¶
UnmarshalJSON from a json byte array