tendermint: github.com/tendermint/tendermint/consensus Index | Files | Directories

package consensus

import "github.com/tendermint/tendermint/consensus"

Index

Package Files

codec.go metrics.go reactor.go replay.go replay_file.go state.go ticker.go wal.go wal_generator.go

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"
)

Variables

var (
    ErrPeerStateHeightRegression = errors.New("Error peer state height regression")
    ErrPeerStateInvalidStartTime = errors.New("Error peer state invalid startTime")
)
var (
    ErrInvalidProposalSignature = errors.New("Error invalid proposal signature")
    ErrInvalidProposalPOLRound  = errors.New("Error invalid proposal POL round")
    ErrAddingVote               = errors.New("Error adding vote")
    ErrVoteHeightMismatch       = errors.New("Error vote height mismatch")
)

func CompareHRS Uses

func CompareHRS(h1 int64, r1 int, s1 cstypes.RoundStepType, h2 int64, r2 int, s2 cstypes.RoundStepType) int

func IsDataCorruptionError Uses

func IsDataCorruptionError(err error) bool

IsDataCorruptionError returns true if data has been corrupted inside WAL.

func NewWAL Uses

func NewWAL(walFile string, groupOptions ...func(*auto.Group)) (*baseWAL, error)

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 RegisterConsensusMessages Uses

func RegisterConsensusMessages(cdc *amino.Codec)

func RegisterWALMessages Uses

func RegisterWALMessages(cdc *amino.Codec)

func RunReplayFile Uses

func RunReplayFile(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig, console bool)

replay the wal file

func WALGenerateNBlocks Uses

func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error)

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.

func WALWithNBlocks Uses

func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error)

WALWithNBlocks returns a WAL content with numBlocks.

type BlockPartMessage Uses

type BlockPartMessage struct {
    Height int64
    Round  int
    Part   *types.Part
}

BlockPartMessage is sent when gossipping a piece of the proposed block.

func (*BlockPartMessage) String Uses

func (m *BlockPartMessage) String() string

String returns a string representation.

func (*BlockPartMessage) ValidateBasic Uses

func (m *BlockPartMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type ConsensusMessage Uses

type ConsensusMessage interface {
    ValidateBasic() error
}

ConsensusMessage is a message that can be sent and received on the ConsensusReactor

type ConsensusReactor Uses

type ConsensusReactor struct {
    p2p.BaseReactor // BaseService + p2p.Switch
    // contains filtered or unexported fields
}

ConsensusReactor defines a reactor for the consensus service.

func NewConsensusReactor Uses

func NewConsensusReactor(consensusState *ConsensusState, fastSync bool, options ...ReactorOption) *ConsensusReactor

NewConsensusReactor returns a new ConsensusReactor with the given consensusState.

func (*ConsensusReactor) AddPeer Uses

func (conR *ConsensusReactor) AddPeer(peer p2p.Peer)

AddPeer implements Reactor by spawning multiple gossiping goroutines for the peer.

func (*ConsensusReactor) FastSync Uses

func (conR *ConsensusReactor) FastSync() bool

FastSync returns whether the consensus reactor is in fast-sync mode.

func (*ConsensusReactor) GetChannels Uses

func (conR *ConsensusReactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor

func (*ConsensusReactor) InitPeer Uses

func (conR *ConsensusReactor) InitPeer(peer p2p.Peer) p2p.Peer

InitPeer implements Reactor by creating a state for the peer.

func (*ConsensusReactor) OnStart Uses

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 Uses

func (conR *ConsensusReactor) OnStop()

OnStop implements BaseService by unsubscribing from events and stopping state.

func (*ConsensusReactor) Receive Uses

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 Uses

func (conR *ConsensusReactor) RemovePeer(peer p2p.Peer, reason interface{})

RemovePeer is a noop.

func (*ConsensusReactor) SetEventBus Uses

func (conR *ConsensusReactor) SetEventBus(b *types.EventBus)

SetEventBus sets event bus.

func (*ConsensusReactor) String Uses

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 Uses

func (conR *ConsensusReactor) StringIndented(indent string) string

StringIndented returns an indented string representation of the ConsensusReactor

func (*ConsensusReactor) SwitchToConsensus Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (cs *ConsensusState) AddVote(vote *types.Vote, peerID p2p.ID) (added bool, err error)

AddVote inputs a vote.

func (*ConsensusState) GetLastHeight Uses

func (cs *ConsensusState) GetLastHeight() int64

GetLastHeight returns the last height committed. If there were no blocks, returns 0.

func (*ConsensusState) GetRoundState Uses

func (cs *ConsensusState) GetRoundState() *cstypes.RoundState

GetRoundState returns a shallow copy of the internal consensus state.

func (*ConsensusState) GetRoundStateJSON Uses

func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error)

GetRoundStateJSON returns a json of RoundState, marshalled using go-amino.

func (*ConsensusState) GetRoundStateSimpleJSON Uses

func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error)

