Documentation ¶
Index ¶
- Constants
- Variables
- func CompareHRS(h1 uint64, r1 uint, s1 ttypes.RoundStepType, h2 uint64, r2 uint, ...) int
- func MakeValidators(cmm *types.CommitteeInfo) *ttypes.ValidatorSet
- func RegisterConsensusMessages(cdc *amino.Codec)
- type BlockPartMessage
- type CSOption
- type CommitStepMessage
- type ConsensusMessage
- type ConsensusReactor
- func (conR *ConsensusReactor) AddPeer(peer tp2p.Peer)
- func (conR *ConsensusReactor) FastSync() bool
- func (conR *ConsensusReactor) GetChannels() []*tp2p.ChannelDescriptor
- func (conR *ConsensusReactor) OnStart() error
- func (conR *ConsensusReactor) OnStop()
- func (conR *ConsensusReactor) Receive(chID byte, src tp2p.Peer, msgBytes []byte)
- func (conR *ConsensusReactor) RemovePeer(peer tp2p.Peer, reason interface{})
- func (conR *ConsensusReactor) SetEventBus(b *ttypes.EventBus)
- func (conR *ConsensusReactor) SetHealthMgr(h *ttypes.HealthMgr)
- func (conR *ConsensusReactor) String() string
- func (conR *ConsensusReactor) StringIndented(indent string) string
- type ConsensusState
- func (cs *ConsensusState) AddProposalBlockPart(height uint64, round uint, part *ttypes.Part, peerID string) error
- func (cs *ConsensusState) AddVote(vote *ttypes.Vote, peerID string) (added bool, err error)
- func (cs *ConsensusState) GetRoundState() *ttypes.RoundState
- func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error)
- func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error)
- func (cs *ConsensusState) OnStart() error
- func (cs *ConsensusState) OnStop()
- func (cs *ConsensusState) SetCommitteeInfo(c *types.CommitteeInfo)
- func (cs *ConsensusState) SetEventBus(b *ttypes.EventBus)
- func (cs *ConsensusState) SetHealthMgr(h *ttypes.HealthMgr)
- func (cs *ConsensusState) SetLogger(l log.Logger)
- func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator)
- func (cs *ConsensusState) SetProposal(proposal *ttypes.Proposal, peerID string) error
- func (cs *ConsensusState) SetProposalAndBlock(proposal *ttypes.Proposal, block *types.Block, parts *ttypes.PartSet, ...) error
- func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)
- func (cs *ConsensusState) String() string
- func (cs *ConsensusState) UpdateValidatorsSet(vset *ttypes.ValidatorSet, uHeight, eHeight uint64)
- func (cs *ConsensusState) Wait()
- type HasVoteMessage
- type NewRoundStepMessage
- type Node
- func (n *Node) AddHealthForCommittee(h *ttypes.HealthMgr, c *types.CommitteeInfo)
- func (n *Node) GetCommitteeStatus(committeeID *big.Int) map[string]interface{}
- func (n *Node) IsLeader(committeeID *big.Int) bool
- func (n *Node) Notify(id *big.Int, action int) error
- func (n *Node) OnStart() error
- func (n *Node) OnStop()
- func (n *Node) PutCommittee(committeeInfo *types.CommitteeInfo) error
- func (n *Node) PutNodes(id *big.Int, nodes []*types.CommitteeNode) error
- func (n *Node) RunForever()
- func (n *Node) SetCommitteeStop(committeeID *big.Int, stop uint64) error
- func (n *Node) UpdateCommittee(info *types.CommitteeInfo) error
- type PeerState
- func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage)
- func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage)
- func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)
- func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)
- func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *help.BitArray)
- func (ps *PeerState) BlockPartsSent() uint
- func (ps *PeerState) EnsureVoteBitArrays(height uint64, numValidators uint)
- func (ps *PeerState) GetHeight() uint64
- func (ps *PeerState) GetRoundState() *ttypes.PeerRoundState
- func (ps *PeerState) InitProposalBlockParts(partsHeader ttypes.PartSetHeader)
- func (ps *PeerState) PickSendVote(votes ttypes.VoteSetReader) bool
- func (ps *PeerState) PickVoteToSend(votes ttypes.VoteSetReader) (vote *ttypes.Vote, ok bool)
- func (ps *PeerState) RecordBlockPart(bp *BlockPartMessage) uint
- func (ps *PeerState) RecordVote(vote *ttypes.Vote) uint
- func (ps *PeerState) SetHasProposal(proposal *ttypes.Proposal)
- func (ps *PeerState) SetHasProposalBlockPart(height uint64, round uint, index uint)
- func (ps *PeerState) SetHasVote(vote *ttypes.Vote)
- func (ps *PeerState) SetLogger(logger log.Logger) *PeerState
- func (ps *PeerState) String() string
- func (ps *PeerState) StringIndented(indent string) string
- func (ps *PeerState) ToJSON() ([]byte, error)
- func (ps *PeerState) VotesSent() uint
- type ProposalMessage
- type ProposalPOLMessage
- type TimeoutTicker
- type ValidatorUpdateMessage
- type VoteMessage
- type VoteSetBitsMessage
- type VoteSetMaj23Message
Constants ¶
const ( //Start is status for notify Start int = iota //Stop is status for notify Stop //Switch is status for notify Switch )
const ( //StateChannel is channel state StateChannel = byte(0x20) //DataChannel is channel state DataChannel = byte(0x21) //VoteChannel is channel state VoteChannel = byte(0x22) //VoteSetBitsChannel is channel state VoteSetBitsChannel = byte(0x23) )
Variables ¶
var ( //ErrInvalidProposalSignature is Error invalid proposal signature ErrInvalidProposalSignature = errors.New("error invalid proposal signature") //ErrInvalidProposalPOLRound is Error invalid proposal POL round ErrInvalidProposalPOLRound = errors.New("error invalid proposal POL round") //ErrAddingVote is Error adding vote ErrAddingVote = errors.New("error adding vote") //ErrVoteHeightMismatch is Error vote height mismatch ErrVoteHeightMismatch = errors.New("error vote height mismatch") )
Functions ¶
func CompareHRS ¶
func CompareHRS(h1 uint64, r1 uint, s1 ttypes.RoundStepType, h2 uint64, r2 uint, s2 ttypes.RoundStepType) int
CompareHRS is compare msg'and peerSet's height round Step
func MakeValidators ¶
func MakeValidators(cmm *types.CommitteeInfo) *ttypes.ValidatorSet
MakeValidators is make CommitteeInfo to ValidatorSet
func RegisterConsensusMessages ¶
func RegisterConsensusMessages(cdc *amino.Codec)
RegisterConsensusMessages is register all consensus message
Types ¶
type BlockPartMessage ¶
BlockPartMessage is sent when gossipping a piece of the proposed block.
func (*BlockPartMessage) String ¶
func (m *BlockPartMessage) String() string
String returns a string representation.
type CSOption ¶
type CSOption func(*ConsensusState)
CSOption sets an optional parameter on the ConsensusState.
type CommitStepMessage ¶
type CommitStepMessage struct { Height uint64 BlockPartsHeader ttypes.PartSetHeader BlockParts *help.BitArray }
CommitStepMessage is sent when a block is committed.
func (*CommitStepMessage) String ¶
func (m *CommitStepMessage) String() string
String returns a string representation.
type ConsensusMessage ¶
type ConsensusMessage interface{}
ConsensusMessage is a message that can be sent and received on the ConsensusReactor
type ConsensusReactor ¶
type ConsensusReactor struct { tp2p.BaseReactor // BaseService + p2p.Switch // contains filtered or unexported fields }
ConsensusReactor defines a reactor for the consensus service.
func NewConsensusReactor ¶
func NewConsensusReactor(consensusState *ConsensusState, fastSync bool) *ConsensusReactor
NewConsensusReactor returns a new ConsensusReactor with the given consensusState.
func (*ConsensusReactor) AddPeer ¶
func (conR *ConsensusReactor) AddPeer(peer tp2p.Peer)
AddPeer implements Reactor
func (*ConsensusReactor) FastSync ¶
func (conR *ConsensusReactor) FastSync() bool
FastSync returns whether the consensus reactor is in fast-sync mode.
func (*ConsensusReactor) GetChannels ¶
func (conR *ConsensusReactor) GetChannels() []*tp2p.ChannelDescriptor
GetChannels implements Reactor
func (*ConsensusReactor) OnStart ¶
func (conR *ConsensusReactor) OnStart() error
OnStart implements BaseService by subscribing to events, which later will be broadcasted to other peers and starting state if we're not in fast sync.
func (*ConsensusReactor) OnStop ¶
func (conR *ConsensusReactor) OnStop()
OnStop implements BaseService by unsubscribing from events and stopping state.
func (*ConsensusReactor) Receive ¶
func (conR *ConsensusReactor) Receive(chID byte, src tp2p.Peer, msgBytes []byte)
Receive implements Reactor NOTE: We process these messages even when we're fast_syncing. Messages affect either a peer state or the consensus state. Peer state updates can happen in parallel, but processing of proposals, block parts, and votes are ordered by the receiveRoutine NOTE: blocks on consensus state for proposals, block parts, and votes
func (*ConsensusReactor) RemovePeer ¶
func (conR *ConsensusReactor) RemovePeer(peer tp2p.Peer, reason interface{})
RemovePeer implements Reactor
func (*ConsensusReactor) SetEventBus ¶
func (conR *ConsensusReactor) SetEventBus(b *ttypes.EventBus)
SetEventBus sets event bus.
func (*ConsensusReactor) SetHealthMgr ¶
func (conR *ConsensusReactor) SetHealthMgr(h *ttypes.HealthMgr)
SetHealthMgr sets peer healthMgr
func (*ConsensusReactor) String ¶
func (conR *ConsensusReactor) String() string
String returns a string representation of the ConsensusReactor. NOTE: For now, it is just a hard-coded string to avoid accessing unprotected shared variables. TODO: improve!
func (*ConsensusReactor) StringIndented ¶
func (conR *ConsensusReactor) StringIndented(indent string) string
StringIndented returns an indented string representation of the ConsensusReactor
type ConsensusState ¶
type ConsensusState struct { help.BaseService ttypes.RoundState // contains filtered or unexported fields }
ConsensusState handles execution of the consensus algorithm. It processes votes and proposals, and upon reaching agreement, commits blocks to the chain and executes them against the application. The internal state machine receives input from peers, the internal validator, and from a timer.
func NewConsensusState ¶
func NewConsensusState( config *cfg.ConsensusConfig, state ttypes.StateAgent, store *ttypes.BlockStore, options ...CSOption, ) *ConsensusState
NewConsensusState returns a new ConsensusState.
func (*ConsensusState) AddProposalBlockPart ¶
func (cs *ConsensusState) AddProposalBlockPart(height uint64, round uint, part *ttypes.Part, peerID string) error
AddProposalBlockPart inputs a part of the proposal block. not used
func (*ConsensusState) GetRoundState ¶
func (cs *ConsensusState) GetRoundState() *ttypes.RoundState
GetRoundState returns a shallow copy of the internal consensus state.
func (*ConsensusState) GetRoundStateJSON ¶
func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error)
GetRoundStateJSON returns a json of RoundState, marshalled using go-amino.
func (*ConsensusState) GetRoundStateSimpleJSON ¶
func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error)
GetRoundStateSimpleJSON returns a json of RoundStateSimple, marshalled using go-amino.
func (*ConsensusState) OnStart ¶
func (cs *ConsensusState) OnStart() error
OnStart implements help.Service. It loads the latest state via the WAL, and starts the timeout and receive routines.
func (*ConsensusState) OnStop ¶
func (cs *ConsensusState) OnStop()
OnStop implements help.Service. It stops all routines and waits for the WAL to finish.
func (*ConsensusState) SetCommitteeInfo ¶
func (cs *ConsensusState) SetCommitteeInfo(c *types.CommitteeInfo)
func (*ConsensusState) SetEventBus ¶
func (cs *ConsensusState) SetEventBus(b *ttypes.EventBus)
SetEventBus sets event bus.
func (*ConsensusState) SetHealthMgr ¶
func (cs *ConsensusState) SetHealthMgr(h *ttypes.HealthMgr)
SetHealthMgr sets peer health
func (*ConsensusState) SetLogger ¶
func (cs *ConsensusState) SetLogger(l log.Logger)
SetLogger implements Service.
func (*ConsensusState) SetPrivValidator ¶
func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator)
SetPrivValidator sets the private validator account for signing votes.
func (*ConsensusState) SetProposal ¶
func (cs *ConsensusState) SetProposal(proposal *ttypes.Proposal, peerID string) error
SetProposal inputs a proposal. not used
func (*ConsensusState) SetProposalAndBlock ¶
func (cs *ConsensusState) SetProposalAndBlock(proposal *ttypes.Proposal, block *types.Block, parts *ttypes.PartSet, peerID string) error
SetProposalAndBlock inputs the proposal and all block parts. not used
func (*ConsensusState) SetTimeoutTicker ¶
func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)
SetTimeoutTicker sets the local timer. It may be useful to overwrite for testing.
func (*ConsensusState) UpdateValidatorsSet ¶
func (cs *ConsensusState) UpdateValidatorsSet(vset *ttypes.ValidatorSet, uHeight, eHeight uint64)
UpdateValidatorsSet is Set when the committee member is chaneged
func (*ConsensusState) Wait ¶
func (cs *ConsensusState) Wait()
Wait waits for the the main routine to return. NOTE: be sure to Stop() the event switch and drain any event channels or this may deadlock
type HasVoteMessage ¶
HasVoteMessage is sent to indicate that a particular vote has been received.
func (*HasVoteMessage) String ¶
func (m *HasVoteMessage) String() string
String returns a string representation.
type NewRoundStepMessage ¶
type NewRoundStepMessage struct { Height uint64 Round uint Step ttypes.RoundStepType SecondsSinceStartTime uint LastCommitRound uint }
NewRoundStepMessage is sent for every step taken in the ConsensusState. For every height/round/step transition
func (*NewRoundStepMessage) String ¶
func (m *NewRoundStepMessage) String() string
String returns a string representation.
type Node ¶
type Node struct { help.BaseService Agent types.PbftAgentProxy // contains filtered or unexported fields }
Node is the highest level interface to a full abeychain node. It includes all configuration information and running services.
func NewNode ¶
func NewNode(config *cfg.TbftConfig, chainID string, priv *ecdsa.PrivateKey, agent types.PbftAgentProxy) (*Node, error)
NewNode returns a new, ready to go, abeychain Node.
func (*Node) AddHealthForCommittee ¶
func (n *Node) AddHealthForCommittee(h *ttypes.HealthMgr, c *types.CommitteeInfo)
func (*Node) GetCommitteeStatus ¶
GetCommitteeStatus is show committee info in api
func (*Node) PutCommittee ¶
func (n *Node) PutCommittee(committeeInfo *types.CommitteeInfo) error
PutCommittee is agent put all committee to server
func (*Node) RunForever ¶
func (n *Node) RunForever()
RunForever waits for an interrupt signal and stops the node.
func (*Node) SetCommitteeStop ¶
SetCommitteeStop is stop committeeID server
func (*Node) UpdateCommittee ¶
func (n *Node) UpdateCommittee(info *types.CommitteeInfo) error
UpdateCommittee update the committee info from agent when the members was changed
type PeerState ¶
type PeerState struct { PRS ttypes.PeerRoundState `json:"round_state"` // Exposed. Stats *peerStateStats `json:"stats"` // Exposed. // contains filtered or unexported fields }
PeerState contains the known state of a peer, including its connection and threadsafe access to its PeerRoundState. NOTE: THIS GETS DUMPED WITH rpc/core/consensus.go. Be mindful of what you Expose.
func NewPeerState ¶
NewPeerState returns a new PeerState for the given Peer
func (*PeerState) ApplyCommitStepMessage ¶
func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage)
ApplyCommitStepMessage updates the peer state for the new commit.
func (*PeerState) ApplyHasVoteMessage ¶
func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage)
ApplyHasVoteMessage updates the peer state for the new vote.
func (*PeerState) ApplyNewRoundStepMessage ¶
func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)
ApplyNewRoundStepMessage updates the peer state for the new round.
func (*PeerState) ApplyProposalPOLMessage ¶
func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)
ApplyProposalPOLMessage updates the peer state for the new proposal POL.
func (*PeerState) ApplyVoteSetBitsMessage ¶
func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *help.BitArray)
ApplyVoteSetBitsMessage updates the peer state for the bit-array of votes it claims to have for the corresponding BlockID. `ourVotes` is a BitArray of votes we have for msg.BlockID NOTE: if ourVotes is nil (e.g. msg.Height < rs.Height), we conservatively overwrite ps's votes w/ msg.Votes.
func (*PeerState) BlockPartsSent ¶
BlockPartsSent returns the number of blocks for which peer has been sending us block parts.
func (*PeerState) EnsureVoteBitArrays ¶
EnsureVoteBitArrays ensures the bit-arrays have been allocated for tracking what votes this peer has received. NOTE: It's important to make sure that numValidators actually matches what the node sees as the number of validators for height.
func (*PeerState) GetHeight ¶
GetHeight returns an atomic snapshot of the PeerRoundState's height used by the mempool to ensure peers are caught up before broadcasting new txs
func (*PeerState) GetRoundState ¶
func (ps *PeerState) GetRoundState() *ttypes.PeerRoundState
GetRoundState returns an shallow copy of the PeerRoundState. There's no point in mutating it since it won't change PeerState.
func (*PeerState) InitProposalBlockParts ¶
func (ps *PeerState) InitProposalBlockParts(partsHeader ttypes.PartSetHeader)
InitProposalBlockParts initializes the peer's proposal block parts header and bit array.
func (*PeerState) PickSendVote ¶
func (ps *PeerState) PickSendVote(votes ttypes.VoteSetReader) bool
PickSendVote picks a vote and sends it to the peer. Returns true if vote was sent.
func (*PeerState) PickVoteToSend ¶
PickVoteToSend picks a vote to send to the peer. Returns true if a vote was picked. NOTE: `votes` must be the correct Size() for the Height().
func (*PeerState) RecordBlockPart ¶
func (ps *PeerState) RecordBlockPart(bp *BlockPartMessage) uint
RecordBlockPart updates internal statistics for this peer by recording the block part. It returns the total number of block parts (1 per block). This essentially means the number of blocks for which peer has been sending us block parts.
func (*PeerState) RecordVote ¶
RecordVote updates internal statistics for this peer by recording the vote. It returns the total number of votes (1 per block). This essentially means the number of blocks for which peer has been sending us votes.
func (*PeerState) SetHasProposal ¶
SetHasProposal sets the given proposal as known for the peer.
func (*PeerState) SetHasProposalBlockPart ¶
SetHasProposalBlockPart sets the given block part index as known for the peer.
func (*PeerState) SetHasVote ¶
SetHasVote sets the given vote as known by the peer
func (*PeerState) SetLogger ¶
SetLogger allows to set a logger on the peer state. Returns the peer state itself.
func (*PeerState) StringIndented ¶
StringIndented returns a string representation of the PeerState
type ProposalMessage ¶
ProposalMessage is sent when a new block is proposed.
func (*ProposalMessage) String ¶
func (m *ProposalMessage) String() string
String returns a string representation.
type ProposalPOLMessage ¶
ProposalPOLMessage is sent when a previous proposal is re-proposed.
func (*ProposalPOLMessage) String ¶
func (m *ProposalPOLMessage) String() string
String returns a string representation.
type TimeoutTicker ¶
type TimeoutTicker interface { Start() error Stop() error Chan() <-chan timeoutInfo // on which to receive a timeout ScheduleTimeout(ti timeoutInfo) // reset the timer }
TimeoutTicker is a timer that schedules timeouts conditional on the height/round/step in the timeoutInfo. The timeoutInfo.Duration may be non-positive.
func NewTimeoutTicker ¶
func NewTimeoutTicker(name string) TimeoutTicker
NewTimeoutTicker returns a new TimeoutTicker.
type ValidatorUpdateMessage ¶
type ValidatorUpdateMessage struct {
// contains filtered or unexported fields
}
ValidatorUpdateMessage is send when a new committee is elected
func (*ValidatorUpdateMessage) String ¶
func (v *ValidatorUpdateMessage) String() string
String returns a string representation.
type VoteMessage ¶
VoteMessage is sent when voting for a proposal (or lack thereof).
func (*VoteMessage) String ¶
func (m *VoteMessage) String() string
String returns a string representation.
type VoteSetBitsMessage ¶
type VoteSetBitsMessage struct { Height uint64 Round uint Type byte BlockID ttypes.BlockID Votes *help.BitArray }
VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID.
func (*VoteSetBitsMessage) String ¶
func (m *VoteSetBitsMessage) String() string
String returns a string representation.
type VoteSetMaj23Message ¶
VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes.
func (*VoteSetMaj23Message) String ¶
func (m *VoteSetMaj23Message) String() string
String returns a string representation.
Directories ¶
Path | Synopsis |
---|---|
flowrate
Package flowrate provides the tools for monitoring and limiting the flow rate of an arbitrary data stream.
|
Package flowrate provides the tools for monitoring and limiting the flow rate of an arbitrary data stream. |
upnp
Taken from taipei-torrent.
|
Taken from taipei-torrent. |