Documentation ¶
Overview ¶
Package tendermint Uses nacl's secret_box to encrypt a net.Conn. It is (meant to be) an implementation of the STS protocol. Note we do not (yet) assume that a remote peer's pubkey is known ahead of time, and thus we are technically still vulnerable to MITM. (TODO!) See docs/sts-final.pdf for more info
Index ¶
- Constants
- Variables
- func CompareHRS(h1 int64, r1 int, s1 ttypes.RoundStepType, h2 int64, r2 int, ...) int
- func CreateBlockInfoTx(pubkey string, lastCommit *tmtypes.TendermintCommit, ...) *types.Transaction
- func DefaultDBProvider(ID string) (dbm.DB, error)
- func EvidenceToInfoBytes(evidence ttypes.Evidence, priority int64) ([]byte, error)
- func GenAddressByPubKey(pubkey crypto.PubKey) []byte
- func LoadProposer(source *tmtypes.Validator) (*ttypes.Validator, error)
- func LoadValidators(des []*ttypes.Validator, source []*tmtypes.Validator)
- func MakeGenesisDocFromFile(genDocFile string) (*ttypes.GenesisDoc, error)
- func New(cfg *types.Consensus, sub []byte) queue.Module
- func Parallel(tasks ...func())
- func SaveState(state State) *tmtypes.State
- func VerifyEvidence(stateDB *CSStateDB, s State, evidence ttypes.Evidence) error
- type BlockExecutor
- type CSStateDB
- type Client
- func (client *Client) BuildBlock() *types.Block
- func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail) error
- func (client *Client) CheckCommit(height int64) bool
- func (client *Client) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)
- func (client *Client) CheckTxsAvailable() bool
- func (client *Client) Close()
- func (client *Client) CommitBlock(propBlock *types.Block) error
- func (client *Client) CreateBlock()
- func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
- func (client *Client) GenesisDoc() *ttypes.GenesisDoc
- func (client *Client) GetGenesisBlockTime() int64
- func (client *Client) LoadBlockCommit(height int64) *tmtypes.TendermintCommit
- func (client *Client) LoadProposalBlock(height int64) *tmtypes.TendermintBlock
- func (client *Client) LoadSeenCommit(height int64) *tmtypes.TendermintCommit
- func (client *Client) PrivValidator() ttypes.PrivValidator
- func (client *Client) ProcEvent(msg queue.Message) bool
- func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.TendermintBlockInfo, error)
- func (client *Client) QueryValidatorsByHeight(height int64) (*tmtypes.ValNodes, error)
- func (client *Client) SetQueueClient(q queue.Client)
- func (client *Client) StartConsensus()
- func (client *Client) StopC() <-chan struct{}
- func (client *Client) TxsAvailable() <-chan int64
- type ConsensusState
- func (cs *ConsensusState) Commit(t time.Time) time.Time
- func (cs *ConsensusState) EmptyBlocksInterval() time.Duration
- func (cs *ConsensusState) GetPrecommitsState(height int64, round int, blockID *tmtypes.BlockID) *ttypes.BitArray
- func (cs *ConsensusState) GetPrevotesState(height int64, round int, blockID *tmtypes.BlockID) *ttypes.BitArray
- func (cs *ConsensusState) GetRoundState() *ttypes.RoundState
- func (cs *ConsensusState) GetState() State
- func (cs *ConsensusState) GetValidators() (int64, []*ttypes.Validator)
- func (cs *ConsensusState) IsProposer() bool
- func (cs *ConsensusState) IsRunning() bool
- func (cs *ConsensusState) LoadCommit(height int64) *tmtypes.TendermintCommit
- func (cs *ConsensusState) PeerGossipSleep() time.Duration
- func (cs *ConsensusState) PeerQueryMaj23Sleep() time.Duration
- func (cs *ConsensusState) Precommit(round int) time.Duration
- func (cs *ConsensusState) Prevote(round int) time.Duration
- func (cs *ConsensusState) Propose(round int) time.Duration
- func (cs *ConsensusState) SetBroadcastChannel(broadcastChannel chan<- MsgInfo)
- func (cs *ConsensusState) SetOurID(id ID)
- func (cs *ConsensusState) SetPeerMaj23(height int64, round int, voteType byte, peerID ID, blockID *tmtypes.BlockID)
- func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator)
- func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)
- func (cs *ConsensusState) Start()
- func (cs *ConsensusState) Stop()
- func (cs *ConsensusState) String() string
- func (cs *ConsensusState) WaitForTxs() bool
- type EvidenceInfo
- type EvidencePool
- func (evpool *EvidencePool) AddEvidence(evidence ttypes.Evidence) (err error)
- func (evpool *EvidencePool) EvidenceChan() <-chan ttypes.Evidence
- func (evpool *EvidencePool) MarkEvidenceAsCommitted(evidence []*tmtypes.EvidenceEnvelope)
- func (evpool *EvidencePool) PendingEvidence() []ttypes.Evidence
- func (evpool *EvidencePool) PriorityEvidence() []ttypes.Evidence
- func (evpool *EvidencePool) State() State
- func (evpool *EvidencePool) Update(block *ttypes.TendermintBlock)
- type EvidenceStore
- func (store *EvidenceStore) AddNewEvidence(evidence ttypes.Evidence, priority int64) bool
- func (store *EvidenceStore) EvidenceFromInfoBytes(data []byte) (ttypes.Evidence, error)
- func (store *EvidenceStore) GetEvidence(height int64, hash []byte) *EvidenceInfo
- func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []ttypes.Evidence)
- func (store *EvidenceStore) MarkEvidenceAsBroadcasted(evidence ttypes.Evidence)
- func (store *EvidenceStore) MarkEvidenceAsCommitted(evidence ttypes.Evidence)
- func (store *EvidenceStore) PendingEvidence() (evidence []ttypes.Evidence)
- func (store *EvidenceStore) PriorityEvidence() (evidence []ttypes.Evidence)
- type ID
- type IP2IPPort
- type MsgInfo
- type Node
- func (node *Node) Broadcast(msg MsgInfo) chan bool
- func (node *Node) BroadcastRoutine()
- func (node *Node) CompatibleWith(other NodeInfo) error
- func (node *Node) DialPeerWithAddress(addr string) error
- func (node *Node) FilterConnByAddr(addr net.Addr) error
- func (node *Node) IsRunning() bool
- func (node *Node) Start()
- func (node *Node) StartConsensusRoutine()
- func (node *Node) Stop()
- func (node *Node) StopPeerForError(peer Peer, reason interface{})
- type NodeInfo
- type Peer
- type PeerConnState
- func (ps *PeerConnState) ApplyCommitStepMessage(msg *tmtypes.CommitStepMsg)
- func (ps *PeerConnState) ApplyHasVoteMessage(msg *tmtypes.HasVoteMsg)
- func (ps *PeerConnState) ApplyNewRoundStepMessage(msg *tmtypes.NewRoundStepMsg)
- func (ps *PeerConnState) ApplyProposalPOLMessage(msg *tmtypes.ProposalPOLMsg)
- func (ps *PeerConnState) ApplyVoteSetBitsMessage(msg *tmtypes.VoteSetBitsMsg, ourVotes *ttypes.BitArray)
- func (ps *PeerConnState) EnsureVoteBitArrays(height int64, numValidators int)
- func (ps *PeerConnState) GetHeight() int64
- func (ps *PeerConnState) GetRoundState() *ttypes.PeerRoundState
- func (ps *PeerConnState) PickVoteToSend(votes ttypes.VoteSetReader) (vote *ttypes.Vote, ok bool)
- func (ps *PeerConnState) SetHasProposal(proposal *tmtypes.Proposal)
- func (ps *PeerConnState) SetHasProposalBlock(block *ttypes.TendermintBlock)
- func (ps *PeerConnState) SetHasVote(vote *ttypes.Vote)
- type PeerSet
- type SecretConnection
- func (sc *SecretConnection) Close() error
- func (sc *SecretConnection) LocalAddr() net.Addr
- func (sc *SecretConnection) Read(data []byte) (n int, err error)
- func (sc *SecretConnection) RemoteAddr() net.Addr
- func (sc *SecretConnection) RemotePubKey() crypto.PubKey
- func (sc *SecretConnection) SetDeadline(t time.Time) error
- func (sc *SecretConnection) SetReadDeadline(t time.Time) error
- func (sc *SecretConnection) SetWriteDeadline(t time.Time) error
- func (sc *SecretConnection) Write(data []byte) (n int, err error)
- type StackError
- type State
- func (s State) Bytes() []byte
- func (s State) Copy() State
- func (s State) Equals(s2 State) bool
- func (s State) GetValidators() (last *ttypes.ValidatorSet, current *ttypes.ValidatorSet)
- func (s State) IsEmpty() bool
- func (s State) MakeBlock(height int64, round int64, Txs []*types.Transaction, ...) *ttypes.TendermintBlock
- type TimeoutTicker
Constants ¶
const DebugCatchup = false
DebugCatchup define whether catch up now
const (
//MaxMsgPacketPayloadSize define
MaxMsgPacketPayloadSize = 10 * 1024 * 1024
)
Variables ¶
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") )
Errors define
Functions ¶
func CompareHRS ¶
func CompareHRS(h1 int64, r1 int, s1 ttypes.RoundStepType, h2 int64, r2 int, s2 ttypes.RoundStepType) int
CompareHRS method
func CreateBlockInfoTx ¶
func CreateBlockInfoTx(pubkey string, lastCommit *tmtypes.TendermintCommit, seenCommit *tmtypes.TendermintCommit, state *tmtypes.State, proposal *tmtypes.Proposal, block *tmtypes.TendermintBlock) *types.Transaction
CreateBlockInfoTx make blockInfo to the first transaction of the block and execer is valnode
func DefaultDBProvider ¶
DefaultDBProvider returns a database using the DBBackend and DBDir specified in the ctx.Config.
func EvidenceToInfoBytes ¶
EvidenceToInfoBytes method
func GenAddressByPubKey ¶
GenAddressByPubKey method
func LoadProposer ¶
LoadProposer convert external proposer to internal proposer
func LoadValidators ¶
LoadValidators convert all external validators to internal validators
func MakeGenesisDocFromFile ¶
func MakeGenesisDocFromFile(genDocFile string) (*ttypes.GenesisDoc, error)
MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.
Types ¶
type BlockExecutor ¶
type BlockExecutor struct {
// contains filtered or unexported fields
}
BlockExecutor provides the context and accessories for properly executing a block.
func NewBlockExecutor ¶
func NewBlockExecutor(db *CSStateDB, evpool ttypes.EvidencePool) *BlockExecutor
NewBlockExecutor returns a new BlockExecutor with a NopEventBus. Call SetEventBus to provide one.
func (*BlockExecutor) ApplyBlock ¶
func (blockExec *BlockExecutor) ApplyBlock(s State, blockID ttypes.BlockID, block *ttypes.TendermintBlock) (State, error)
ApplyBlock validates the block against the state, executes it against the app, fires the relevant events, commits the app, and saves the new state and responses. It's the only function that needs to be called from outside this package to process and commit an entire block. It takes a blockID to avoid recomputing the parts hash.
func (*BlockExecutor) ValidateBlock ¶
func (blockExec *BlockExecutor) ValidateBlock(s State, block *ttypes.TendermintBlock) error
ValidateBlock validates the given block against the given state. If the block is invalid, it returns an error. Validation does not mutate state, but does require historical information from the stateDB, ie. to verify evidence from a validator at an old height.
type CSStateDB ¶
type CSStateDB struct {
// contains filtered or unexported fields
}
CSStateDB just for EvidencePool and BlockExecutor
func (*CSStateDB) LoadValidators ¶
func (csdb *CSStateDB) LoadValidators(height int64) (*ttypes.ValidatorSet, error)
LoadValidators by height
type Client ¶
type Client struct { //config *drivers.BaseClient // contains filtered or unexported fields }
Client Tendermint implementation
func (*Client) BuildBlock ¶
BuildBlock build a new block contains some transactions
func (*Client) CheckBlock ¶
CheckBlock 暂不检查任何的交易
func (*Client) CheckCommit ¶
CheckCommit by height
func (*Client) CheckTxDup ¶
func (client *Client) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)
CheckTxDup check transactions that duplicate
func (*Client) CheckTxsAvailable ¶
CheckTxsAvailable check whether some new transactions arriving
func (*Client) CommitBlock ¶
CommitBlock call WriteBlock to real commit to chain
func (*Client) CreateBlock ¶
func (client *Client) CreateBlock()
CreateBlock a routine monitor whether some transactions available and tell client by available channel
func (*Client) CreateGenesisTx ¶
func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
CreateGenesisTx ...
func (*Client) GenesisDoc ¶
func (client *Client) GenesisDoc() *ttypes.GenesisDoc
GenesisDoc returns the Node's GenesisDoc.
func (*Client) GetGenesisBlockTime ¶
GetGenesisBlockTime ...
func (*Client) LoadBlockCommit ¶
func (client *Client) LoadBlockCommit(height int64) *tmtypes.TendermintCommit
LoadBlockCommit by height
func (*Client) LoadProposalBlock ¶
func (client *Client) LoadProposalBlock(height int64) *tmtypes.TendermintBlock
LoadProposalBlock by height
func (*Client) LoadSeenCommit ¶
func (client *Client) LoadSeenCommit(height int64) *tmtypes.TendermintCommit
LoadSeenCommit by height
func (*Client) PrivValidator ¶
func (client *Client) PrivValidator() ttypes.PrivValidator
PrivValidator returns the Node's PrivValidator. XXX: for convenience only!
func (*Client) QueryBlockInfoByHeight ¶
func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.TendermintBlockInfo, error)
QueryBlockInfoByHeight ...
func (*Client) QueryValidatorsByHeight ¶
QueryValidatorsByHeight ...
func (*Client) SetQueueClient ¶
SetQueueClient ...
func (*Client) StartConsensus ¶
func (client *Client) StartConsensus()
StartConsensus a routine that make the consensus start
func (*Client) TxsAvailable ¶
TxsAvailable check available channel
type ConsensusState ¶
type ConsensusState struct { ttypes.RoundState Quit chan struct{} ProposalBlockHash []byte // 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(client *Client, state State, blockExec *BlockExecutor, evpool ttypes.EvidencePool) *ConsensusState
NewConsensusState returns a new ConsensusState.
func (*ConsensusState) Commit ¶
func (cs *ConsensusState) Commit(t time.Time) time.Time
Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits for a single block (ie. a commit).
func (*ConsensusState) EmptyBlocksInterval ¶
func (cs *ConsensusState) EmptyBlocksInterval() time.Duration
EmptyBlocksInterval returns the amount of time to wait before proposing an empty block or starting the propose timer if there are no txs available
func (*ConsensusState) GetPrecommitsState ¶
func (cs *ConsensusState) GetPrecommitsState(height int64, round int, blockID *tmtypes.BlockID) *ttypes.BitArray
GetPrecommitsState method
func (*ConsensusState) GetPrevotesState ¶
func (cs *ConsensusState) GetPrevotesState(height int64, round int, blockID *tmtypes.BlockID) *ttypes.BitArray
GetPrevotesState method
func (*ConsensusState) GetRoundState ¶
func (cs *ConsensusState) GetRoundState() *ttypes.RoundState
GetRoundState returns a copy of the internal consensus state.
func (*ConsensusState) GetState ¶
func (cs *ConsensusState) GetState() State
GetState returns a copy of the chain state.
func (*ConsensusState) GetValidators ¶
func (cs *ConsensusState) GetValidators() (int64, []*ttypes.Validator)
GetValidators returns a copy of the current validators.
func (*ConsensusState) LoadCommit ¶
func (cs *ConsensusState) LoadCommit(height int64) *tmtypes.TendermintCommit
LoadCommit loads the commit for a given height.
func (*ConsensusState) PeerGossipSleep ¶
func (cs *ConsensusState) PeerGossipSleep() time.Duration
PeerGossipSleep returns the amount of time to sleep if there is nothing to send from the ConsensusReactor
func (*ConsensusState) PeerQueryMaj23Sleep ¶
func (cs *ConsensusState) PeerQueryMaj23Sleep() time.Duration
PeerQueryMaj23Sleep returns the amount of time to sleep after each VoteSetMaj23Message is sent in the ConsensusReactor
func (*ConsensusState) Precommit ¶
func (cs *ConsensusState) Precommit(round int) time.Duration
Precommit returns the amount of time to wait for straggler votes after receiving any +2/3 precommits
func (*ConsensusState) Prevote ¶
func (cs *ConsensusState) Prevote(round int) time.Duration
Prevote returns the amount of time to wait for straggler votes after receiving any +2/3 prevotes
func (*ConsensusState) Propose ¶
func (cs *ConsensusState) Propose(round int) time.Duration
Propose returns the amount of time to wait for a proposal
func (*ConsensusState) SetBroadcastChannel ¶
func (cs *ConsensusState) SetBroadcastChannel(broadcastChannel chan<- MsgInfo)
SetBroadcastChannel method
func (*ConsensusState) SetPeerMaj23 ¶
func (cs *ConsensusState) SetPeerMaj23(height int64, round int, voteType byte, peerID ID, blockID *tmtypes.BlockID)
SetPeerMaj23 when reach maj 2/3
func (*ConsensusState) SetPrivValidator ¶
func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator)
SetPrivValidator sets the private validator account for signing votes.
func (*ConsensusState) SetTimeoutTicker ¶
func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker)
SetTimeoutTicker sets the local timer. It may be useful to overwrite for testing.
func (*ConsensusState) Start ¶
func (cs *ConsensusState) Start()
Start It start first time starts the timeout checkTxsAvailable routine and receive routines.
func (*ConsensusState) String ¶
func (cs *ConsensusState) String() string
---------------------------------------- String returns a string.
func (*ConsensusState) WaitForTxs ¶
func (cs *ConsensusState) WaitForTxs() bool
WaitForTxs returns true if the consensus should wait for transactions before entering the propose step
type EvidenceInfo ¶
type EvidenceInfo struct { Committed bool `json:"committed"` Priority int64 `json:"priority"` Evidence envelope `json:"evidence"` }
EvidenceInfo struct
type EvidencePool ¶
type EvidencePool struct {
// contains filtered or unexported fields
}
EvidencePool maintains a pool of valid evidence in an EvidenceStore.
func NewEvidencePool ¶
func NewEvidencePool(stateDB *CSStateDB, state State, evidenceStore *EvidenceStore) *EvidencePool
NewEvidencePool method
func (*EvidencePool) AddEvidence ¶
func (evpool *EvidencePool) AddEvidence(evidence ttypes.Evidence) (err error)
AddEvidence checks the evidence is valid and adds it to the pool. Blocks on the EvidenceChan.
func (*EvidencePool) EvidenceChan ¶
func (evpool *EvidencePool) EvidenceChan() <-chan ttypes.Evidence
EvidenceChan returns an unbuffered channel on which new evidence can be received.
func (*EvidencePool) MarkEvidenceAsCommitted ¶
func (evpool *EvidencePool) MarkEvidenceAsCommitted(evidence []*tmtypes.EvidenceEnvelope)
MarkEvidenceAsCommitted marks all the evidence as committed.
func (*EvidencePool) PendingEvidence ¶
func (evpool *EvidencePool) PendingEvidence() []ttypes.Evidence
PendingEvidence returns all uncommitted evidence.
func (*EvidencePool) PriorityEvidence ¶
func (evpool *EvidencePool) PriorityEvidence() []ttypes.Evidence
PriorityEvidence returns the priority evidence.
func (*EvidencePool) State ¶
func (evpool *EvidencePool) State() State
State returns the current state of the evpool.
func (*EvidencePool) Update ¶
func (evpool *EvidencePool) Update(block *ttypes.TendermintBlock)
Update loads the latest
type EvidenceStore ¶
type EvidenceStore struct {
// contains filtered or unexported fields
}
EvidenceStore is a store of all the evidence we've seen, including evidence that has been committed, evidence that has been verified but not broadcast, and evidence that has been broadcast but not yet committed.
func (*EvidenceStore) AddNewEvidence ¶
func (store *EvidenceStore) AddNewEvidence(evidence ttypes.Evidence, priority int64) bool
AddNewEvidence adds the given evidence to the database. It returns false if the evidence is already stored.
func (*EvidenceStore) EvidenceFromInfoBytes ¶
func (store *EvidenceStore) EvidenceFromInfoBytes(data []byte) (ttypes.Evidence, error)
EvidenceFromInfoBytes method
func (*EvidenceStore) GetEvidence ¶
func (store *EvidenceStore) GetEvidence(height int64, hash []byte) *EvidenceInfo
GetEvidence fetches the evidence with the given height and hash.
func (*EvidenceStore) ListEvidence ¶
func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []ttypes.Evidence)
ListEvidence lists the evidence for the given prefix key. It is wrapped by PriorityEvidence and PendingEvidence for convenience.
func (*EvidenceStore) MarkEvidenceAsBroadcasted ¶
func (store *EvidenceStore) MarkEvidenceAsBroadcasted(evidence ttypes.Evidence)
MarkEvidenceAsBroadcasted removes evidence from Outqueue.
func (*EvidenceStore) MarkEvidenceAsCommitted ¶
func (store *EvidenceStore) MarkEvidenceAsCommitted(evidence ttypes.Evidence)
MarkEvidenceAsCommitted removes evidence from pending and outqueue and sets the state to committed.
func (*EvidenceStore) PendingEvidence ¶
func (store *EvidenceStore) PendingEvidence() (evidence []ttypes.Evidence)
PendingEvidence returns all known uncommitted evidence.
func (*EvidenceStore) PriorityEvidence ¶
func (store *EvidenceStore) PriorityEvidence() (evidence []ttypes.Evidence)
PriorityEvidence returns the evidence from the outqueue, sorted by highest priority.
type IP2IPPort ¶
type IP2IPPort struct {
// contains filtered or unexported fields
}
IP2IPPort struct
type Node ¶
type Node struct { Network string Version string ID ID IP string //get ip from connect to ourself // contains filtered or unexported fields }
Node struct
func NewNode ¶
func NewNode(seeds []string, protocol string, lAddr string, privKey crypto.PrivKey, network string, version string, state *ConsensusState, evpool *EvidencePool) *Node
NewNode method
func (*Node) BroadcastRoutine ¶
func (node *Node) BroadcastRoutine()
BroadcastRoutine receive to broadcast
func (*Node) CompatibleWith ¶
CompatibleWith one node by nodeInfo
func (*Node) DialPeerWithAddress ¶
DialPeerWithAddress ...
func (*Node) FilterConnByAddr ¶
FilterConnByAddr TODO:can make fileter by addr
func (*Node) StartConsensusRoutine ¶
func (node *Node) StartConsensusRoutine()
StartConsensusRoutine if peers reached the threshold start consensus routine
func (*Node) StopPeerForError ¶
StopPeerForError called if error occurred
type NodeInfo ¶
type NodeInfo struct { ID ID `json:"id"` Network string `json:"network"` Version string `json:"version"` IP string `json:"ip,omitempty"` }
NodeInfo struct
type Peer ¶
type Peer interface { ID() ID RemoteIP() (net.IP, error) // remote IP of the connection RemoteAddr() (net.Addr, error) IsOutbound() bool IsPersistent() bool Send(msg MsgInfo) bool TrySend(msg MsgInfo) bool Stop() SetTransferChannel(chan MsgInfo) }
Peer interface
type PeerConnState ¶
type PeerConnState struct { ttypes.PeerRoundState // contains filtered or unexported fields }
PeerConnState struct
func (*PeerConnState) ApplyCommitStepMessage ¶
func (ps *PeerConnState) ApplyCommitStepMessage(msg *tmtypes.CommitStepMsg)
ApplyCommitStepMessage updates the peer state for the new commit.
func (*PeerConnState) ApplyHasVoteMessage ¶
func (ps *PeerConnState) ApplyHasVoteMessage(msg *tmtypes.HasVoteMsg)
ApplyHasVoteMessage updates the peer state for the new vote.
func (*PeerConnState) ApplyNewRoundStepMessage ¶
func (ps *PeerConnState) ApplyNewRoundStepMessage(msg *tmtypes.NewRoundStepMsg)
ApplyNewRoundStepMessage updates the peer state for the new round.
func (*PeerConnState) ApplyProposalPOLMessage ¶
func (ps *PeerConnState) ApplyProposalPOLMessage(msg *tmtypes.ProposalPOLMsg)
ApplyProposalPOLMessage updates the peer state for the new proposal POL.
func (*PeerConnState) ApplyVoteSetBitsMessage ¶
func (ps *PeerConnState) ApplyVoteSetBitsMessage(msg *tmtypes.VoteSetBitsMsg, ourVotes *ttypes.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 (*PeerConnState) EnsureVoteBitArrays ¶
func (ps *PeerConnState) 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 (*PeerConnState) GetHeight ¶
func (ps *PeerConnState) 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 (*PeerConnState) GetRoundState ¶
func (ps *PeerConnState) GetRoundState() *ttypes.PeerRoundState
GetRoundState returns an atomic snapshot of the PeerRoundState. There's no point in mutating it since it won't change PeerState.
func (*PeerConnState) PickVoteToSend ¶
func (ps *PeerConnState) PickVoteToSend(votes ttypes.VoteSetReader) (vote *ttypes.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 (*PeerConnState) SetHasProposal ¶
func (ps *PeerConnState) SetHasProposal(proposal *tmtypes.Proposal)
SetHasProposal sets the given proposal as known for the peer.
func (*PeerConnState) SetHasProposalBlock ¶
func (ps *PeerConnState) SetHasProposalBlock(block *ttypes.TendermintBlock)
SetHasProposalBlock sets the given proposal block as known for the peer.
func (*PeerConnState) SetHasVote ¶
func (ps *PeerConnState) SetHasVote(vote *ttypes.Vote)
SetHasVote sets the given vote as known by the peer
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
PeerSet struct
func (*PeerSet) Add ¶
Add adds the peer to the PeerSet. It returns an error carrying the reason, if the peer is already present.
func (*PeerSet) Has ¶
Has returns true if the set contains the peer referred to by this peerKey, otherwise false.
func (*PeerSet) HasIP ¶
HasIP returns true if the set contains the peer referred to by this IP address, otherwise false.
type SecretConnection ¶
type SecretConnection struct {
// contains filtered or unexported fields
}
SecretConnection Implements net.Conn
func MakeSecretConnection ¶
func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKey) (*SecretConnection, error)
MakeSecretConnection Performs handshake and returns a new authenticated SecretConnection. Returns nil if error in handshake. Caller should call conn.Close() See docs/sts-final.pdf for more information.
func (*SecretConnection) Close ¶
func (sc *SecretConnection) Close() error
Close Implements net.Conn
func (*SecretConnection) Read ¶
func (sc *SecretConnection) Read(data []byte) (n int, err error)
CONTRACT: data smaller than dataMaxSize is read atomically.
func (*SecretConnection) RemoteAddr ¶
func (sc *SecretConnection) RemoteAddr() net.Addr
RemoteAddr ...
func (*SecretConnection) RemotePubKey ¶
func (sc *SecretConnection) RemotePubKey() crypto.PubKey
RemotePubKey Returns authenticated remote pubkey
func (*SecretConnection) SetDeadline ¶
func (sc *SecretConnection) SetDeadline(t time.Time) error
SetDeadline ...
func (*SecretConnection) SetReadDeadline ¶
func (sc *SecretConnection) SetReadDeadline(t time.Time) error
SetReadDeadline ...
func (*SecretConnection) SetWriteDeadline ¶
func (sc *SecretConnection) SetWriteDeadline(t time.Time) error
SetWriteDeadline ...
type StackError ¶
type StackError struct { Err interface{} Stack []byte }
StackError struct
func (StackError) Error ¶
func (se StackError) Error() string
func (StackError) String ¶
func (se StackError) String() string
type State ¶
type State struct { // Immutable ChainID string // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockTotalTx int64 LastBlockID ttypes.BlockID LastBlockTime int64 // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change, // so we can query for historical validator sets. // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 Validators *ttypes.ValidatorSet LastValidators *ttypes.ValidatorSet LastHeightValidatorsChanged int64 // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. ConsensusParams ttypes.ConsensusParams LastHeightConsensusParamsChanged int64 // Merkle root of the results from executing prev block LastResultsHash []byte // The latest AppHash we've received from calling abci.Commit() AppHash []byte }
State is a short description of the latest committed block of the Tendermint consensus. It keeps all information necessary to validate new blocks, including the last validator set and the consensus params. All fields are exposed so the struct can be easily serialized, but none of them should be mutated directly. Instead, use state.Copy() or state.NextState(...). NOTE: not goroutine-safe.
func MakeGenesisState ¶
func MakeGenesisState(genDoc *ttypes.GenesisDoc) (State, error)
MakeGenesisState creates state from ttypes.GenesisDoc.
func MakeGenesisStateFromFile ¶
MakeGenesisStateFromFile reads and unmarshals state from the given file.
Used during replay and in tests.
func (State) GetValidators ¶
func (s State) GetValidators() (last *ttypes.ValidatorSet, current *ttypes.ValidatorSet)
GetValidators returns the last and current validator sets.
func (State) MakeBlock ¶
func (s State) MakeBlock(height int64, round int64, Txs []*types.Transaction, commit *tmtypes.TendermintCommit) *ttypes.TendermintBlock
MakeBlock builds a block with the given txs and commit from the current state.
type TimeoutTicker ¶
type TimeoutTicker interface { Start() Stop() 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() TimeoutTicker
NewTimeoutTicker returns a new TimeoutTicker.