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, state *tmtypes.State, block *tmtypes.TendermintBlock) *types.Transaction
- func DefaultDBProvider(name string) dbm.DB
- 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
- 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) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)
- func (client *Client) CheckTxsAvailable(height int64) bool
- func (client *Client) Close()
- func (client *Client) CmpBestBlock(newBlock *types.Block, cmpBlock *types.Block) bool
- func (client *Client) CommitBlock(block *types.Block) error
- func (client *Client) CreateBlock()
- func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
- func (client *Client) GenesisDoc() *ttypes.GenesisDoc
- func (client *Client) GenesisState() *State
- func (client *Client) GetGenesisBlockTime() int64
- func (client *Client) LoadBlockCommit(height int64) *tmtypes.TendermintCommit
- func (client *Client) LoadBlockState(height int64) *tmtypes.State
- func (client *Client) LoadProposalBlock(height int64) *tmtypes.TendermintBlock
- func (client *Client) ProcEvent(msg *queue.Message) bool
- func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.TendermintBlockInfo, *types.Block, error)
- func (client *Client) QueryValidatorsByHeight(height int64) (*tmtypes.ValNodes, error)
- func (client *Client) Query_IsHealthy(req *types.ReqNil) (types.Message, error)
- func (client *Client) Query_NodeInfo(req *types.ReqNil) (types.Message, error)
- func (client *Client) SetQueueClient(q queue.Client)
- func (client *Client) StartConsensus()
- func (client *Client) StopC() <-chan struct{}
- func (client *Client) TxsAvailable() <-chan int64
- func (client *Client) WaitBlock(height int64) bool
- 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) GetPrivValidator() ttypes.PrivValidator
- 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) SetUnicastChannel(unicastChannel chan<- MsgInfo)
- func (cs *ConsensusState) Start()
- func (cs *ConsensusState) Stop()
- func (cs *ConsensusState) WaitForTxs() bool
- type ConsensusStore
- 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{})
- func (node *Node) UnicastRoutine()
- type NodeInfo
- type Peer
- type PeerConnState
- func (ps *PeerConnState) ApplyHasVoteMessage(msg *tmtypes.HasVoteMsg)
- func (ps *PeerConnState) ApplyNewRoundStepMessage(msg *tmtypes.NewRoundStepMsg)
- func (ps *PeerConnState) ApplyProposalPOLMessage(msg *tmtypes.ProposalPOLMsg)
- func (ps *PeerConnState) ApplyValidBlockMessage(msg *tmtypes.ValidBlockMsg)
- 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) SetHasAggVote(aggVote *ttypes.AggVote)
- 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 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, pblock *types.Block, ...) *ttypes.TendermintBlock
- type TimeoutTicker
Constants ¶
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") ErrAddingAggVote = errors.New("Error adding aggregate 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, state *tmtypes.State, 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 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) *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
func (*Client) CheckBlock ¶
CheckBlock 检查区块
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) CmpBestBlock ¶
CmpBestBlock 比较newBlock是不是最优区块
func (*Client) CommitBlock ¶
CommitBlock call WriteBlock to 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) GenesisState ¶
GenesisState returns the Node's GenesisState.
func (*Client) GetGenesisBlockTime ¶
GetGenesisBlockTime ...
func (*Client) LoadBlockCommit ¶
func (client *Client) LoadBlockCommit(height int64) *tmtypes.TendermintCommit
LoadBlockCommit by height
func (*Client) LoadBlockState ¶
LoadBlockState by height
func (*Client) LoadProposalBlock ¶
func (client *Client) LoadProposalBlock(height int64) *tmtypes.TendermintBlock
LoadProposalBlock by height
func (*Client) QueryBlockInfoByHeight ¶
func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.TendermintBlockInfo, *types.Block, error)
QueryBlockInfoByHeight get blockInfo and block by height
func (*Client) QueryValidatorsByHeight ¶
QueryValidatorsByHeight ...
func (*Client) Query_IsHealthy ¶
Query_IsHealthy query whether consensus is sync
func (*Client) Query_NodeInfo ¶
Query_NodeInfo query validator node info
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 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) *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) GetPrivValidator ¶ added in v1.65.1
func (cs *ConsensusState) GetPrivValidator() ttypes.PrivValidator
GetPrivValidator returns the private validator account for signing votes.
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) SetUnicastChannel ¶ added in v1.65.1
func (cs *ConsensusState) SetUnicastChannel(unicastChannel chan<- MsgInfo)
SetUnicastChannel method
func (*ConsensusState) Start ¶
func (cs *ConsensusState) Start()
Start It start first time starts the timeout checkTxsAvailable routine and receive routines.
func (*ConsensusState) WaitForTxs ¶
func (cs *ConsensusState) WaitForTxs() bool
WaitForTxs returns true if the consensus should wait for transactions before entering the propose step
type ConsensusStore ¶
type ConsensusStore struct {
// contains filtered or unexported fields
}
ConsensusStore ...
func NewConsensusStore ¶
func NewConsensusStore() *ConsensusStore
NewConsensusStore returns a new ConsensusStore with the given DB
func (*ConsensusStore) LoadSeenCommit ¶
func (cs *ConsensusStore) LoadSeenCommit(height int64) *tmtypes.TendermintCommit
LoadSeenCommit by height
func (*ConsensusStore) LoadStateFromStore ¶
func (cs *ConsensusStore) LoadStateFromStore() *tmtypes.State
LoadStateFromStore ...
func (*ConsensusStore) LoadStateHeight ¶
func (cs *ConsensusStore) LoadStateHeight() int64
LoadStateHeight ...
func (*ConsensusStore) SaveConsensusState ¶
func (cs *ConsensusStore) SaveConsensusState(height int64, state *tmtypes.State, sc proto.Message) error
SaveConsensusState save state and seenCommit
type ID ¶
type ID string
ID is a hex-encoded crypto.Address
func GenIDByPubKey ¶ added in v1.65.1
GenIDByPubKey method
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) *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
func (*Node) UnicastRoutine ¶ added in v1.65.1
func (node *Node) UnicastRoutine()
UnicastRoutine receive to broadcast
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) 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) ApplyValidBlockMessage ¶
func (ps *PeerConnState) ApplyValidBlockMessage(msg *tmtypes.ValidBlockMsg)
ApplyValidBlockMessage updates the peer state for the new valid block.
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) SetHasAggVote ¶ added in v1.65.2
func (ps *PeerConnState) SetHasAggVote(aggVote *ttypes.AggVote)
SetHasAggVote sets the given aggregate precommit as known for the peer.
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 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.
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.