GetRoundStateSimpleJSON returns a json of RoundStateSimple, marshalled using go-amino.

func (*ConsensusState) GetState Uses

func (cs *ConsensusState) GetState() sm.State

GetState returns a copy of the chain state.

func (*ConsensusState) GetValidators Uses

func (cs *ConsensusState) GetValidators() (int64, []*types.Validator)

GetValidators returns a copy of the current validators.

func (*ConsensusState) LoadCommit Uses

func (cs *ConsensusState) LoadCommit(height int64) *types.Commit

LoadCommit loads the commit for a given height.

func (*ConsensusState) OnStart Uses

func (cs *ConsensusState) OnStart() error

OnStart implements cmn.Service. It loads the latest state via the WAL, and starts the timeout and receive routines.

func (*ConsensusState) OnStop Uses

func (cs *ConsensusState) OnStop()

OnStop implements cmn.Service.

func (*ConsensusState) OpenWAL Uses

func (cs *ConsensusState) OpenWAL(walFile string) (WAL, error)

OpenWAL opens a file to log all consensus messages and timeouts for deterministic accountability

func (*ConsensusState) ReplayFile Uses

func (cs *ConsensusState) ReplayFile(file string, console bool) error

Replay msgs in file or start the console

func (*ConsensusState) SetEventBus Uses

func (cs *ConsensusState) SetEventBus(b *types.EventBus)

SetEventBus sets event bus.

func (*ConsensusState) SetLogger Uses

func (cs *ConsensusState) SetLogger(l log.Logger)

SetLogger implements Service.

func (*ConsensusState) SetPrivValidator Uses

func (cs *ConsensusState) SetPrivValidator(priv types.PrivValidator)

SetPrivValidator sets the private validator account for signing votes.

func (*ConsensusState) SetProposal Uses

func (cs *ConsensusState) SetProposal(proposal *types.Proposal, peerID p2p.ID) error

SetProposal inputs a proposal.

func (*ConsensusState) SetProposalAndBlock Uses

func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, peerID p2p.ID) error

SetProposalAndBlock inputs the proposal and all block parts.

func (*ConsensusState) SetTimeoutTicker Uses

func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)

SetTimeoutTicker sets the local timer. It may be useful to overwrite for testing.

func (*ConsensusState) String Uses

func (cs *ConsensusState) String() string

String returns a string.

func (*ConsensusState) Wait Uses

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 DataCorruptionError Uses

type DataCorruptionError struct {
    // contains filtered or unexported fields
}

DataCorruptionError is an error that occures if data on disk was corrupted.

func (DataCorruptionError) Cause Uses

func (e DataCorruptionError) Cause() error

func (DataCorruptionError) Error Uses

func (e DataCorruptionError) Error() string

type EndHeightMessage Uses

type EndHeightMessage struct {
    Height int64 `json:"height"`
}

EndHeightMessage marks the end of the given height inside WAL. @internal used by scripts/wal2json util.

type Handshaker Uses

type Handshaker struct {
    // contains filtered or unexported fields
}

func NewHandshaker Uses

