tendermint

package
v1.68.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: BSD-3-Clause Imports: 41 Imported by: 4

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

View Source
const (

	//MaxMsgPacketPayloadSize define
	MaxMsgPacketPayloadSize = 10 * 1024 * 1024
)

Variables

View Source
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

func DefaultDBProvider(name string) dbm.DB

DefaultDBProvider returns a database using the DBBackend and DBDir specified in the ctx.Config.

func LoadProposer

func LoadProposer(source *tmtypes.Validator) (*ttypes.Validator, error)

LoadProposer convert external proposer to internal proposer

func LoadValidators

func LoadValidators(des []*ttypes.Validator, source []*tmtypes.Validator)

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.

func New

func New(cfg *types.Consensus, sub []byte) queue.Module

New ...

func Parallel

func Parallel(tasks ...func())

Parallel method

func SaveState

func SaveState(state State) *tmtypes.State

SaveState convert internal state to external state

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 NewStateDB

func NewStateDB(client *Client, state State) *CSStateDB

NewStateDB make a new one

func (*CSStateDB) LoadState

func (csdb *CSStateDB) LoadState() State

LoadState from state cache

func (*CSStateDB) LoadValidators

func (csdb *CSStateDB) LoadValidators(height int64) (*ttypes.ValidatorSet, error)

LoadValidators by height

func (*CSStateDB) SaveState

func (csdb *CSStateDB) SaveState(state State)

SaveState to state cache

type Client

type Client struct {
	//config
	*drivers.BaseClient
	// contains filtered or unexported fields
}

Client Tendermint implementation

func (*Client) BuildBlock

func (client *Client) BuildBlock() *types.Block

BuildBlock build a new block

func (*Client) CheckBlock

func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail) error

CheckBlock 检查区块

func (*Client) CheckTxDup

func (client *Client) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)

CheckTxDup check transactions that duplicate

func (*Client) CheckTxsAvailable

func (client *Client) CheckTxsAvailable(height int64) bool

CheckTxsAvailable check whether some new transactions arriving

func (*Client) Close

func (client *Client) Close()

Close TODO:may need optimize

func (*Client) CmpBestBlock

func (client *Client) CmpBestBlock(newBlock *types.Block, cmpBlock *types.Block) bool

CmpBestBlock 比较newBlock是不是最优区块

func (*Client) CommitBlock

func (client *Client) CommitBlock(block *types.Block) error

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

func (client *Client) GenesisState() *State

GenesisState returns the Node's GenesisState.

func (*Client) GetGenesisBlockTime

func (client *Client) GetGenesisBlockTime() int64

GetGenesisBlockTime ...

func (*Client) LoadBlockCommit

func (client *Client) LoadBlockCommit(height int64) *tmtypes.TendermintCommit

LoadBlockCommit by height

func (*Client) LoadBlockState

func (client *Client) LoadBlockState(height int64) *tmtypes.State

LoadBlockState by height

func (*Client) LoadProposalBlock

func (client *Client) LoadProposalBlock(height int64) *tmtypes.TendermintBlock

LoadProposalBlock by height

func (*Client) ProcEvent

func (client *Client) ProcEvent(msg *queue.Message) bool

ProcEvent reply not support action err

func (*Client) QueryBlockInfoByHeight

func (client *Client) QueryBlockInfoByHeight(height int64) (*tmtypes.TendermintBlockInfo, *types.Block, error)

QueryBlockInfoByHeight get blockInfo and block by height

func (*Client) QueryValidatorsByHeight

func (client *Client) QueryValidatorsByHeight(height int64) (*tmtypes.ValNodes, error)

QueryValidatorsByHeight ...

func (*Client) Query_IsHealthy

func (client *Client) Query_IsHealthy(req *types.ReqNil) (types.Message, error)

Query_IsHealthy query whether consensus is sync

func (*Client) Query_NodeInfo

func (client *Client) Query_NodeInfo(req *types.ReqNil) (types.Message, error)

Query_NodeInfo query validator node info

func (*Client) SetQueueClient

func (client *Client) SetQueueClient(q queue.Client)

SetQueueClient ...

func (*Client) StartConsensus

func (client *Client) StartConsensus()

StartConsensus a routine that make the consensus start

func (*Client) StopC

func (client *Client) StopC() <-chan struct{}

StopC stop client

func (*Client) TxsAvailable

func (client *Client) TxsAvailable() <-chan int64

TxsAvailable check available channel

func (*Client) WaitBlock

func (client *Client) WaitBlock(height int64) bool

WaitBlock by height

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

func (cs *ConsensusState) IsProposer() bool

IsProposer method

func (*ConsensusState) IsRunning

func (cs *ConsensusState) IsRunning() bool

IsRunning method

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) QueryRoundState added in v1.67.4

func (cs *ConsensusState) QueryRoundState() *ttypes.RoundState

QueryRoundState returns a copy of the internal consensus state.

