tendermint

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 39 Imported by: 0

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 DebugCatchup = false

DebugCatchup define whether catch up now

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

func DefaultDBProvider(ID string) (dbm.DB, error)

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

func EvidenceToInfoBytes

func EvidenceToInfoBytes(evidence ttypes.Evidence, priority int64) ([]byte, error)

EvidenceToInfoBytes method

func GenAddressByPubKey

func GenAddressByPubKey(pubkey crypto.PubKey) []byte

GenAddressByPubKey method

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

func VerifyEvidence

func VerifyEvidence(stateDB *CSStateDB, s State, evidence ttypes.Evidence) error

VerifyEvidence verifies the evidence fully by checking it is internally consistent and sufficiently recent.

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 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 contains some transactions

func (*Client) CheckBlock

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

CheckBlock 暂不检查任何的交易

func (*Client) CheckCommit

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

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

func (client *Client) CheckTxsAvailable() bool

CheckTxsAvailable check whether some new transactions arriving

func (*Client) Close

func (client *Client) Close()

Close TODO:may need optimize

func (*Client) CommitBlock

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

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

func (client *Client) GetGenesisBlockTime() int64

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

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

ProcEvent ...

func (*Client) QueryBlockInfoByHeight

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

QueryBlockInfoByHeight ...

func (*Client) QueryValidatorsByHeight

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

QueryValidatorsByHeight ...

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

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

func NewEvidenceStore(db dbm.DB) *EvidenceStore

NewEvidenceStore method

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 ID

type ID string

ID is a hex-encoded crypto.Address

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, evpool *EvidencePool) *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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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