func NewHandshaker(stateDB dbm.DB, state sm.State,
    store sm.BlockStore, genDoc *types.GenesisDoc) *Handshaker

func (*Handshaker) Handshake Uses

func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error

TODO: retry the handshake/replay if it fails ?

func (*Handshaker) NBlocks Uses

func (h *Handshaker) NBlocks() int

NBlocks returns the number of blocks applied to the state.

func (*Handshaker) ReplayBlocks Uses

func (h *Handshaker) ReplayBlocks(
    state sm.State,
    appHash []byte,
    appBlockHeight int64,
    proxyApp proxy.AppConns,
) ([]byte, error)

ReplayBlocks replays all blocks since appBlockHeight and ensures the result matches the current state. Returns the final AppHash or an error.

func (*Handshaker) SetEventBus Uses

func (h *Handshaker) SetEventBus(eventBus types.BlockEventPublisher)

SetEventBus - sets the event bus for publishing block related events. If not called, it defaults to types.NopEventBus.

func (*Handshaker) SetLogger Uses

func (h *Handshaker) SetLogger(l log.Logger)

type HasVoteMessage Uses

type HasVoteMessage struct {
    Height int64
    Round  int
    Type   types.SignedMsgType
    Index  int
}

HasVoteMessage is sent to indicate that a particular vote has been received.

func (*HasVoteMessage) String Uses

func (m *HasVoteMessage) String() string

String returns a string representation.

func (*HasVoteMessage) ValidateBasic Uses

func (m *HasVoteMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type Metrics Uses

type Metrics struct {
    // Height of the chain.
    Height metrics.Gauge

    // Number of rounds.
    Rounds metrics.Gauge

    // Number of validators.
    Validators metrics.Gauge
    // Total power of all validators.
    ValidatorsPower metrics.Gauge
    // Number of validators who did not sign.
    MissingValidators metrics.Gauge
    // Total power of the missing validators.
    MissingValidatorsPower metrics.Gauge
    // Number of validators who tried to double sign.
    ByzantineValidators metrics.Gauge
    // Total power of the byzantine validators.
    ByzantineValidatorsPower metrics.Gauge

    // Time between this and the last block.
    BlockIntervalSeconds metrics.Gauge

    // Number of transactions.
    NumTxs metrics.Gauge
    // Size of the block.
    BlockSizeBytes metrics.Gauge
    // Total number of transactions.
    TotalTxs metrics.Gauge
    // The latest block height.
    CommittedHeight metrics.Gauge
    // Whether or not a node is fast syncing. 1 if yes, 0 if no.
    FastSyncing metrics.Gauge

    // Number of blockparts transmitted by peer.
    BlockParts metrics.Counter
}

Metrics contains metrics exposed by this package.

func NopMetrics Uses

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics Uses

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").

type NewRoundStepMessage Uses

type NewRoundStepMessage struct {
    Height                int64
    Round                 int
    Step                  cstypes.RoundStepType
    SecondsSinceStartTime int
    LastCommitRound       int
}

NewRoundStepMessage is sent for every step taken in the ConsensusState. For every height/round/step transition

func (*NewRoundStepMessage) String Uses

func (m *NewRoundStepMessage) String() string

String returns a string representation.

func (*NewRoundStepMessage) ValidateBasic Uses

func (m *NewRoundStepMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type NewValidBlockMessage Uses

type NewValidBlockMessage struct {
    Height           int64
    Round            int
    BlockPartsHeader types.PartSetHeader
    BlockParts       *cmn.BitArray
    IsCommit         bool
}

NewValidBlockMessage is sent when a validator observes a valid block B in some round r, i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. In case the block is also committed, then IsCommit flag is set to true.

func (*NewValidBlockMessage) String Uses

func (m *NewValidBlockMessage) String() string

String returns a string representation.

func (*NewValidBlockMessage) ValidateBasic Uses

func (m *NewValidBlockMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type PeerState Uses

type PeerState struct {
    PRS   cstypes.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 Uses

func NewPeerState(peer p2p.Peer) *PeerState

NewPeerState returns a new PeerState for the given Peer

func (*PeerState) ApplyHasVoteMessage Uses

func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage)

ApplyHasVoteMessage updates the peer state for the new vote.

func (*PeerState) ApplyNewRoundStepMessage Uses

func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)

ApplyNewRoundStepMessage updates the peer state for the new round.

func (*PeerState) ApplyNewValidBlockMessage Uses

func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage)

ApplyNewValidBlockMessage updates the peer state for the new valid block.

func (*PeerState) ApplyProposalPOLMessage Uses

func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)