func (*ConsensusState) SetBroadcastChannel

func (cs *ConsensusState) SetBroadcastChannel(broadcastChannel chan<- MsgInfo)

SetBroadcastChannel method

func (*ConsensusState) SetOurID

func (cs *ConsensusState) SetOurID(id ID)

SetOurID 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) Stop

func (cs *ConsensusState) Stop()

Stop timer and receive routine

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

func GenIDByPubKey(pubkey crypto.PubKey) ID

GenIDByPubKey method

type IP2IPPort

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

IP2IPPort struct

func NewMutexMap

func NewMutexMap() *IP2IPPort

NewMutexMap method

func (*IP2IPPort) Delete

func (ipp *IP2IPPort) Delete(ip string)

Delete method

func (*IP2IPPort) Has

func (ipp *IP2IPPort) Has(ip string) bool

Has method

func (*IP2IPPort) Set

func (ipp *IP2IPPort) Set(ip string, ipport string)

Set method

type MsgInfo

type MsgInfo struct {
	TypeID byte
	Msg    proto.Message
	PeerID ID
	PeerIP string
}

MsgInfo 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) Broadcast

func (node *Node) Broadcast(msg MsgInfo) chan bool

Broadcast to peers in set

func (*Node) BroadcastRoutine

func (node *Node) BroadcastRoutine()

BroadcastRoutine receive to broadcast

func (*Node) CompatibleWith

func (node *Node) CompatibleWith(other NodeInfo) error

CompatibleWith one node by nodeInfo

func (*Node) DialPeerWithAddress

func (node *Node) DialPeerWithAddress(addr string) error

DialPeerWithAddress ...

func (*Node) FilterConnByAddr

func (node *Node) FilterConnByAddr(addr net.Addr) error

FilterConnByAddr TODO:can make fileter by addr

func (*Node) IsRunning

func (node *Node) IsRunning() bool

IsRunning ...

func (*Node) Start

func (node *Node) Start()

Start node

func (*Node) StartConsensusRoutine

func (node *Node) StartConsensusRoutine()

StartConsensusRoutine if peers reached the threshold start consensus routine

func (*Node) Stop

func (node *Node) Stop()

Stop ...

func (*Node) StopPeerForError

func (node *Node) StopPeerForError(peer Peer, reason interface{})

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 NewPeerSet

func NewPeerSet() *PeerSet

NewPeerSet method

func (*PeerSet) Add

func (ps *PeerSet) Add(peer Peer) error

Add adds the peer to the PeerSet. It returns an error carrying the reason, if the peer is already present.

func (*PeerSet) GetIP added in v1.65.2

func (ps *PeerSet) GetIP(peerKey ID) net.IP

func (*PeerSet) Has

func (ps *PeerSet) Has(peerKey ID) bool

Has returns true if the set contains the peer referred to by this peerKey, otherwise false.

func (*PeerSet) HasIP

func (ps *PeerSet) HasIP(peerIP net.IP) bool

HasIP returns true if the set contains the peer referred to by this IP address, otherwise false.

func (*PeerSet) List

func (ps *PeerSet) List() []Peer

List returns the threadsafe list of peers.

func (*PeerSet) Remove

func (ps *PeerSet) Remove(peer Peer)

Remove discards peer by its Key, if the peer was previously memoized.

func (*PeerSet) Size

func (ps *PeerSet) Size() int

Size of list

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

func (sc *SecretConnection) LocalAddr() net.Addr

LocalAddr ...

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 ...

func (*SecretConnection) Write

func (sc *SecretConnection) Write(data []byte) (n int, err error)

Writes encrypted frames of `sealedFrameSize` CONTRACT: data smaller than dataMaxSize is read atomically.

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 LoadState

func LoadState(state *tmtypes.State) State

LoadState convert external state to internal state

func MakeGenesisState

func MakeGenesisState(genDoc *ttypes.GenesisDoc) (State, error)

MakeGenesisState creates state from ttypes.GenesisDoc.

func MakeGenesisStateFromFile

func MakeGenesisStateFromFile(genDocFile string) (State, error)

MakeGenesisStateFromFile reads and unmarshals state from the given file.

Used during replay and in tests.

func (State) Bytes

func (s State) Bytes() []byte

Bytes serializes the State using go-wire.

func (State) Copy

func (s State) Copy() State

Copy makes a copy of the State for mutating.

func (State) Equals

func (s State) Equals(s2 State) bool

Equals returns true if the States are identical.

func (State) GetValidators

func (s State) GetValidators() (last *ttypes.ValidatorSet, current *ttypes.ValidatorSet)

GetValidators returns the last and current validator sets.

func (State) IsEmpty

func (s State) IsEmpty() bool

IsEmpty returns true if the State is equal to the empty State.

func (State) MakeBlock

func (s State) MakeBlock(height int64, round int64, pblock *types.Block, commit *tmtypes.TendermintCommit, proposerAddr []byte) *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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL