Documentation
¶
Index ¶
- Constants
- Variables
- func CompareHRS(h1 int64, r1 int, s1 cstypes.RoundStepType, h2 int64, r2 int, ...) int
- func IsDataCorruptionError(err error) bool
- func NewWAL(walFile string, groupOptions ...func(*auto.Group)) (*baseWAL, error)
- func RegisterConsensusMessages(cdc *amino.Codec)
- func RegisterWALMessages(cdc *amino.Codec)
- func RunReplayFile(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console bool)
- func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error)
- func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error)
- type BlockPartMessage
- type ConsensusMessage
- type ConsensusReactor
- func (conR *ConsensusReactor) AddPeer(peer p2p.Peer)
- func (conR *ConsensusReactor) FastSync() bool
- func (conR *ConsensusReactor) GetChannels() []*p2p.ChannelDescriptor
- func (conR *ConsensusReactor) OnStart() error
- func (conR *ConsensusReactor) OnStop()
- func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
- func (conR *ConsensusReactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (conR *ConsensusReactor) SetEventBus(b *types.EventBus)
- func (conR *ConsensusReactor) String() string
- func (conR *ConsensusReactor) StringIndented(indent string) string
- func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int)
- type ConsensusState
- func (cs *ConsensusState) AddProposalBlockPart(height int64, round int, part *types.Part, peerID p2p.ID) error
- func (cs *ConsensusState) AddVote(vote *types.Vote, peerID p2p.ID) (added bool, err error)
- func (cs *ConsensusState) GetLastHeight() int64
- func (cs *ConsensusState) GetRoundState() *cstypes.RoundState
- func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error)
- func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error)
- func (cs *ConsensusState) GetState() sm.State
- func (cs *ConsensusState) GetValidators() (int64, []*types.Validator)
- func (cs *ConsensusState) LoadCommit(height int64) *types.Commit
- func (cs *ConsensusState) OnStart() error
- func (cs *ConsensusState) OnStop()
- func (cs *ConsensusState) OpenWAL(walFile string) (WAL, error)
- func (cs *ConsensusState) ReplayFile(file string, console bool) error
- func (cs *ConsensusState) SetEventBus(b *types.EventBus)
- func (cs *ConsensusState) SetLogger(l log.Logger)
- func (cs *ConsensusState) SetPrivValidator(priv types.PrivValidator)
- func (cs *ConsensusState) SetProposal(proposal *types.Proposal, peerID p2p.ID) error
- func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, ...) error
- func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)
- func (cs *ConsensusState) String() string
- func (cs *ConsensusState) Wait()
- type DataCorruptionError
- type EndHeightMessage
- type Handshaker
- func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error
- func (h *Handshaker) NBlocks() int
- func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight int64, proxyApp proxy.AppConns) ([]byte, error)
- func (h *Handshaker) SetEventBus(eventBus types.BlockEventPublisher)
- func (h *Handshaker) SetLogger(l log.Logger)
- type HasVoteMessage
- type Metrics
- type NewRoundStepMessage
- type NewValidBlockMessage
- type PeerState
- func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage)
- func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)
- func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage)
- func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)
- func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *cmn.BitArray)
- func (ps *PeerState) BlockPartsSent() int
- func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int)
- func (ps *PeerState) GetHeight() int64
- func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState
- func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader)
- func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool
- func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (vote *types.Vote, ok bool)
- func (ps *PeerState) RecordBlockPart() int
- func (ps *PeerState) RecordVote() int
- func (ps *PeerState) SetHasProposal(proposal *types.Proposal)
- func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int)
- func (ps *PeerState) SetHasVote(vote *types.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() int
- type ProposalMessage
- type ProposalPOLMessage
- type ReactorOption
- type RoundInfo
- type StateOption
- type TimedWALMessage
- type TimeoutTicker
- type VoteMessage
- type VoteSetBitsMessage
- type VoteSetMaj23Message
- type WAL
- type WALDecoder
- type WALEncoder
- type WALMessage
- type WALSearchOptions
Constants ¶
const ( StateChannel = byte(0x20) DataChannel = byte(0x21) VoteChannel = byte(0x22) VoteSetBitsChannel = byte(0x23) )
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "consensus" )
const POSTADDR = "http://127.0.0.1:8001/"
Variables ¶
Functions ¶
func CompareHRS ¶
func CompareHRS(h1 int64, r1 int, s1 cstypes.RoundStepType, h2 int64, r2 int, s2 cstypes.RoundStepType) int
func IsDataCorruptionError ¶
IsDataCorruptionError returns true if data has been corrupted inside WAL.
func NewWAL ¶
NewWAL returns a new write-ahead logger based on `baseWAL`, which implements WAL. It's flushed and synced to disk every 2s and once when stopped.
func RunReplayFile ¶
func RunReplayFile(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console bool)
replay the wal file
func WALGenerateNBlocks ¶
WALGenerateNBlocks generates a consensus WAL. It does this by spinning up a stripped down version of node (proxy app, event bus, consensus state) with a persistent kvstore application and special consensus wal instance (byteBufferWAL) and waits until numBlocks are created. If the node fails to produce given numBlocks, it returns an error.
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.
func (*BlockPartMessage) ValidateBasic ¶
func (m *BlockPartMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type ConsensusMessage ¶
type ConsensusMessage interface {
ValidateBasic() error
}
ConsensusMessage is a message that can be sent and received on the ConsensusReactor
type ConsensusReactor ¶
type ConsensusReactor struct {
p2p.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, options ...ReactorOption) *ConsensusReactor
NewConsensusReactor returns a new ConsensusReactor with the given consensusState.
func (*ConsensusReactor) AddPeer ¶
func (conR *ConsensusReactor) AddPeer(peer p2p.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() []*p2p.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 p2p.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 p2p.Peer, reason interface{})
RemovePeer implements Reactor
func (*ConsensusReactor) SetEventBus ¶
func (conR *ConsensusReactor) SetEventBus(b *types.EventBus)
SetEventBus sets event bus.
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
func (*ConsensusReactor) SwitchToConsensus ¶
func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int)
SwitchToConsensus switches from fast_sync mode to consensus mode. It resets the state, turns off fast_sync, and starts the consensus state-machine
type ConsensusState ¶
type ConsensusState struct {
cmn.BaseService
cstypes.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 sm.State, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, txNotifier txNotifier, evpool evidencePool, options ...StateOption, ) *ConsensusState
NewConsensusState returns a new ConsensusState.
func (*ConsensusState) AddProposalBlockPart ¶
func (cs *ConsensusState) AddProposalBlockPart(height int64, round int, part *types.Part, peerID p2p.ID) error
AddProposalBlockPart inputs a part of the proposal block.
func (*ConsensusState) AddVote ¶
AddVote inputs a vote.
func (*ConsensusState) GetLastHeight ¶
func (cs *ConsensusState) GetLastHeight() int64
GetLastHeight returns the last height committed. If there were no blocks, returns 0.
func (*ConsensusState) GetRoundState ¶
func (cs *ConsensusState) GetRoundState() *cstypes.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 *