ApplyProposalPOLMessage updates the peer state for the new proposal POL.

func (*PeerState) ApplyVoteSetBitsMessage Uses

func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *cmn.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 Uses

func (ps *PeerState) BlockPartsSent() int

BlockPartsSent returns the number of useful block parts the peer has sent us.

func (*PeerState) EnsureVoteBitArrays Uses

func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int)

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 Uses

func (ps *PeerState) GetHeight() int64

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 Uses

func (ps *PeerState) GetRoundState() *cstypes.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 Uses

func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader)

InitProposalBlockParts initializes the peer's proposal block parts header and bit array.

func (*PeerState) PickSendVote Uses

func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool

PickSendVote picks a vote and sends it to the peer. Returns true if vote was sent.

func (*PeerState) PickVoteToSend Uses

func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (vote *types.Vote, ok bool)

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 Uses

func (ps *PeerState) RecordBlockPart() int

RecordBlockPart increments internal block part related statistics for this peer. It returns the total number of added block parts.

func (*PeerState) RecordVote Uses

func (ps *PeerState) RecordVote() int

RecordVote increments internal votes related statistics for this peer. It returns the total number of added votes.

func (*PeerState) SetHasProposal Uses

func (ps *PeerState) SetHasProposal(proposal *types.Proposal)

SetHasProposal sets the given proposal as known for the peer.

func (*PeerState) SetHasProposalBlockPart Uses

func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int)

SetHasProposalBlockPart sets the given block part index as known for the peer.

func (*PeerState) SetHasVote Uses

func (ps *PeerState) SetHasVote(vote *types.Vote)

SetHasVote sets the given vote as known by the peer

func (*PeerState) SetLogger Uses

func (ps *PeerState) SetLogger(logger log.Logger) *PeerState

SetLogger allows to set a logger on the peer state. Returns the peer state itself.

func (*PeerState) String Uses

func (ps *PeerState) String() string

String returns a string representation of the PeerState

func (*PeerState) StringIndented Uses

func (ps *PeerState) StringIndented(indent string) string

StringIndented returns a string representation of the PeerState

func (*PeerState) ToJSON Uses

func (ps *PeerState) ToJSON() ([]byte, error)

ToJSON returns a json of PeerState, marshalled using go-amino.

func (*PeerState) VotesSent Uses

func (ps *PeerState) VotesSent() int

VotesSent returns the number of blocks for which peer has been sending us votes.

type ProposalMessage Uses

type ProposalMessage struct {
    Proposal *types.Proposal
}

ProposalMessage is sent when a new block is proposed.

func (*ProposalMessage) String Uses

func (m *ProposalMessage) String() string

String returns a string representation.

func (*ProposalMessage) ValidateBasic Uses

