Documentation
¶
Index ¶
- Constants
- Variables
- func Factory(params *consensus.ConsensusParams) (consensus.Consensus, error)
- func PutIbftExtra(h *types.Header, istanbulExtra *IstanbulExtra) error
- type Ibft
- type IbftState
- type IstanbulExtra
- type MsgType
- type Snapshot
- type ValidatorSet
- func (v *ValidatorSet) Add(addr types.Address)
- func (v *ValidatorSet) CalcProposer(round uint64, lastProposer types.Address) types.Address
- func (v *ValidatorSet) Del(addr types.Address)
- func (v *ValidatorSet) Equal(vv *ValidatorSet) bool
- func (v *ValidatorSet) Includes(addr types.Address) bool
- func (v *ValidatorSet) Index(addr types.Address) int
- func (v *ValidatorSet) Len() int
- func (v *ValidatorSet) MaxFaultyNodes() int
- type Vote
Constants ¶
const (
DefaultEpochSize = 100000
)
const IbftKeyName = "validator.key"
Variables ¶
var ( // IstanbulDigest represents a hash of "Istanbul practical byzantine fault tolerance" // to identify whether the block is from Istanbul consensus engine IstanbulDigest = types.StringToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365") // IstanbulExtraVanity represents a fixed number of extra-data bytes reserved for proposer vanity IstanbulExtraVanity = 32 // IstanbulExtraSeal represents the fixed number of extra-data bytes reserved for proposer seal IstanbulExtraSeal = 65 )
Functions ¶
func Factory ¶
func Factory( params *consensus.ConsensusParams, ) (consensus.Consensus, error)
Factory implements the base consensus Factory method
func PutIbftExtra ¶
func PutIbftExtra(h *types.Header, istanbulExtra *IstanbulExtra) error
PutIbftExtra sets the extra data field in the header to the passed in istanbul extra data
Types ¶
type Ibft ¶
type Ibft struct {
// contains filtered or unexported fields
}
Ibft represents the IBFT consensus mechanism object
func (*Ibft) GetBlockCreator ¶
GetBlockCreator retrieves the block signer from the extra data field
type IstanbulExtra ¶
IstanbulExtra defines the structure of the extra field for Istanbul
func (*IstanbulExtra) MarshalRLPTo ¶
func (i *IstanbulExtra) MarshalRLPTo(dst []byte) []byte
MarshalRLPTo defines the marshal function wrapper for IstanbulExtra
func (*IstanbulExtra) MarshalRLPWith ¶
func (i *IstanbulExtra) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith defines the marshal function implementation for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLP ¶
func (i *IstanbulExtra) UnmarshalRLP(input []byte) error
UnmarshalRLP defines the unmarshal function wrapper for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLPFrom ¶
UnmarshalRLPFrom defines the unmarshal implementation for IstanbulExtra
type Snapshot ¶
type Snapshot struct {
// block number when the snapshot was created
Number uint64
// block hash when the snapshot was created
Hash string
// votes casted in chronological order
Votes []*Vote
// current set of validators
Set ValidatorSet
}
Snapshot is the current state at a given point in time for validators and votes
func (*Snapshot) Count ¶
Count returns the vote tally. The count increases if the callback function returns true
func (*Snapshot) RemoveVotes ¶
RemoveVotes removes votes from the snapshot, based on the passed in callback
type ValidatorSet ¶
func (*ValidatorSet) Add ¶
func (v *ValidatorSet) Add(addr types.Address)
Add adds a new address to the validator set
func (*ValidatorSet) CalcProposer ¶
CalcProposer calculates the address of the next proposer, from the validator set
func (*ValidatorSet) Del ¶
func (v *ValidatorSet) Del(addr types.Address)
Del removes an address from the validator set
func (*ValidatorSet) Equal ¶
func (v *ValidatorSet) Equal(vv *ValidatorSet) bool
Equal checks if 2 validator sets are equal
func (*ValidatorSet) Includes ¶
func (v *ValidatorSet) Includes(addr types.Address) bool
Includes checks if the address is in the validator set
func (*ValidatorSet) Index ¶
func (v *ValidatorSet) Index(addr types.Address) int
Index returns the index of the passed in address in the validator set. Returns -1 if not found
func (*ValidatorSet) Len ¶
func (v *ValidatorSet) Len() int
Len returns the size of the validator set
func (*ValidatorSet) MaxFaultyNodes ¶
func (v *ValidatorSet) MaxFaultyNodes() int
MaxFaultyNodes returns the maximum number of allowed faulty nodes (F), based on the current validator set