Documentation
¶
Index ¶
- Constants
- Variables
- func CanonicalTime(t time.Time) string
- func EqualCommitteeMemberArray(a, b []*ctypes.CommitteeMember) bool
- func IsVoteTypeValid(typeB byte) bool
- func MakeBlockFromPartSet(reader *PartSet) (*ctypes.Block, error)
- func RegisterBlockAmino(cdc *amino.Codec)
- type BlockID
- type BlockMeta
- type BlockStore
- func (b *BlockStore) LoadBlockCommit(height uint64) *Commit
- func (b *BlockStore) LoadBlockMeta(height uint64) *BlockMeta
- func (b *BlockStore) LoadBlockPart(height uint64, index uint) *Part
- func (b *BlockStore) MaxBlockHeight() uint64
- func (b *BlockStore) MinBlockHeight() uint64
- func (b *BlockStore) SaveBlock(block *ctypes.Block, blockParts *PartSet, seenCommit *Commit, ...)
- type CanonicalJSONBlockID
- type CanonicalJSONHeartbeat
- type CanonicalJSONPartSetHeader
- type CanonicalJSONProposal
- type CanonicalJSONVote
- type Commit
- func (commit *Commit) BitArray() *help.BitArray
- func (commit *Commit) FirstPrecommit() *Vote
- func (commit *Commit) GetByIndex(index uint) *Vote
- func (commit *Commit) Hash() help.HexBytes
- func (commit *Commit) Height() uint64
- func (commit *Commit) IsCommit() bool
- func (commit *Commit) Round() int
- func (commit *Commit) Size() uint
- func (commit *Commit) StringIndented(indent string) string
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- type EventBus
- func (b *EventBus) OnStart() error
- func (b *EventBus) OnStop()
- func (b *EventBus) PublishEventCompleteProposal(event EventDataRoundState) error
- func (b *EventBus) PublishEventLock(event EventDataRoundState) error
- func (b *EventBus) PublishEventNewRound(event EventDataRoundState) error
- func (b *EventBus) PublishEventNewRoundStep(event EventDataRoundState) error
- func (b *EventBus) PublishEventPolka(event EventDataRoundState) error
- func (b *EventBus) PublishEventRelock(event EventDataRoundState) error
- func (b *EventBus) PublishEventTimeoutPropose(event EventDataRoundState) error
- func (b *EventBus) PublishEventTimeoutWait(event EventDataRoundState) error
- func (b *EventBus) PublishEventUnlock(event EventDataRoundState) error
- func (b *EventBus) PublishEventVote(event EventDataVote) error
- func (b *EventBus) Subscribe(key string, out chan<- interface{}) event.Subscription
- type EventCallback
- type EventData
- type EventDataCommon
- type EventDataRoundState
- type EventDataVote
- type EventSwitch
- type Eventable
- type Fireable
- type Health
- type HealthMgr
- func (h *HealthMgr) ChanFrom() chan *SwitchValidator
- func (h *HealthMgr) ChanTo() chan *SwitchValidator
- func (h *HealthMgr) GetHealth(adress []byte) *Health
- func (h *HealthMgr) OnStart() error
- func (h *HealthMgr) OnStop()
- func (h *HealthMgr) PutBackHealth(he *Health)
- func (h *HealthMgr) PutWorkHealth(he *Health)
- func (h *HealthMgr) Sum() int
- func (h *HealthMgr) Switch(s *SwitchValidator)
- func (h *HealthMgr) UpdataHealthInfo(id tp2p.ID, ip string, port uint32, pk []byte)
- func (h *HealthMgr) Update(id tp2p.ID)
- func (h *HealthMgr) UpdateFromCommittee(member, backMember ctypes.CommitteeMembers)
- func (h *HealthMgr) VerifySwitch(sv *SwitchValidator) error
- type HealthsByAddress
- type HeightVoteSet
- func (hvs *HeightVoteSet) AddVote(vote *Vote, peerID string) (added bool, err error)
- func (hvs *HeightVoteSet) GetSignsFromVote(round int, hash []byte, addr help.Address) *KeepBlockSign
- func (hvs *HeightVoteSet) Height() uint64
- func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error)
- func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID BlockID)
- func (hvs *HeightVoteSet) Precommits(round int) *VoteSet
- func (hvs *HeightVoteSet) Prevotes(round int) *VoteSet
- func (hvs *HeightVoteSet) Reset(height uint64, valSet *ValidatorSet)
- func (hvs *HeightVoteSet) Round() int
- func (hvs *HeightVoteSet) SetPeerMaj23(round int, typeB byte, peerID string, blockID BlockID) error
- func (hvs *HeightVoteSet) SetRound(round int)
- func (hvs *HeightVoteSet) String() string
- func (hvs *HeightVoteSet) StringIndented(indent string) string
- type KeepBlockSign
- type P2PID
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part) (bool, error)
- func (ps *PartSet) BitArray() *help.BitArray
- func (ps *PartSet) Count() uint
- func (ps *PartSet) GetPart(index uint) *Part
- func (ps *PartSet) GetReader() io.Reader
- func (ps *PartSet) HasHeader(header PartSetHeader) bool
- func (ps *PartSet) Hash() []byte
- func (ps *PartSet) HashesTo(hash []byte) bool
- func (ps *PartSet) Header() PartSetHeader
- func (ps *PartSet) IsComplete() bool
- func (ps *PartSet) MarshalJSON() ([]byte, error)
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() uint
- type PartSetHeader
- type PartSetReader
- type PeerRoundState
- type PrivValidator
- type PrivValidatorsByAddress
- type Proposal
- type RoundState
- type RoundStateSimple
- type RoundStepType
- type RoundVoteSet
- type StateAgent
- type StateAgentImpl
- func (state *StateAgentImpl) Broadcast(height *big.Int)
- func (state *StateAgentImpl) ConsensusCommit(block *ctypes.Block) error
- func (state *StateAgentImpl) GetAddress() help.Address
- func (state *StateAgentImpl) GetChainID() string
- func (state *StateAgentImpl) GetLastBlockHeight() uint64
- func (state *StateAgentImpl) GetLastValidator() *ValidatorSet
- func (state *StateAgentImpl) GetLastValidatorAddress() common.Address
- func (state *StateAgentImpl) GetPubKey() tcrypto.PubKey
- func (state *StateAgentImpl) GetValidator() *ValidatorSet
- func (state *StateAgentImpl) HasPeerID(id string) error
- func (state *StateAgentImpl) MakeBlock(v *SwitchValidator) (*ctypes.Block, error)
- func (state *StateAgentImpl) MakePartSet(partSize uint, block *ctypes.Block) (*PartSet, error)
- func (state *StateAgentImpl) PrivReset()
- func (state *StateAgentImpl) SetBeginHeight(h uint64)
- func (state *StateAgentImpl) SetEndHeight(h uint64)
- func (state *StateAgentImpl) SetPrivValidator(priv PrivValidator)
- func (state *StateAgentImpl) SignProposal(chainID string, proposal *Proposal) error
- func (state *StateAgentImpl) SignVote(chainID string, vote *Vote) error
- func (state *StateAgentImpl) UpdateValidator(vset *ValidatorSet, makeids bool) error
- func (state *StateAgentImpl) ValidateBlock(block *ctypes.Block, result bool) (*KeepBlockSign, error)
- type SwitchValidator
- type Validator
- type ValidatorSet
- func (valSet *ValidatorSet) Add(val *Validator) (added bool)
- func (valSet *ValidatorSet) Copy() *ValidatorSet
- func (valSet *ValidatorSet) FindValidatorSetProposer(address common.Address)
- func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
- func (valSet *ValidatorSet) GetByIndex(index uint) (address []byte, val *Validator)
- func (valSet *ValidatorSet) GetProposer() (proposer *Validator)
- func (valSet *ValidatorSet) HasAddress(address []byte) bool
- func (valSet *ValidatorSet) Hash() []byte
- func (valSet *ValidatorSet) IncrementAccum(times uint)
- func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) MakeIDs() map[string]interface{}
- func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
- func (valSet *ValidatorSet) RemoveForPK(pk ecdsa.PublicKey) (val *Validator, removed bool)
- func (valSet *ValidatorSet) Size() uint
- func (valSet *ValidatorSet) String() string
- func (valSet *ValidatorSet) StringIndented(indent string) string
- func (valSet *ValidatorSet) TotalVotingPower() int64
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height uint64, commit *Commit) error
- func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string, blockID BlockID, height uint64, ...) error
- type ValidatorsByAddress
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *help.BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *help.BitArray
- func (voteSet *VoteSet) BitArrayString() string
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address []byte) *Vote
- func (voteSet *VoteSet) GetByIndex(valIndex uint) *Vote
- func (voteSet *VoteSet) GetSignByAddress(addr help.Address) *KeepBlockSign
- func (voteSet *VoteSet) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() uint64
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *Commit
- func (voteSet *VoteSet) MakePbftSigns(thash []byte) ([]*ttypes.PbftSign, error)
- func (voteSet *VoteSet) MarshalJSON() ([]byte, error)
- func (voteSet *VoteSet) Round() int
- func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error
- func (voteSet *VoteSet) Size() uint
- func (voteSet *VoteSet) String() string
- func (voteSet *VoteSet) StringIndented(indent string) string
- func (voteSet *VoteSet) StringShort() string
- func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- func (voteSet *VoteSet) VoteStrings() []string
- type VoteSetJSON
- type VoteSetReader
Constants ¶
const ( MaxLimitBlockStore = 200 MaxBlockBytes = 1048510 // lMB )
-------------------------------------------------------
const ( EventCompleteProposal = "CompleteProposal" EventLock = "Lock" //EventNewBlock = "NewBlock" //EventNewBlockHeader = "NewBlockHeader" EventNewRound = "NewRound" EventNewRoundStep = "NewRoundStep" EventPolka = "Polka" EventRelock = "Relock" EventTimeoutPropose = "TimeoutPropose" EventTimeoutWait = "TimeoutWait" //EventTx = "Tx" EventUnlock = "Unlock" EventVote = "Vote" EventMsgNotFound = "MessageUnsubscribe" )
Reserved event types
const ( //HealthOut peer time out HealthOut = 1200 BlackDoorCount = 4 SwitchPartWork = 0 SwitchPartBack = 1 SwitchPartSeed = 2 )
const ( RoundStepNewHeight = RoundStepType(0x01) // Wait til CommitTime + timeoutCommit RoundStepNewRound = RoundStepType(0x02) // Setup new round and go to RoundStepPropose RoundStepPropose = RoundStepType(0x03) // Did propose, gossip proposal RoundStepPrevote = RoundStepType(0x04) // Did prevote, gossip prevotes RoundStepPrevoteWait = RoundStepType(0x05) // Did receive any +2/3 prevotes, start timeout RoundStepPrecommit = RoundStepType(0x06) // Did precommit, gossip precommits RoundStepPrecommitWait = RoundStepType(0x07) // Did receive any +2/3 precommits, start timeout RoundStepCommit = RoundStepType(0x08) // Entered commit state machine // NOTE: RoundStepNewHeight acts as RoundStepCommitWait. RoundStepBlockSync = RoundStepType(0xee) // Entered commit state machine )
RoundStepType
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
const ( //BlockPartSizeBytes is part's size BlockPartSizeBytes uint = 65536 // 64kB, )
const TimeFormat = time.RFC3339Nano
TimeFormat is used for generating the sigs
Variables ¶
var ( //ErrPartSetUnexpectedIndex is Error part set unexpected index ErrPartSetUnexpectedIndex = errors.New("error part set unexpected index") //ErrPartSetInvalidProof is Error part set invalid proof ErrPartSetInvalidProof = errors.New("error part set invalid proof") )
var ( //ErrVoteUnexpectedStep is Error Unexpected step ErrVoteUnexpectedStep = errors.New("unexpected step") //ErrVoteInvalidValidatorIndex is Error Invalid validator index ErrVoteInvalidValidatorIndex = errors.New("invalid validator index") // ErrVoteInvalidValidatorAddress is Error Invalid validator address ErrVoteInvalidValidatorAddress = errors.New("invalid validator address") //ErrVoteInvalidSignature is Error Invalid signature ErrVoteInvalidSignature = errors.New("invalid signature") //ErrVoteInvalidBlockHash is Error Invalid block hash //ErrVoteInvalidBlockHash = errors.New("invalid block hash") //ErrVoteNonDeterministicSignature is Error Non-deterministic signature ErrVoteNonDeterministicSignature = errors.New("non-deterministic signature") //ErrVoteConflictingVotes is Error Conflicting votes from validator ErrVoteConflictingVotes = errors.New("conflicting votes from validator") //ErrVoteNil is Error Nil vote ErrVoteNil = errors.New("nil vote") )
var EnableHealthMgr = true
var ( //ErrorGotVoteFromUnwantedRound is Peer has sent a vote that does not match our round for more than one round ErrorGotVoteFromUnwantedRound = errors.New("peer has sent a vote that does not match our round for more than one round") )
var (
//PeerStateKey is reactor key
PeerStateKey = "ConsensusReactor.peerState"
)
Functions ¶
func CanonicalTime ¶
func EqualCommitteeMemberArray ¶
func EqualCommitteeMemberArray(a, b []*ctypes.CommitteeMember) bool
func MakeBlockFromPartSet ¶
MakeBlockFromPartSet partSet to block
func RegisterBlockAmino ¶
RegisterBlockAmino is register for block amino
Types ¶
type BlockID ¶
type BlockID struct {
Hash help.HexBytes `json:"hash"`
PartsHeader PartSetHeader `json:"parts"`
}
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
type BlockMeta ¶
type BlockMeta struct {
Block *ctypes.Block
BlockID *BlockID
BlockPacks *PartSet
SeenCommit *Commit
Proposal *Proposal
}
BlockMeta struct
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
BlockStore struct
func NewBlockStore ¶
func NewBlockStore() *BlockStore
NewBlockStore warning all function not thread_safe
func (*BlockStore) LoadBlockCommit ¶
func (b *BlockStore) LoadBlockCommit(height uint64) *Commit
LoadBlockCommit is load blocks commit vote
func (*BlockStore) LoadBlockMeta ¶
func (b *BlockStore) LoadBlockMeta(height uint64) *BlockMeta
LoadBlockMeta load BlockMeta with height
func (*BlockStore) LoadBlockPart ¶
func (b *BlockStore) LoadBlockPart(height uint64, index uint) *Part
LoadBlockPart load block part with height and index
func (*BlockStore) MaxBlockHeight ¶
func (b *BlockStore) MaxBlockHeight() uint64
MaxBlockHeight get max fast block height
func (*BlockStore) MinBlockHeight ¶
func (b *BlockStore) MinBlockHeight() uint64
MinBlockHeight get min fast block height
type CanonicalJSONBlockID ¶
type CanonicalJSONBlockID struct {
Hash help.HexBytes `json:"hash,omitempty"`
PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"`
}
func CanonicalBlockID ¶
func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID
type CanonicalJSONHeartbeat ¶
type CanonicalJSONPartSetHeader ¶
type CanonicalJSONPartSetHeader struct {
Hash help.HexBytes `json:"hash,omitempty"`
Total uint `json:"total,omitempty"`
}
func CanonicalPartSetHeader ¶
func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader
type CanonicalJSONProposal ¶
type CanonicalJSONProposal struct {
ChainID string `json:"@chain_id"`
Type string `json:"@type"`
BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"`
Height uint64 `json:"height"`
POLBlockID CanonicalJSONBlockID `json:"pol_block_id"`
POLRound uint `json:"pol_round"`
Round uint `json:"round"`
Timestamp string `json:"timestamp"`
}
func CanonicalProposal ¶
func CanonicalProposal(chainID string, proposal *Proposal) CanonicalJSONProposal
type CanonicalJSONVote ¶
type CanonicalJSONVote struct {
ChainID string `json:"@chain_id"`
Type string `json:"@type"`
BlockID CanonicalJSONBlockID `json:"block_id"`
Height uint64 `json:"height"`
Round uint `json:"round"`
Timestamp string `json:"timestamp"`
VoteType byte `json:"type"`
}
func CanonicalVote ¶
func CanonicalVote(chainID string, vote *Vote) CanonicalJSONVote
type Commit ¶
type Commit struct {
// NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order.
// Any peer with a block can gossip precommits by index with a peer without recalculating the
// active ValidatorSet.
BlockID BlockID `json:"block_id"`
Precommits []*Vote `json:"precommits"`
// contains filtered or unexported fields
}
Commit contains the evidence that a block was committed by a set of validators. NOTE: Commit is empty for height 1, but never nil.
func (*Commit) FirstPrecommit ¶
FirstPrecommit returns the first non-nil precommit in the commit. If all precommits are nil, it returns an empty precommit with height 0.
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data.
type EventBus ¶
type EventBus struct {
help.BaseService
// contains filtered or unexported fields
}
EventBus is a common bus for all events going through the system. All calls are proxied to underlying pubsub server. All events must be published using EventBus to ensure correct data types.
func (*EventBus) PublishEventCompleteProposal ¶
func (b *EventBus) PublishEventCompleteProposal(event EventDataRoundState) error
PublishEventCompleteProposal send event data common EventCompleteProposal
func (*EventBus) PublishEventLock ¶
func (b *EventBus) PublishEventLock(event EventDataRoundState) error
PublishEventLock send event data common
func (*EventBus) PublishEventNewRound ¶
func (b *EventBus) PublishEventNewRound(event EventDataRoundState) error
PublishEventNewRound send event data common EventNewRound
func (*EventBus) PublishEventNewRoundStep ¶
func (b *EventBus) PublishEventNewRoundStep(event EventDataRoundState) error
PublishEventNewRoundStep send event data common EventNewRoundStep
func (*EventBus) PublishEventPolka ¶
func (b *EventBus) PublishEventPolka(event EventDataRoundState) error
PublishEventPolka send event data common EventPolka
func (*EventBus) PublishEventRelock ¶
func (b *EventBus) PublishEventRelock(event EventDataRoundState) error
PublishEventRelock send event data common relock
func (*EventBus) PublishEventTimeoutPropose ¶
func (b *EventBus) PublishEventTimeoutPropose(event EventDataRoundState) error
PublishEventTimeoutPropose send event data common EventTimeoutPropose
func (*EventBus) PublishEventTimeoutWait ¶
func (b *EventBus) PublishEventTimeoutWait(event EventDataRoundState) error
PublishEventTimeoutWait send event data common EventTimeoutWait
func (*EventBus) PublishEventUnlock ¶
func (b *EventBus) PublishEventUnlock(event EventDataRoundState) error
PublishEventUnlock send event data common unlock
func (*EventBus) PublishEventVote ¶
func (b *EventBus) PublishEventVote(event EventDataVote) error
PublishEventVote send event data common EventVote
type EventData ¶
type EventData interface {
}
EventData Generic event data can be typed and registered with go-amino via concrete implementation of this interface
type EventDataCommon ¶
type EventDataCommon struct {
Key string `json:"key"`
Data EventDataRoundState `json:"data"`
}
EventDataCommon struct
type EventDataRoundState ¶
type EventDataRoundState struct {
Height uint64 `json:"height"`
Round uint `json:"round"`
Step string `json:"step"`
// private, not exposed to websockets
RoundState interface{} `json:"-"`
}
EventDataRoundState NOTE: This goes into the replay WAL
type EventSwitch ¶
type EventSwitch interface {
help.Service
Fireable
AddListenerForEvent(listenerID, event string, cb EventCallback)
RemoveListenerForEvent(event string, listenerID string)
RemoveListener(listenerID string)
}
EventSwitch interface
type Eventable ¶
type Eventable interface {
SetEventSwitch(evsw EventSwitch)
}
Eventable reactors and other modules should export this interface to become eventable
type Health ¶
type Health struct {
ID tp2p.ID
IP string
Port uint32
Tick int32
State uint32
HType uint32
Val *Validator
Self bool
}
Health struct
type HealthMgr ¶
type HealthMgr struct {
help.BaseService
Work map[tp2p.ID]*Health
Back []*Health
// contains filtered or unexported fields
}
HealthMgr struct
func (*HealthMgr) ChanFrom ¶
func (h *HealthMgr) ChanFrom() chan *SwitchValidator
ChanFrom get switchChanTo for recv from state
func (*HealthMgr) ChanTo ¶
func (h *HealthMgr) ChanTo() chan *SwitchValidator
ChanTo get switchChanTo for send to state
func (*HealthMgr) PutBackHealth ¶
PutBackHealth add a *health to back
func (*HealthMgr) PutWorkHealth ¶
PutWorkHealth add a *health to work
func (*HealthMgr) UpdataHealthInfo ¶
UpdataHealthInfo update one health
func (*HealthMgr) UpdateFromCommittee ¶
func (h *HealthMgr) UpdateFromCommittee(member, backMember ctypes.CommitteeMembers)
UpdateFromCommittee agent put member and back, update flag
func (*HealthMgr) VerifySwitch ¶
func (h *HealthMgr) VerifySwitch(sv *SwitchValidator) error
VerifySwitch verify remove and add switchEnter
type HealthsByAddress ¶
type HealthsByAddress []*Health
HealthsByAddress Sort Healths by address
func (HealthsByAddress) Len ¶
func (hs HealthsByAddress) Len() int
func (HealthsByAddress) Less ¶
func (hs HealthsByAddress) Less(i, j int) bool
func (HealthsByAddress) Swap ¶
func (hs HealthsByAddress) Swap(i, j int)
type HeightVoteSet ¶
type HeightVoteSet struct {
// contains filtered or unexported fields
}
HeightVoteSet comment
Keeps track of all VoteSets from round 0 to round 'round'.
Also keeps track of up to one RoundVoteSet greater than 'round' from each peer, to facilitate catchup syncing of commits.
A commit is +2/3 precommits for a block at a round, but which round is not known in advance, so when a peer provides a precommit for a round greater than mtx.round, we create a new entry in roundVoteSets but also remember the peer to prevent abuse. We let each peer provide us with up to 2 unexpected "catchup" rounds. One for their LastCommit round, and another for the official commit round.
func NewHeightVoteSet ¶
func NewHeightVoteSet(chainID string, height uint64, valSet *ValidatorSet) *HeightVoteSet
NewHeightVoteSet get new HeightVoteSet
func (*HeightVoteSet) AddVote ¶
func (hvs *HeightVoteSet) AddVote(vote *Vote, peerID string) (added bool, err error)
AddVote Duplicate votes return added=false, err=nil. By convention, peerID is "" if origin is self.
func (*HeightVoteSet) GetSignsFromVote ¶
func (hvs *HeightVoteSet) GetSignsFromVote(round int, hash []byte, addr help.Address) *KeepBlockSign
GetSignsFromVote get sign from all round
func (*HeightVoteSet) Height ¶
func (hvs *HeightVoteSet) Height() uint64
Height get now VoteSet Height
func (*HeightVoteSet) MarshalJSON ¶
func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error)
MarshalJSON get all votes json
func (*HeightVoteSet) POLInfo ¶
func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID BlockID)
POLInfo Last round and blockID that has +2/3 prevotes for a particular block or nil. Returns -1 if no such round exists.
func (*HeightVoteSet) Precommits ¶
func (hvs *HeightVoteSet) Precommits(round int) *VoteSet
Precommits get preCommit vote
func (*HeightVoteSet) Prevotes ¶
func (hvs *HeightVoteSet) Prevotes(round int) *VoteSet
Prevotes get preVote vote
func (*HeightVoteSet) Reset ¶
func (hvs *HeightVoteSet) Reset(height uint64, valSet *ValidatorSet)
Reset is reset ValidatorSet
func (*HeightVoteSet) SetPeerMaj23 ¶
SetPeerMaj23 If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too
func (*HeightVoteSet) SetRound ¶
func (hvs *HeightVoteSet) SetRound(round int)
SetRound Create more RoundVoteSets up to round.
func (*HeightVoteSet) String ¶
func (hvs *HeightVoteSet) String() string
--------------------------------------------------------- string and json
func (*HeightVoteSet) StringIndented ¶
func (hvs *HeightVoteSet) StringIndented(indent string) string
StringIndented get Indented voteSet string
type KeepBlockSign ¶
KeepBlockSign is block's sign
type P2PID ¶
type P2PID string
P2PID UNSTABLE XXX: duplicate of p2p.ID to avoid dependence between packages. Perhaps we can have a minimal types package containing this (and other things?) that both `types` and `p2p` import ?
type Part ¶
type Part struct {
Index uint `json:"index"`
Bytes help.HexBytes `json:"bytes"`
Proof help.SimpleProof `json:"proof"`
// contains filtered or unexported fields
}
Part struct
func (*Part) StringIndented ¶
StringIndented indent's string
type PartSet ¶
type PartSet struct {
// contains filtered or unexported fields
}
PartSet struct
func MakePartSet ¶
MakePartSet block to partset
func NewPartSetFromData ¶
NewPartSetFromData Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
NewPartSetFromHeader Returns an empty PartSet ready to be populated.
func (*PartSet) HasHeader ¶
func (ps *PartSet) HasHeader(header PartSetHeader) bool
HasHeader Compare header
func (*PartSet) MarshalJSON ¶
MarshalJSON is marshal partsBitArray to json
func (*PartSet) StringShort ¶
StringShort print partSet count and total
type PartSetHeader ¶
PartSetHeader struct
func (PartSetHeader) Equals ¶
func (psh PartSetHeader) Equals(other PartSetHeader) bool
Equals compare other partSet header's hash
func (PartSetHeader) String ¶
func (psh PartSetHeader) String() string
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
PartSetReader struct
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
NewPartSetReader return new reader
type PeerRoundState ¶
type PeerRoundState struct {
Height uint64 `json:"height"` // Height peer is at
Round uint `json:"round"` // Round peer is at, -1 if unknown.
Step RoundStepType `json:"step"` // Step peer is at
StartTime time.Time `json:"start_time"` // Estimated start of round 0 at this height
Proposal bool `json:"proposal"` // True if peer has proposal for this round
ProposalBlockPartsHeader PartSetHeader `json:"proposal_block_parts_header"` //
ProposalBlockParts *help.BitArray `json:"proposal_block_parts"` //
ProposalPOLRound uint `json:"proposal_pol_round"` // Proposal's POL round. -1 if none.
ProposalPOL *help.BitArray `json:"proposal_pol"` // nil until ProposalPOLMessage received.
Prevotes *help.BitArray `json:"prevotes"` // All votes peer has for this round
Precommits *help.BitArray `json:"precommits"` // All precommits peer has for this round
LastCommitRound uint `json:"last_commit_round"` // Round of commit for last height. -1 if none.
LastCommit *help.BitArray `json:"last_commit"` // All commit precommits of commit for last height.
CatchupCommitRound int `json:"catchup_commit_round"` // Round that we have commit for. Not necessarily unique. -1 if none.
CatchupCommit *help.BitArray `json:"catchup_commit"` // All commit precommits peer has for this height & CatchupCommitRound
}
PeerRoundState contains the known state of a peer. NOTE: Read-only when returned by PeerState.GetRoundState().
func (PeerRoundState) String ¶
func (prs PeerRoundState) String() string
String returns a string representation of the PeerRoundState
func (PeerRoundState) StringIndented ¶
func (prs PeerRoundState) StringIndented(indent string) string
StringIndented returns a string representation of the PeerRoundState
type PrivValidator ¶
type PrivValidator interface {
GetAddress() help.Address // redundant since .PubKey().Address()
GetPubKey() tcrypto.PubKey
SignVote(chainID string, vote *Vote) error
SignProposal(chainID string, proposal *Proposal) error
}
PrivValidator defines the functionality of a local TrueChain validator that signs votes, proposals, and heartbeats, and never double signs.
func NewPrivValidator ¶
func NewPrivValidator(priv ecdsa.PrivateKey) PrivValidator
NewPrivValidator return new private Validator
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []PrivValidator
PrivValidatorsByAddress is private validators for address
func (PrivValidatorsByAddress) Len ¶
func (pvs PrivValidatorsByAddress) Len() int
func (PrivValidatorsByAddress) Less ¶
func (pvs PrivValidatorsByAddress) Less(i, j int) bool
func (PrivValidatorsByAddress) Swap ¶
func (pvs PrivValidatorsByAddress) Swap(i, j int)
type Proposal ¶
type Proposal struct {
Height uint64 `json:"height"`
Round uint `json:"round"`
Timestamp time.Time `json:"timestamp"`
BlockPartsHeader PartSetHeader `json:"block_parts_header"`
POLRound uint `json:"pol_round"` // -1 if null.
POLBlockID BlockID `json:"pol_block_id"` // zero if null.
Signature []byte `json:"signature"`
}
Proposal defines a block proposal for the consensus. It refers to the block only by its PartSetHeader. It must be signed by the correct proposer for the given Height/Round to be considered valid. It may depend on votes from a previous round, a so-called Proof-of-Lock (POL) round, as noted in the POLRound and POLBlockID.
func NewProposal ¶
func NewProposal(height uint64, round int, blockPartsHeader PartSetHeader, polRound uint, polBlockID BlockID) *Proposal
NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.
type RoundState ¶
type RoundState struct {
Height uint64 `json:"height"` // Height we are working on
Round uint `json:"round"`
Step RoundStepType `json:"step"`
StartTime time.Time `json:"start_time"`
CommitTime time.Time `json:"commit_time"` // Subjective time when +2/3 precommits for Block at Round were found
Validators *ValidatorSet `json:"validators"`
Proposal *Proposal `json:"proposal"`
ProposalBlock *types.Block `json:"proposal_block"`
ProposalBlockParts *PartSet `json:"proposal_block_parts"`
LockedRound uint `json:"locked_round"`
LockedBlock *types.Block `json:"locked_block"`
LockedBlockParts *PartSet `json:"locked_block_parts"`
ValidRound uint `json:"valid_round"` // Last known round with POL for non-nil valid block.
ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above.
ValidBlockParts *PartSet `json:"valid_block_parts"` // Last known block parts of POL metnioned above.
Votes *HeightVoteSet `json:"votes"`
CommitRound uint `json:"commit_round"` //
LastCommit *VoteSet `json:"last_commit"` // Last precommits at Height-1
}
RoundState defines the internal consensus state. NOTE: Not thread safe. Should only be manipulated by functions downstream of the cs.receiveRoutine
func (*RoundState) RoundStateEvent ¶
func (rs *RoundState) RoundStateEvent() EventDataRoundState
RoundStateEvent returns the H/R/S of the RoundState as an event.
func (*RoundState) RoundStateSimple ¶
func (rs *RoundState) RoundStateSimple() RoundStateSimple
RoundStateSimple Compress the RoundState to RoundStateSimple
func (*RoundState) StringIndented ¶
func (rs *RoundState) StringIndented(indent string) string
StringIndented returns a string
func (*RoundState) StringShort ¶
func (rs *RoundState) StringShort() string
StringShort returns a string
type RoundStateSimple ¶
type RoundStateSimple struct {
HeightRoundStep string `json:"height/round/step"`
StartTime time.Time `json:"start_time"`
ProposalBlockHash help.HexBytes `json:"proposal_block_hash"`
LockedBlockHash help.HexBytes `json:"locked_block_hash"`
ValidBlockHash help.HexBytes `json:"valid_block_hash"`
Votes json.RawMessage `json:"height_vote_set"`
}
RoundStateSimple Compressed version of the RoundState for use in RPC
type RoundStepType ¶
type RoundStepType uint8 // These must be numeric, ordered.
RoundStepType enumerates the state of the consensus state machine
type RoundVoteSet ¶
RoundVoteSet struct
type StateAgent ¶
type StateAgent interface {
GetValidator() *ValidatorSet
UpdateValidator(vset *ValidatorSet, makeids bool) error
GetLastValidator() *ValidatorSet
GetLastValidatorAddress() common.Address
GetLastBlockHeight() uint64
SetEndHeight(h uint64)
SetBeginHeight(h uint64)
GetChainID() string
MakeBlock(v *SwitchValidator) (*ctypes.Block, error)
MakePartSet(partSize uint, block *ctypes.Block) (*PartSet, error)
ValidateBlock(block *ctypes.Block, result bool) (*KeepBlockSign, error)
ConsensusCommit(block *ctypes.Block) error
GetAddress() help.Address
GetPubKey() tcrypto.PubKey
SignVote(chainID string, vote *Vote) error
SignProposal(chainID string, proposal *Proposal) error
PrivReset()
}
StateAgent implements PrivValidator
type StateAgentImpl ¶
type StateAgentImpl struct {
Priv *privValidator
Agent ctypes.PbftAgentProxy
Validators *ValidatorSet
ChainID string
LastHeight uint64
BeginHeight uint64
EndHeight uint64
CID uint64
// contains filtered or unexported fields
}
StateAgentImpl agent state struct
func NewStateAgent ¶
func NewStateAgent(agent ctypes.PbftAgentProxy, chainID string, vals *ValidatorSet, height, cid uint64) *StateAgentImpl
NewStateAgent return new agent state
func (*StateAgentImpl) Broadcast ¶
func (state *StateAgentImpl) Broadcast(height *big.Int)
Broadcast is agent Broadcast block
func (*StateAgentImpl) ConsensusCommit ¶
func (state *StateAgentImpl) ConsensusCommit(block *ctypes.Block) error
ConsensusCommit is BroadcastConsensus block to agent
func (*StateAgentImpl) GetAddress ¶
func (state *StateAgentImpl) GetAddress() help.Address
GetAddress get priv_validator's address
func (*StateAgentImpl) GetChainID ¶
func (state *StateAgentImpl) GetChainID() string
GetChainID is get state'chainID
func (*StateAgentImpl) GetLastBlockHeight ¶
func (state *StateAgentImpl) GetLastBlockHeight() uint64
GetLastBlockHeight is get fast block height for agent
func (*StateAgentImpl) GetLastValidator ¶
func (state *StateAgentImpl) GetLastValidator() *ValidatorSet
GetLastValidator is get state's Validators
func (*StateAgentImpl) GetLastValidatorAddress ¶
func (state *StateAgentImpl) GetLastValidatorAddress() common.Address
func (*StateAgentImpl) GetPubKey ¶
func (state *StateAgentImpl) GetPubKey() tcrypto.PubKey
GetPubKey get priv_validator's public key
func (*StateAgentImpl) GetValidator ¶
func (state *StateAgentImpl) GetValidator() *ValidatorSet
GetValidator is get state's Validators
func (*StateAgentImpl) HasPeerID ¶
func (state *StateAgentImpl) HasPeerID(id string) error
HasPeerID judge the peerid whether in validators
func (*StateAgentImpl) MakeBlock ¶
func (state *StateAgentImpl) MakeBlock(v *SwitchValidator) (*ctypes.Block, error)
MakeBlock from agent FetchFastBlock
func (*StateAgentImpl) MakePartSet ¶
MakePartSet make block to part for partSiae
func (*StateAgentImpl) PrivReset ¶
func (state *StateAgentImpl) PrivReset()
PrivReset reset PrivValidator
func (*StateAgentImpl) SetBeginHeight ¶
func (state *StateAgentImpl) SetBeginHeight(h uint64)
SetBeginHeight set height of block for the committee to begin. (begin,end]
func (*StateAgentImpl) SetEndHeight ¶
func (state *StateAgentImpl) SetEndHeight(h uint64)
SetEndHeight set now committee fast block height for end. (begin,end]
func (*StateAgentImpl) SetPrivValidator ¶
func (state *StateAgentImpl) SetPrivValidator(priv PrivValidator)
SetPrivValidator set state a new PrivValidator
func (*StateAgentImpl) SignProposal ¶
func (state *StateAgentImpl) SignProposal(chainID string, proposal *Proposal) error
SignProposal sign of proposal msg
func (*StateAgentImpl) SignVote ¶
func (state *StateAgentImpl) SignVote(chainID string, vote *Vote) error
SignVote sign of vote
func (*StateAgentImpl) UpdateValidator ¶
func (state *StateAgentImpl) UpdateValidator(vset *ValidatorSet, makeids bool) error
UpdateValidator set new Validators when committee member was changed
func (*StateAgentImpl) ValidateBlock ¶
func (state *StateAgentImpl) ValidateBlock(block *ctypes.Block, result bool) (*KeepBlockSign, error)
ValidateBlock get a verify block if nil return new
type SwitchValidator ¶
type SwitchValidator struct {
Remove *Health
Add *Health
Infos []*ctypes.CommitteeMember
Resion string
From int // 0-- add ,1-- resore
DoorCount int
Round int // -1 not exc,no lock
ID uint64
}
SwitchValidator struct
func (*SwitchValidator) Equal ¶
func (s *SwitchValidator) Equal(other *SwitchValidator) bool
Equal return true they are same id or both nil otherwise return false
func (*SwitchValidator) EqualWithRemove ¶
func (s *SwitchValidator) EqualWithRemove(other *SwitchValidator) bool
EqualWithRemove return true they are same id or both nil otherwise return false
func (*SwitchValidator) EqualWithoutID ¶
func (s *SwitchValidator) EqualWithoutID(other *SwitchValidator) bool
EqualWithoutID return true they are same id or both nil otherwise return false
func (*SwitchValidator) String ¶
func (s *SwitchValidator) String() string
type Validator ¶
type Validator struct {
Address help.Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
Accum int64 `json:"accum"`
}
Validator state for each Validator NOTE: The Accum is not included in Validator.Hash(); make sure to update that method if changes are made here
func NewValidator ¶
NewValidator is return a new Validator
func (*Validator) CompareAccum ¶
CompareAccum Returns the one with higher Accum.
func (*Validator) Copy ¶
Copy Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.
type ValidatorSet ¶
type ValidatorSet struct {
// NOTE: persisted via reflect, must be exported.
Validators []*Validator `json:"validators"`
Proposer *Validator `json:"proposer"`
// contains filtered or unexported fields
}
ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.
func NewValidatorSet ¶
func NewValidatorSet(vals []*Validator) *ValidatorSet
NewValidatorSet is make a Validator to ValidatorSet
func (*ValidatorSet) Add ¶
func (valSet *ValidatorSet) Add(val *Validator) (added bool)
Add adds val to the validator set and returns true. It returns false if val is already in the set.
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet
func (*ValidatorSet) FindValidatorSetProposer ¶
func (valSet *ValidatorSet) FindValidatorSetProposer(address common.Address)
func (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
GetByAddress returns an index of the validator with address and validator itself if found. Otherwise, -1 and nil are returned.
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index uint) (address []byte, val *Validator)
GetByIndex returns the validator's address and validator itself by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).
func (*ValidatorSet) GetProposer ¶
func (valSet *ValidatorSet) GetProposer() (proposer *Validator)
GetProposer returns the current proposer. If the validator set is empty, nil is returned.
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address []byte) bool
HasAddress returns true if address given is in the validator set, false - otherwise.
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
Hash returns the Merkle root hash build using validators (as leaves) in the set.
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times uint)
IncrementAccum increments accum of each validator and updates the proposer. Panics if validator set is empty.
func (*ValidatorSet) Iterate ¶
func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
Iterate will run the given function over the set.
func (*ValidatorSet) MakeIDs ¶
func (valSet *ValidatorSet) MakeIDs() map[string]interface{}
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
Remove deletes the validator with address. It returns the validator removed and true. If returns nil and false if validator is not present in the set.
func (*ValidatorSet) RemoveForPK ¶
func (valSet *ValidatorSet) RemoveForPK(pk ecdsa.PublicKey) (val *Validator, removed bool)
RemoveForPK deletes the validator with address. It returns the validator removed and true. If returns nil and false if validator is not present in the set.
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() uint
Size returns the length of the validator set.
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
StringIndented is VoteSet Indented format String
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
TotalVotingPower returns the sum of the voting powers of all validators.
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
Update updates val and returns true. It returns false if val is not present in the set.
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height uint64, commit *Commit) error
VerifyCommit Verify that +2/3 of the set had signed the given signBytes
func (*ValidatorSet) VerifyCommitAny ¶
func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string, blockID BlockID, height uint64, commit *Commit) error
VerifyCommitAny will check to see if the set would be valid with a different validator set.
valSet is the validator set that we know * over 2/3 of the power in old signed this block
newSet is the validator set that signed this block
- only votes from old are sufficient for 2/3 majority in the new set as well
That means that: * 10% of the valset can't just declare themselves kings * If the validator set is 3x old size, we need more proof to trust
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
ValidatorsByAddress is Sort validators by address
func (ValidatorsByAddress) Len ¶
func (vs ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (vs ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (vs ValidatorsByAddress) Swap(i, j int)
type Vote ¶
type Vote struct {
ValidatorAddress help.Address `json:"validator_address"`
ValidatorIndex uint `json:"validator_index"`
Height uint64 `json:"height"`
Round uint `json:"round"`
Result uint `json:"result"`
Timestamp time.Time `json:"timestamp"`
Type byte `json:"type"`
BlockID BlockID `json:"block_id"` // zero if vote is nil.
Signature []byte `json:"signature"`
ResultSign []byte `json:"reuslt_signature"`
}
Vote Represents a prevote, precommit, or commit vote from validators for consensus.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet comment
VoteSet helps collect signatures from validators at each height+round for a
predefined vote type.
We need VoteSet to be able to keep track of conflicting votes when validators
double-sign. Yet, we can't keep track of *all* the votes seen, as that could
be a DoS attack vector.
There are two storage areas for votes.
1. voteSet.votes
2. voteSet.votesByBlock
`.votes` is the "canonical" list of votes. It always has at least one vote,
if a vote from a validator had been seen at all. Usually it keeps track of
the first vote seen, but when a 2/3 majority is found, votes for that get
priority and are copied over from `.votesByBlock`.
`.votesByBlock` keeps track of a list of votes for a particular block. There
are two ways a &blockVotes{} gets created in `.votesByBlock`.
1. the first vote seen by a validator was for the particular block.
2. a peer claims to have seen 2/3 majority for the particular block.
Since the first vote from a validator will always get added in `.votesByBlock`
, all votes in `.votes` will have a corresponding entry in `.votesByBlock`.
When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its
votes are copied into `.votes`.
All this is memory bounded because conflicting votes only get added if a peer
told us to track that block, each peer only gets to tell us 1 such block, and,
there's only a limited number of peers.
NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func NewVoteSet ¶
func NewVoteSet(chainID string, height uint64, round int, typeB byte, valSet *ValidatorSet) *VoteSet
NewVoteSet Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddVote ¶
AddVote Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[
UnexpectedStep | InvalidIndex | InvalidAddress | InvalidSignature | InvalidBlockHash | ConflictingVotes ]
Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil NOTE: Vote must not be nil
func (*VoteSet) BitArrayByBlockID ¶
BitArrayByBlockID get a BitArray for blockID
func (*VoteSet) BitArrayString ¶
BitArrayString Return the bit-array of votes including the fraction of power that has voted like: "BA{29:xx__x__x_x___x__x_______xxx__} 856/1304 = 0.66"
func (*VoteSet) GetByAddress ¶
GetByAddress is get a vote for address
func (*VoteSet) GetByIndex ¶
GetByIndex if validator has conflicting votes, returns "canonical" vote
func (*VoteSet) GetSignByAddress ¶
func (voteSet *VoteSet) GetSignByAddress(addr help.Address) *KeepBlockSign
GetSignByAddress is address to KeepBlockSign
func (*VoteSet) HasTwoThirdsAny ¶
HasTwoThirdsAny return is have up 2/3
func (*VoteSet) HasTwoThirdsMajority ¶
HasTwoThirdsMajority check is have first block id
func (*VoteSet) MakePbftSigns ¶
MakePbftSigns is make a signs for hash
func (*VoteSet) MarshalJSON ¶
MarshalJSON Marshal the VoteSet to JSON. Same as String(), just in JSON, and without the height/round/typeB (since its already included in the votes).
func (*VoteSet) SetPeerMaj23 ¶
SetPeerMaj23 If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil
func (*VoteSet) StringIndented ¶
StringIndented is format print VoteSet indented
func (*VoteSet) StringShort ¶
StringShort is format VteSet to short format
func (*VoteSet) TwoThirdsMajority ¶
TwoThirdsMajority If there was a +2/3 majority for blockID, return blockID and true. Else, return the empty BlockID{} and false.
func (*VoteSet) VoteStrings ¶
VoteStrings Returns a list of votes compressed to more readable strings.
type VoteSetJSON ¶
type VoteSetJSON struct {
Votes []string `json:"votes"`
VotesBitArray string `json:"votes_bit_array"`
PeerMaj23s map[P2PID]BlockID `json:"peer_maj_23s"`
}
VoteSetJSON More human readable JSON of the vote set NOTE: insufficient for unmarshalling from (compressed votes) TODO: make the peerMaj23s nicer to read (eg just the block hash)