func (m *ProposalMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type ProposalPOLMessage Uses

type ProposalPOLMessage struct {
    Height           int64
    ProposalPOLRound int
    ProposalPOL      *cmn.BitArray
}

ProposalPOLMessage is sent when a previous proposal is re-proposed.

func (*ProposalPOLMessage) String Uses

func (m *ProposalPOLMessage) String() string

String returns a string representation.

func (*ProposalPOLMessage) ValidateBasic Uses

func (m *ProposalPOLMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type ReactorOption Uses

type ReactorOption func(*ConsensusReactor)

func ReactorMetrics Uses

func ReactorMetrics(metrics *Metrics) ReactorOption

ReactorMetrics sets the metrics

type StateOption Uses

type StateOption func(*ConsensusState)

StateOption sets an optional parameter on the ConsensusState.

func StateMetrics Uses

func StateMetrics(metrics *Metrics) StateOption

StateMetrics sets the metrics.

type TimedWALMessage Uses

type TimedWALMessage struct {
    Time time.Time  `json:"time"` // for debugging purposes
    Msg  WALMessage `json:"msg"`
}

type TimeoutTicker Uses

type TimeoutTicker interface {
    Start() error
    Stop() error
    Chan() <-chan timeoutInfo       // on which to receive a timeout
    ScheduleTimeout(ti timeoutInfo) // reset the timer

    SetLogger(log.Logger)
}

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 Uses

func NewTimeoutTicker() TimeoutTicker

NewTimeoutTicker returns a new TimeoutTicker.

type VoteMessage Uses

type VoteMessage struct {
    Vote *types.Vote
}

VoteMessage is sent when voting for a proposal (or lack thereof).

func (*VoteMessage) String Uses

func (m *VoteMessage) String() string

String returns a string representation.

func (*VoteMessage) ValidateBasic Uses

func (m *VoteMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type VoteSetBitsMessage Uses

type VoteSetBitsMessage struct {
    Height  int64
    Round   int
    Type    types.SignedMsgType
    BlockID types.BlockID
    Votes   *cmn.BitArray
}

VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID.

func (*VoteSetBitsMessage) String Uses

func (m *VoteSetBitsMessage) String() string

String returns a string representation.

func (*VoteSetBitsMessage) ValidateBasic Uses

func (m *VoteSetBitsMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type VoteSetMaj23Message Uses

type VoteSetMaj23Message struct {
    Height  int64
    Round   int
    Type    types.SignedMsgType
    BlockID types.BlockID
}

VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes.

func (*VoteSetMaj23Message) String Uses

func (m *VoteSetMaj23Message) String() string

String returns a string representation.

func (*VoteSetMaj23Message) ValidateBasic Uses

func (m *VoteSetMaj23Message) ValidateBasic() error

ValidateBasic performs basic validation.

type WAL Uses

type WAL interface {
    Write(WALMessage)
    WriteSync(WALMessage)
    FlushAndSync() error

    SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error)

    // service methods
    Start() error
    Stop() error
    Wait()
}

WAL is an interface for any write-ahead logger.

type WALDecoder Uses

type WALDecoder struct {
    // contains filtered or unexported fields
}

A WALDecoder reads and decodes custom-encoded WAL messages from an input stream. See WALEncoder for the format used.

It will also compare the checksums and make sure data size is equal to the length from the header. If that is not the case, error will be returned.

func NewWALDecoder Uses

func NewWALDecoder(rd io.Reader) *WALDecoder

NewWALDecoder returns a new decoder that reads from rd.

func (*WALDecoder) Decode Uses

func (dec *WALDecoder) Decode() (*TimedWALMessage, error)

Decode reads the next custom-encoded value from its reader and returns it.

type WALEncoder Uses

type WALEncoder struct {
    // contains filtered or unexported fields
}

A WALEncoder writes custom-encoded WAL messages to an output stream.

Format: 4 bytes CRC sum + 4 bytes length + arbitrary-length value (go-amino encoded)

func NewWALEncoder Uses

func NewWALEncoder(wr io.Writer) *WALEncoder

NewWALEncoder returns a new encoder that writes to wr.

func (*WALEncoder) Encode Uses

func (enc *WALEncoder) Encode(v *TimedWALMessage) error

Encode writes the custom encoding of v to the stream. It returns an error if the amino-encoded size of v is greater than 1MB. Any error encountered during the write is also returned.

type WALMessage Uses

type WALMessage interface{}

type WALSearchOptions Uses

type WALSearchOptions struct {
    // IgnoreDataCorruptionErrors set to true will result in skipping data corruption errors.
    IgnoreDataCorruptionErrors bool
}

WALSearchOptions are optional arguments to SearchForEndHeight.

Directories

PathSynopsis
types

Package consensus imports 41 packages (graph) and is imported by 32 packages. Updated 2019-09-12. Refresh now. Tools for package owners.