Documentation ¶
Overview ¶
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func MajorityTwoThird(n int) int
- type BftBasicInfo
- func (z *BftBasicInfo) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *BftBasicInfo) EncodeMsg(en *msgp.Writer) (err error)
- func (z *BftBasicInfo) MarshalMsg(b []byte) (o []byte, err error)
- func (z *BftBasicInfo) Msgsize() (s int)
- func (b *BftBasicInfo) ProvideHeight() uint64
- func (m BftBasicInfo) String() string
- func (z *BftBasicInfo) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BftMessage
- type BftMessageEvent
- type BftMessagePreCommit
- func (m *BftMessagePreCommit) BlsSignatureTargets() []byte
- func (z *BftMessagePreCommit) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *BftMessagePreCommit) EncodeMsg(en *msgp.Writer) (err error)
- func (z *BftMessagePreCommit) GetType() BftMessageType
- func (z *BftMessagePreCommit) MarshalMsg(b []byte) (o []byte, err error)
- func (z *BftMessagePreCommit) Msgsize() (s int)
- func (z *BftMessagePreCommit) PublicKey() []byte
- func (m *BftMessagePreCommit) SignatureTargets() []byte
- func (m BftMessagePreCommit) String() string
- func (z *BftMessagePreCommit) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BftMessagePreVote
- func (z *BftMessagePreVote) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *BftMessagePreVote) EncodeMsg(en *msgp.Writer) (err error)
- func (z *BftMessagePreVote) GetType() BftMessageType
- func (z *BftMessagePreVote) MarshalMsg(b []byte) (o []byte, err error)
- func (z *BftMessagePreVote) Msgsize() (s int)
- func (z *BftMessagePreVote) PublicKey() []byte
- func (m *BftMessagePreVote) SignatureTargets() []byte
- func (m BftMessagePreVote) String() string
- func (z *BftMessagePreVote) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BftMessageProposal
- func (z *BftMessageProposal) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *BftMessageProposal) EncodeMsg(en *msgp.Writer) (err error)
- func (m *BftMessageProposal) GetType() BftMessageType
- func (z *BftMessageProposal) MarshalMsg(b []byte) (o []byte, err error)
- func (z *BftMessageProposal) Msgsize() (s int)
- func (m *BftMessageProposal) PublicKey() []byte
- func (m *BftMessageProposal) SignatureTargets() []byte
- func (m BftMessageProposal) String() string
- func (z *BftMessageProposal) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BftMessageType
- func (z *BftMessageType) DecodeMsg(dc *msgp.Reader) (err error)
- func (z BftMessageType) EncodeMsg(en *msgp.Writer) (err error)
- func (z BftMessageType) MarshalMsg(b []byte) (o []byte, err error)
- func (z BftMessageType) Msgsize() (s int)
- func (m BftMessageType) String() string
- func (z *BftMessageType) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BftPartner
- type BftPeer
- type BftPeerCommunicatorIncoming
- type BftPeerCommunicatorOutgoing
- type BftStatus
- type BftStatusReport
- type ChangeStateEvent
- type ConsensusDecision
- type ConsensusReachedListener
- type DecisionMaker
- type DefaultBftPartner
- func (p *DefaultBftPartner) Broadcast(messageType BftMessageType, hr HeightRound, content Proposal, validRound int)
- func (p *DefaultBftPartner) EventLoop()
- func (p *DefaultBftPartner) GetBftPeerCommunicatorIncoming() BftPeerCommunicatorIncoming
- func (p *DefaultBftPartner) GetValue(newBlock bool) (Proposal, ProposalCondition)
- func (p *DefaultBftPartner) OnTimeoutPreCommit(context WaiterContext)
- func (p *DefaultBftPartner) OnTimeoutPreVote(context WaiterContext)
- func (p *DefaultBftPartner) OnTimeoutPropose(context WaiterContext)
- func (p *DefaultBftPartner) Proposer(hr HeightRound) int
- func (p *DefaultBftPartner) RegisterConsensusReachedListener(listener ConsensusReachedListener)
- func (p *DefaultBftPartner) Reset(nbParticipants int, id int)
- func (p *DefaultBftPartner) Start()
- func (p *DefaultBftPartner) StartNewEra(height uint64, round int)
- func (p *DefaultBftPartner) Status() interface{}
- func (p *DefaultBftPartner) Stop()
- func (p *DefaultBftPartner) WaitStepTimeout(stepType StepType, timeout time.Duration, hr HeightRound, ...)
- func (p *DefaultBftPartner) WaiterLoop()
- func (p *DefaultBftPartner) WipeOldStates()
- type HeightRound
- func (z *HeightRound) DecodeMsg(dc *msgp.Reader) (err error)
- func (z HeightRound) EncodeMsg(en *msgp.Writer) (err error)
- func (h *HeightRound) IsAfter(o HeightRound) bool
- func (h *HeightRound) IsAfterOrEqual(o HeightRound) bool
- func (h *HeightRound) IsBefore(o HeightRound) bool
- func (z HeightRound) MarshalMsg(b []byte) (o []byte, err error)
- func (z HeightRound) Msgsize() (s int)
- func (h *HeightRound) String() string
- func (z *HeightRound) UnmarshalMsg(bts []byte) (o []byte, err error)
- type HeightRoundState
- type HeightRoundStateMap
- type MsgpEnabled
- type Proposal
- type ProposalCondition
- type ProposalGenerator
- type ProposalValidator
- type Signable
- type StepType
- type StringProposal
- func (s StringProposal) Copy() Proposal
- func (z *StringProposal) DecodeMsg(dc *msgp.Reader) (err error)
- func (z StringProposal) EncodeMsg(en *msgp.Writer) (err error)
- func (s StringProposal) Equal(o Proposal) bool
- func (s StringProposal) GetId() *types.Hash
- func (z StringProposal) MarshalMsg(b []byte) (o []byte, err error)
- func (z StringProposal) Msgsize() (s int)
- func (s StringProposal) String() string
- func (z *StringProposal) UnmarshalMsg(bts []byte) (o []byte, err error)
- type TendermintContext
- type ValueIdMatchType
- type Waiter
- type WaiterContext
- type WaiterRequest
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func MajorityTwoThird ¶
Types ¶
type BftBasicInfo ¶
type BftBasicInfo struct { SourceId uint16 HeightRound HeightRound PublicKeyBytes hexutil.Bytes }
func (*BftBasicInfo) DecodeMsg ¶
func (z *BftBasicInfo) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*BftBasicInfo) EncodeMsg ¶
func (z *BftBasicInfo) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*BftBasicInfo) MarshalMsg ¶
func (z *BftBasicInfo) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*BftBasicInfo) Msgsize ¶
func (z *BftBasicInfo) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BftBasicInfo) ProvideHeight ¶
func (b *BftBasicInfo) ProvideHeight() uint64
func (BftBasicInfo) String ¶
func (m BftBasicInfo) String() string
func (*BftBasicInfo) UnmarshalMsg ¶
func (z *BftBasicInfo) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type BftMessage ¶
type BftMessage interface { Signable GetType() BftMessageType ProvideHeight() uint64 String() string }
OgMessage is the message that can be convert to BinaryMessage
type BftMessageEvent ¶
type BftMessageEvent struct { Message BftMessage Peer BftPeer }
type BftMessagePreCommit ¶
type BftMessagePreCommit struct { BftBasicInfo Idv *types.Hash // ID of the proposal, usually be the hash of the proposal BlsSignature hexutil.Bytes }
func (*BftMessagePreCommit) BlsSignatureTargets ¶
func (m *BftMessagePreCommit) BlsSignatureTargets() []byte
func (*BftMessagePreCommit) DecodeMsg ¶
func (z *BftMessagePreCommit) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*BftMessagePreCommit) EncodeMsg ¶
func (z *BftMessagePreCommit) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*BftMessagePreCommit) GetType ¶
func (z *BftMessagePreCommit) GetType() BftMessageType
func (*BftMessagePreCommit) MarshalMsg ¶
func (z *BftMessagePreCommit) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*BftMessagePreCommit) Msgsize ¶
func (z *BftMessagePreCommit) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BftMessagePreCommit) PublicKey ¶
func (z *BftMessagePreCommit) PublicKey() []byte
func (*BftMessagePreCommit) SignatureTargets ¶
func (m *BftMessagePreCommit) SignatureTargets() []byte
func (BftMessagePreCommit) String ¶
func (m BftMessagePreCommit) String() string
func (*BftMessagePreCommit) UnmarshalMsg ¶
func (z *BftMessagePreCommit) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type BftMessagePreVote ¶
type BftMessagePreVote struct { BftBasicInfo Idv *types.Hash // ID of the proposal, usually be the hash of the proposal }
func (*BftMessagePreVote) DecodeMsg ¶
func (z *BftMessagePreVote) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*BftMessagePreVote) EncodeMsg ¶
func (z *BftMessagePreVote) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*BftMessagePreVote) GetType ¶
func (z *BftMessagePreVote) GetType() BftMessageType
func (*BftMessagePreVote) MarshalMsg ¶
func (z *BftMessagePreVote) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*BftMessagePreVote) Msgsize ¶
func (z *BftMessagePreVote) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BftMessagePreVote) PublicKey ¶
func (z *BftMessagePreVote) PublicKey() []byte
func (*BftMessagePreVote) SignatureTargets ¶
func (m *BftMessagePreVote) SignatureTargets() []byte
func (BftMessagePreVote) String ¶
func (m BftMessagePreVote) String() string
func (*BftMessagePreVote) UnmarshalMsg ¶
func (z *BftMessagePreVote) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type BftMessageProposal ¶
type BftMessageProposal struct { BftBasicInfo Value Proposal //TODO ValidRound int }
func (*BftMessageProposal) DecodeMsg ¶
func (z *BftMessageProposal) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*BftMessageProposal) EncodeMsg ¶
func (z *BftMessageProposal) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*BftMessageProposal) GetType ¶
func (m *BftMessageProposal) GetType() BftMessageType
func (*BftMessageProposal) MarshalMsg ¶
func (z *BftMessageProposal) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*BftMessageProposal) Msgsize ¶
func (z *BftMessageProposal) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BftMessageProposal) PublicKey ¶
func (m *BftMessageProposal) PublicKey() []byte
func (*BftMessageProposal) SignatureTargets ¶
func (m *BftMessageProposal) SignatureTargets() []byte
func (BftMessageProposal) String ¶
func (m BftMessageProposal) String() string
func (*BftMessageProposal) UnmarshalMsg ¶
func (z *BftMessageProposal) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type BftMessageType ¶
type BftMessageType uint16
const ( BftMessageTypeProposal BftMessageType = iota + 100 BftMessageTypePreVote BftMessageTypePreCommit )
func (*BftMessageType) DecodeMsg ¶
func (z *BftMessageType) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (BftMessageType) EncodeMsg ¶
func (z BftMessageType) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (BftMessageType) MarshalMsg ¶
func (z BftMessageType) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (BftMessageType) Msgsize ¶
func (z BftMessageType) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (BftMessageType) String ¶
func (m BftMessageType) String() string
func (*BftMessageType) UnmarshalMsg ¶
func (z *BftMessageType) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type BftPartner ¶
type BftPartner interface { StartNewEra(height uint64, round int) Start() Stop() WaiterLoop() EventLoop() GetBftPeerCommunicatorIncoming() BftPeerCommunicatorIncoming RegisterConsensusReachedListener(listener ConsensusReachedListener) }
type BftPeerCommunicatorIncoming ¶
type BftPeerCommunicatorIncoming interface { GetPipeIn() chan *BftMessageEvent GetPipeOut() chan *BftMessageEvent }
type BftPeerCommunicatorOutgoing ¶
type BftPeerCommunicatorOutgoing interface { Broadcast(msg BftMessage, peers []BftPeer) Unicast(msg BftMessage, peer BftPeer) }
type BftStatus ¶
type BftStatus struct { CurrentHR HeightRound N int // total number of participants F int // max number of Byzantines Maj23 int Peers []BftPeer States HeightRoundStateMap // for line 55, round number -> count }
BftStatus records all states of BFT consider updating resetStatus() if you want to add things here
type BftStatusReport ¶
type BftStatusReport struct { HeightRound HeightRound States HeightRoundStateMap Now time.Time }
type ChangeStateEvent ¶
type ChangeStateEvent struct { NewStepType StepType HeightRound HeightRound }
type ConsensusDecision ¶
type ConsensusDecision Proposal
type ConsensusReachedListener ¶
type ConsensusReachedListener interface {
GetConsensusDecisionMadeEventChannel() chan ConsensusDecision
}
type DecisionMaker ¶
type DecisionMaker interface {
MakeDecision(proposal Proposal, state *HeightRoundState) (ConsensusDecision, error)
}
type DefaultBftPartner ¶
type DefaultBftPartner struct { Id int BftStatus *BftStatus ProposalGenerator ProposalGenerator ProposalValidator ProposalValidator DecisionMaker DecisionMaker WaiterTimeoutChannel chan *WaiterRequest // event listener for a decision once made ConsensusReachedListeners []ConsensusReachedListener // contains filtered or unexported fields }
DefaultBftPartner implements a Tendermint client according to "The latest gossip on BFT consensus" DefaultBftPartner is the action performer manipulating the BftStatus. It listens to the conditions changed outside (by message or by time) and perform actions. Note: Destroy and use a new one upon peers changing.
func NewDefaultBFTPartner ¶
func NewDefaultBFTPartner(nbParticipants int, id int, blockTime time.Duration, peerCommunicatorIncoming BftPeerCommunicatorIncoming, peerCommunicatorOutgoing BftPeerCommunicatorOutgoing, proposalGenerator ProposalGenerator, proposalValidator ProposalValidator, decisionMaker DecisionMaker, peerInfo []BftPeer, ) *DefaultBftPartner
func (*DefaultBftPartner) Broadcast ¶
func (p *DefaultBftPartner) Broadcast(messageType BftMessageType, hr HeightRound, content Proposal, validRound int)
Multicast encapsulate messages to all partners
func (*DefaultBftPartner) EventLoop ¶
func (p *DefaultBftPartner) EventLoop()
func (*DefaultBftPartner) GetBftPeerCommunicatorIncoming ¶
func (p *DefaultBftPartner) GetBftPeerCommunicatorIncoming() BftPeerCommunicatorIncoming
func (*DefaultBftPartner) GetValue ¶
func (p *DefaultBftPartner) GetValue(newBlock bool) (Proposal, ProposalCondition)
GetValue generates the value requiring consensus
func (*DefaultBftPartner) OnTimeoutPreCommit ¶
func (p *DefaultBftPartner) OnTimeoutPreCommit(context WaiterContext)
OnTimeoutPreCommit is the callback after staying too long on precommit step
func (*DefaultBftPartner) OnTimeoutPreVote ¶
func (p *DefaultBftPartner) OnTimeoutPreVote(context WaiterContext)
OnTimeoutPreVote is the callback after staying too long on prevote step
func (*DefaultBftPartner) OnTimeoutPropose ¶
func (p *DefaultBftPartner) OnTimeoutPropose(context WaiterContext)
OnTimeoutPropose is the callback after staying too long on propose step
func (*DefaultBftPartner) Proposer ¶
func (p *DefaultBftPartner) Proposer(hr HeightRound) int
Proposer returns current round proposer. Now simply round robin
func (*DefaultBftPartner) RegisterConsensusReachedListener ¶
func (p *DefaultBftPartner) RegisterConsensusReachedListener(listener ConsensusReachedListener)
RegisterConsensusReachedListener registers callback for decision made event TODO: In the future, protected the array so that it can handle term change
func (*DefaultBftPartner) Reset ¶
func (p *DefaultBftPartner) Reset(nbParticipants int, id int)
func (*DefaultBftPartner) Start ¶
func (p *DefaultBftPartner) Start()
func (*DefaultBftPartner) StartNewEra ¶
func (p *DefaultBftPartner) StartNewEra(height uint64, round int)
StartNewEra is called once height or round needs to be changed.
func (*DefaultBftPartner) Status ¶
func (p *DefaultBftPartner) Status() interface{}
func (*DefaultBftPartner) Stop ¶
func (p *DefaultBftPartner) Stop()
func (*DefaultBftPartner) WaitStepTimeout ¶
func (p *DefaultBftPartner) WaitStepTimeout(stepType StepType, timeout time.Duration, hr HeightRound, timeoutCallback func(WaiterContext))
WaitStepTimeout waits for a centain time if stepType stays too long
func (*DefaultBftPartner) WaiterLoop ¶
func (p *DefaultBftPartner) WaiterLoop()
func (*DefaultBftPartner) WipeOldStates ¶
func (p *DefaultBftPartner) WipeOldStates()
type HeightRound ¶
HeightRound is the current progress of the consensus. Height is the block height, round is the sub-progress if no consensus can be easily reached
func (*HeightRound) DecodeMsg ¶
func (z *HeightRound) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (HeightRound) EncodeMsg ¶
func (z HeightRound) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*HeightRound) IsAfter ¶
func (h *HeightRound) IsAfter(o HeightRound) bool
IsAfter judges whether self is a higher HeightRound
func (*HeightRound) IsAfterOrEqual ¶
func (h *HeightRound) IsAfterOrEqual(o HeightRound) bool
IsAfterOrEqual judges whether self is a higher or equal HeightRound
func (*HeightRound) IsBefore ¶
func (h *HeightRound) IsBefore(o HeightRound) bool
IsAfterOrEqual judges whether self is a lower HeightRound
func (HeightRound) MarshalMsg ¶
func (z HeightRound) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (HeightRound) Msgsize ¶
func (z HeightRound) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*HeightRound) String ¶
func (h *HeightRound) String() string
func (*HeightRound) UnmarshalMsg ¶
func (z *HeightRound) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type HeightRoundState ¶
type HeightRoundState struct { MessageProposal *BftMessageProposal // the proposal received in this round LockedValue Proposal LockedRound int ValidValue Proposal ValidRound int Decision ConsensusDecision // final decision of mine in this round PreVotes []*BftMessagePreVote // other peers' PreVotes PreCommits []*BftMessagePreCommit // other peers' PreCommits Sources map[uint16]bool // for line 55, who send future round so that I may advance? StepTypeEqualPreVoteTriggered bool // for line 34, FIRST time trigger StepTypeEqualOrLargerPreVoteTriggered bool // for line 36, FIRST time trigger StepTypeEqualPreCommitTriggered bool // for line 47, FIRST time trigger Step StepType // current step in this round StartAt time.Time }
HeightRoundState is the structure for each Height/Round Always keep this state that is higher than current in Partner.States map in order not to miss future things
func NewHeightRoundState ¶
func NewHeightRoundState(total int) *HeightRoundState
type HeightRoundStateMap ¶
type HeightRoundStateMap map[HeightRound]*HeightRoundState
func (*HeightRoundStateMap) MarshalJSON ¶
func (h *HeightRoundStateMap) MarshalJSON() ([]byte, error)
type MsgpEnabled ¶
type MsgpEnabled interface { msgp.MarshalSizer msgp.Unmarshaler msgp.Decodable msgp.Encodable }
type ProposalCondition ¶
type ProposalCondition struct {
ValidHeight uint64
}
type ProposalGenerator ¶
type ProposalGenerator interface {
ProduceProposal() (proposal Proposal, validCondition ProposalCondition)
}
ProposalGenerator is called when a proposal is needed
type ProposalValidator ¶
ProposalValidator is called when a proposal is needed to be verified
type StringProposal ¶
type StringProposal struct {
Content string
}
StringProposal is for test
func (StringProposal) Copy ¶
func (s StringProposal) Copy() Proposal
func (*StringProposal) DecodeMsg ¶
func (z *StringProposal) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (StringProposal) EncodeMsg ¶
func (z StringProposal) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (StringProposal) Equal ¶
func (s StringProposal) Equal(o Proposal) bool
func (StringProposal) GetId ¶
func (s StringProposal) GetId() *types.Hash
func (StringProposal) MarshalMsg ¶
func (z StringProposal) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (StringProposal) Msgsize ¶
func (z StringProposal) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (StringProposal) String ¶
func (s StringProposal) String() string
func (*StringProposal) UnmarshalMsg ¶
func (z *StringProposal) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TendermintContext ¶
type TendermintContext struct { HeightRound HeightRound StepType StepType }
func (*TendermintContext) Equal ¶
func (t *TendermintContext) Equal(w WaiterContext) bool
func (*TendermintContext) IsAfter ¶
func (t *TendermintContext) IsAfter(w WaiterContext) bool
type ValueIdMatchType ¶
type ValueIdMatchType int
const ( MatchTypeAny ValueIdMatchType = iota MatchTypeByValue MatchTypeNil )
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter provides a way to wait for some context to be changed in a certain time. If the context is not changed, callback function will be triggered. TODO: replace it with context package
func NewWaiter ¶
func NewWaiter(callbackEventChannel chan *WaiterRequest) *Waiter
func (*Waiter) StartEventLoop ¶
func (w *Waiter) StartEventLoop()
func (*Waiter) UpdateContext ¶
func (w *Waiter) UpdateContext(context WaiterContext)
func (*Waiter) UpdateRequest ¶
func (w *Waiter) UpdateRequest(req *WaiterRequest)
type WaiterContext ¶
type WaiterContext interface { Equal(WaiterContext) bool IsAfter(WaiterContext) bool }
type WaiterRequest ¶
type WaiterRequest struct { WaitTime time.Duration Context WaiterContext TimeoutCallback func(WaiterContext) }