Documentation ¶
Overview ¶
Package qbftNode 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(priv crypto.PrivKey, state *tmtypes.QbftState, block *tmtypes.QbftBlock) *types.Transaction
- func DefaultDBProvider(name string) dbm.DB
- func DetachExec() bool
- func LoadProposer(source *tmtypes.QbftValidator) (*ttypes.Validator, error)
- func LoadValidators(des []*ttypes.Validator, source []*tmtypes.QbftValidator)
- 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.QbftState
- func UseAggSig() bool
- type BlockExecutor
- type CSStateDB
- type Client
- func (client *Client) BuildBlock(height int64) *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)
- func (client *Client) CreateBlock()
- func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
- func (client *Client) GenesisState() *State
- func (client *Client) GetGenesisBlockTime() int64
- func (client *Client) LoadBlockCommit(height int64) *tmtypes.QbftCommit
- func (client *Client) LoadBlockState(height int64) *tmtypes.QbftState
- func (client *Client) LoadProposalBlock(height int64) *tmtypes.QbftBlock
- func (client *Client) ProcEvent(msg *queue.Message) bool
- func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.QbftBlockInfo, *types.Block, error)
- func (client *Client) QueryValidatorsByHeight(height int64) (*tmtypes.QbftNodes, error)
- func (client *Client) Query_CurrentState(req *types.ReqNil) (types.Message, 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) TxsAvailable() <-chan int64
- func (client *Client) WaitBlock(height int64) *types.Block
- type ConsensusState
- func (cs *ConsensusState) Commit(t time.Time) time.Time
- func (cs *ConsensusState) EmptyBlockInterval() time.Duration
- func (cs *ConsensusState) GetPrecommitsState(height int64, round int, blockID *tmtypes.QbftBlockID) *ttypes.BitArray
- func (cs *ConsensusState) GetPrevotesState(height int64, round int, blockID *tmtypes.QbftBlockID) *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) IsRunning() bool
- func (cs *ConsensusState) LoadCommit(height int64) *tmtypes.QbftCommit
- 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) QueryRoundState() *ttypes.RoundState
- func (cs *ConsensusState) QueryState() *State
- 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, ...)
- 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()
- 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.QbftHasVoteMsg)
- func (ps *PeerConnState) ApplyNewRoundStepMessage(msg *tmtypes.QbftNewRoundStepMsg)
- func (ps *PeerConnState) ApplyProposalPOLMessage(msg *tmtypes.QbftProposalPOLMsg)
- func (ps *PeerConnState) ApplyValidBlockMessage(msg *tmtypes.QbftValidBlockMsg)
- func (ps *PeerConnState) ApplyVoteSetBitsMessage(msg *tmtypes.QbftVoteSetBitsMsg, 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) PickAggVoteToSend(votes ttypes.VoteSetReader) (vote *ttypes.AggVote, ok bool)
- 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.QbftProposal)
- func (ps *PeerConnState) SetHasProposalBlock(block *ttypes.QbftBlock)
- 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, commit *tmtypes.QbftCommit, ...) *ttypes.QbftBlock
- func (s State) String() string
- func (s State) StringIndented(indent string) string
- type TimeoutTicker
Constants ¶
const (
// DefaultQbftPort 默认端口
DefaultQbftPort = 33001
)
const (
//MaxMsgPacketPayloadSize define
MaxMsgPacketPayloadSize = 2 * 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(priv crypto.PrivKey, state *tmtypes.QbftState, block *tmtypes.QbftBlock) *types.Transaction
CreateBlockInfoTx make blockInfo to the first transaction of the block and execer is qbftNode
func DefaultDBProvider ¶
DefaultDBProvider returns a database
func DetachExec ¶ added in v1.66.0
func DetachExec() bool
DetachExec returns whether detach Execution from Consensus
func LoadProposer ¶
func LoadProposer(source *tmtypes.QbftValidator) (*ttypes.Validator, error)
LoadProposer convert external proposer to internal proposer
func LoadValidators ¶
func LoadValidators(des []*ttypes.Validator, source []*tmtypes.QbftValidator)
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.QbftBlock) (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.QbftBlock) 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
type Client ¶
type Client struct { //config *drivers.BaseClient // contains filtered or unexported fields }
Client qbft 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 trigger consensus forward when tx available
func (*Client) CreateGenesisTx ¶
func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
CreateGenesisTx ...
func (*Client) GenesisState ¶
GenesisState returns the Node's GenesisState.
func (*Client) GetGenesisBlockTime ¶
GetGenesisBlockTime ...
func (*Client) LoadBlockCommit ¶
func (client *Client) LoadBlockCommit(height int64) *tmtypes.QbftCommit
LoadBlockCommit by height
func (*Client) LoadBlockState ¶
LoadBlockState by height
func (*Client) LoadProposalBlock ¶
LoadProposalBlock by height
func (*Client) QueryBlockInfoByHeight ¶
func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.QbftBlockInfo, *types.Block, error)
QueryBlockInfoByHeight get blockInfo and block by height
func (*Client) QueryValidatorsByHeight ¶
QueryValidatorsByHeight ...
func (*Client) Query_CurrentState ¶
Query_CurrentState query current consensus state
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) EmptyBlockInterval ¶
func (cs *ConsensusState) EmptyBlockInterval() time.Duration
EmptyBlockInterval 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.QbftBlockID) *ttypes.BitArray
GetPrecommitsState method
func (*ConsensusState) GetPrevotesState ¶
func (cs *ConsensusState) GetPrevotesState(height int64, round int, blockID *tmtypes.QbftBlockID) *ttypes.BitArray
GetPrevotesState method
func (*ConsensusState) GetPrivValidator ¶
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.QbftCommit
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) QueryRoundState ¶
func (cs *ConsensusState) QueryRoundState() *ttypes.RoundState
QueryRoundState returns a copy of the internal consensus state.
func (*ConsensusState) QueryState ¶
func (cs *ConsensusState) QueryState() *State
QueryState returns a copy of the chain state.
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.QbftBlockID)
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 ¶
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.
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.QbftCommit
LoadSeenCommit by height
func (*ConsensusStore) LoadStateFromStore ¶
func (cs *ConsensusStore) LoadStateFromStore() *tmtypes.QbftState
LoadStateFromStore ...
func (*ConsensusStore) LoadStateHeight ¶
func (cs *ConsensusStore) LoadStateHeight() int64
LoadStateHeight ...
func (*ConsensusStore) SaveConsensusState ¶
func (cs *ConsensusStore) SaveConsensusState(height int64, state *tmtypes.QbftState, sc proto.Message) error
SaveConsensusState save state and seenCommit
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 ¶
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.QbftHasVoteMsg)
ApplyHasVoteMessage updates the peer state for the new vote.
func (*PeerConnState) ApplyNewRoundStepMessage ¶
func (ps *PeerConnState) ApplyNewRoundStepMessage(msg *tmtypes.QbftNewRoundStepMsg)
ApplyNewRoundStepMessage updates the peer state for the new round.
func (*PeerConnState) ApplyProposalPOLMessage ¶
func (ps *PeerConnState) ApplyProposalPOLMessage(msg *tmtypes.QbftProposalPOLMsg)
ApplyProposalPOLMessage updates the peer state for the new proposal POL.
func (*PeerConnState) ApplyValidBlockMessage ¶
func (ps *PeerConnState) ApplyValidBlockMessage(msg *tmtypes.QbftValidBlockMsg)
ApplyValidBlockMessage updates the peer state for the new valid block.
func (*PeerConnState) ApplyVoteSetBitsMessage ¶
func (ps *PeerConnState) ApplyVoteSetBitsMessage(msg *tmtypes.QbftVoteSetBitsMsg, 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) PickAggVoteToSend ¶
func (ps *PeerConnState) PickAggVoteToSend(votes ttypes.VoteSetReader) (vote *ttypes.AggVote, ok bool)
PickAggVoteToSend picks aggregate vote to send to the peer. Returns true if a vote was picked.
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 ¶
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.QbftProposal)
SetHasProposal sets the given proposal as known for the peer.
func (*PeerConnState) SetHasProposalBlock ¶
func (ps *PeerConnState) SetHasProposalBlock(block *ttypes.QbftBlock)
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 Sequence int64 LastSequence int64 LastCommitRound int64 }
QbftState is a short description of the latest committed block of the Qbft 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, pblock *types.Block, commit *tmtypes.QbftCommit, proposerAddr []byte) *ttypes.QbftBlock
MakeBlock builds a block with the given txs and commit from the current state.
func (State) StringIndented ¶
StringIndented returns a string
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.