Documentation ¶
Index ¶
- Constants
- Variables
- func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
- func EventStringBond() string
- func EventStringCompleteProposal() string
- func EventStringDupeout() string
- func EventStringFork() string
- func EventStringLock() string
- func EventStringNewBlock() string
- func EventStringNewBlockHeader() string
- func EventStringNewRound() string
- func EventStringNewRoundStep() string
- func EventStringPolka() string
- func EventStringProposalHeartbeat() string
- func EventStringRebond() string
- func EventStringRelock() string
- func EventStringTimeoutPropose() string
- func EventStringTimeoutWait() string
- func EventStringTx(tx Tx) string
- func EventStringUnbond() string
- func EventStringUnlock() string
- func EventStringVote() string
- func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
- func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)
- func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)
- func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)
- func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)
- func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)
- func FireEventProposalHeartbeat(fireable events.Fireable, rs EventDataProposalHeartbeat)
- func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)
- func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)
- func FireEventTx(fireable events.Fireable, tx EventDataTx)
- func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventVote(fireable events.Fireable, vote EventDataVote)
- func HashSignBytes(chainID string, o Signable) []byte
- func IsVoteTypeValid(type_ byte) bool
- func MakeBlock(height int, chainID string, txs []Tx, commit *Commit, prevBlockID BlockID, ...) (*Block, *PartSet)
- func RandValidator(randPower bool, minPower int64) (*Validator, *PrivValidator)
- func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []*PrivValidator)
- func SignBytes(chainID string, o Signable) []byte
- type Block
- func (b *Block) FillHeader()
- func (b *Block) Hash() data.Bytes
- func (b *Block) HashesTo(hash []byte) bool
- func (b *Block) MakePartSet(partSize int) *PartSet
- func (b *Block) String() string
- func (b *Block) StringIndented(indent string) string
- func (b *Block) StringShort() string
- func (b *Block) ValidateBasic(chainID string, lastBlockHeight int, lastBlockID BlockID, ...) error
- type BlockID
- type BlockMeta
- type BlockStore
- type BlockStoreRPC
- type CanonicalJSONBlockID
- type CanonicalJSONHeartbeat
- type CanonicalJSONOnceHeartbeat
- type CanonicalJSONOnceProposal
- type CanonicalJSONOnceVote
- type CanonicalJSONPartSetHeader
- type CanonicalJSONProposal
- type CanonicalJSONVote
- type Commit
- func (commit *Commit) BitArray() *cmn.BitArray
- func (commit *Commit) FirstPrecommit() *Vote
- func (commit *Commit) GetByIndex(index int) *Vote
- func (commit *Commit) Hash() data.Bytes
- func (commit *Commit) Height() int
- func (commit *Commit) IsCommit() bool
- func (commit *Commit) Round() int
- func (commit *Commit) Size() int
- func (commit *Commit) StringIndented(indent string) string
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- type Data
- type DefaultSigner
- type ErrVoteConflictingVotes
- type EventCache
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataProposalHeartbeat
- type EventDataRoundState
- type EventDataTx
- type EventDataVote
- type EventSwitch
- type Eventable
- type Fireable
- type GenesisDoc
- type GenesisValidator
- type Header
- type Heartbeat
- type Mempool
- type MockMempool
- func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error
- func (m MockMempool) EnableTxsAvailable()
- func (m MockMempool) Flush()
- func (m MockMempool) Lock()
- func (m MockMempool) Reap(n int) Txs
- func (m MockMempool) Size() int
- func (m MockMempool) TxsAvailable() <-chan int
- func (m MockMempool) Unlock()
- func (m MockMempool) Update(height int, txs Txs)
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error)
- func (ps *PartSet) BitArray() *cmn.BitArray
- func (ps *PartSet) Count() int
- func (ps *PartSet) GetPart(index int) *Part
- func (ps *PartSet) GetReader() io.Reader
- func (ps *PartSet) HasHeader(header PartSetHeader) bool
- func (ps *PartSet) Hash() []byte
- func (ps *PartSet) HashesTo(hash []byte) bool
- func (ps *PartSet) Header() PartSetHeader
- func (ps *PartSet) IsComplete() bool
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() int
- type PartSetHeader
- type PartSetReader
- type PrivValidator
- func (privVal *PrivValidator) GetAddress() []byte
- func (privVal *PrivValidator) Reset()
- func (privVal *PrivValidator) Save()
- func (privVal *PrivValidator) SetFile(filePath string)
- func (privVal *PrivValidator) SetSigner(s Signer)
- func (privVal *PrivValidator) SignHeartbeat(chainID string, heartbeat *Heartbeat) error
- func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
- func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
- func (privVal *PrivValidator) String() string
- type PrivValidatorsByAddress
- type Proposal
- type Signable
- type Signer
- type TMEventData
- type TMEventDataInner
- type Tx
- type TxProof
- type TxResult
- type Txs
- type Validator
- type ValidatorSet
- func (valSet *ValidatorSet) Add(val *Validator) (added bool)
- func (valSet *ValidatorSet) Copy() *ValidatorSet
- func (valSet *ValidatorSet) FromBytes(b []byte)
- func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
- func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
- func (valSet *ValidatorSet) GetProposer() (proposer *Validator)
- func (valSet *ValidatorSet) HasAddress(address []byte) bool
- func (valSet *ValidatorSet) Hash() []byte
- func (valSet *ValidatorSet) IncrementAccum(times int)
- func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
- func (valSet *ValidatorSet) Size() int
- func (valSet *ValidatorSet) String() string
- func (valSet *ValidatorSet) StringIndented(indent string) string
- func (valSet *ValidatorSet) ToBytes() []byte
- func (valSet *ValidatorSet) TotalVotingPower() int64
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int, commit *Commit) error
- func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error
- type ValidatorsByAddress
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *BitArray
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address []byte) *Vote
- func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote
- func (voteSet *VoteSet) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() int
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *Commit
- func (voteSet *VoteSet) Round() int
- func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID)
- func (voteSet *VoteSet) Size() int
- func (voteSet *VoteSet) String() string
- func (voteSet *VoteSet) StringIndented(indent string) string
- func (voteSet *VoteSet) StringShort() string
- func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- type VoteSetReader
Constants ¶
const ( MaxBlockSize = 22020096 // 21MB TODO make it configurable DefaultBlockPartSize = 65536 // 64kB TODO: put part size in parts header? )
const ( EventDataTypeNewBlock = byte(0x01) EventDataTypeFork = byte(0x02) EventDataTypeTx = byte(0x03) EventDataTypeNewBlockHeader = byte(0x04) EventDataTypeRoundState = byte(0x11) EventDataTypeVote = byte(0x12) EventDataTypeProposalHeartbeat = byte(0x20) )
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
Variables ¶
var ( EventDataNameNewBlock = "new_block" EventDataNameNewBlockHeader = "new_block_header" EventDataNameTx = "tx" EventDataNameRoundState = "round_state" EventDataNameVote = "vote" EventDataNameProposalHeartbeat = "proposer_heartbeat" )
var ( PeerStateKey = "ConsensusReactor.peerState" PeerMempoolChKey = "MempoolReactor.peerMempoolCh" )
var ( ErrPartSetUnexpectedIndex = errors.New("Error part set unexpected index") ErrPartSetInvalidProof = errors.New("Error part set invalid proof") )
var ( ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature") ErrInvalidBlockPartHash = errors.New("Error invalid block part hash") )
var ( ErrVoteUnexpectedStep = errors.New("Unexpected step") ErrVoteInvalidValidatorIndex = errors.New("Invalid round vote validator index") ErrVoteInvalidValidatorAddress = errors.New("Invalid round vote validator address") ErrVoteInvalidSignature = errors.New("Invalid round vote signature") ErrVoteInvalidBlockHash = errors.New("Invalid block hash") )
var GenDocKey = []byte("GenDocKey")
var TM2PB = tm2pb{}
Convert tendermint types to protobuf types
var ValidatorCodec = validatorCodec{}
Functions ¶
func AddListenerForEvent ¶ added in v0.9.2
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
func EventStringCompleteProposal ¶
func EventStringCompleteProposal() string
func EventStringDupeout ¶
func EventStringDupeout() string
func EventStringFork ¶
func EventStringFork() string
func EventStringLock ¶
func EventStringLock() string
func EventStringNewBlock ¶
func EventStringNewBlock() string
func EventStringNewBlockHeader ¶
func EventStringNewBlockHeader() string
func EventStringNewRound ¶
func EventStringNewRound() string
func EventStringNewRoundStep ¶
func EventStringNewRoundStep() string
func EventStringPolka ¶
func EventStringPolka() string
func EventStringProposalHeartbeat ¶
func EventStringProposalHeartbeat() string
func EventStringRebond ¶
func EventStringRebond() string
func EventStringRelock ¶
func EventStringRelock() string
func EventStringTimeoutPropose ¶
func EventStringTimeoutPropose() string
func EventStringTimeoutWait ¶
func EventStringTimeoutWait() string
func EventStringTx ¶
func EventStringUnbond ¶
func EventStringUnbond() string
func EventStringUnlock ¶
func EventStringUnlock() string
func EventStringVote ¶
func EventStringVote() string
func FireEventCompleteProposal ¶ added in v0.9.2
func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
func FireEventLock ¶ added in v0.9.2
func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
func FireEventNewBlock ¶ added in v0.9.2
func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)
func FireEventNewBlockHeader ¶ added in v0.9.2
func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)
func FireEventNewRound ¶ added in v0.9.2
func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)
func FireEventNewRoundStep ¶ added in v0.9.2
func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)
func FireEventPolka ¶ added in v0.9.2
func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)
func FireEventProposalHeartbeat ¶
func FireEventProposalHeartbeat(fireable events.Fireable, rs EventDataProposalHeartbeat)
func FireEventRelock ¶ added in v0.9.2
func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)
func FireEventTimeoutPropose ¶ added in v0.9.2
func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)
func FireEventTimeoutWait ¶ added in v0.9.2
func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)
func FireEventTx ¶ added in v0.9.2
func FireEventTx(fireable events.Fireable, tx EventDataTx)
func FireEventUnlock ¶ added in v0.9.2
func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)
func FireEventVote ¶ added in v0.9.2
func FireEventVote(fireable events.Fireable, vote EventDataVote)
func HashSignBytes ¶
HashSignBytes is a convenience method for getting the hash of the bytes of a signable
func IsVoteTypeValid ¶ added in v0.9.2
func MakeBlock ¶ added in v0.9.2
func MakeBlock(height int, chainID string, txs []Tx, commit *Commit, prevBlockID BlockID, valHash, appHash []byte, partSize int) (*Block, *PartSet)
MakeBlock returns a new block and corresponding part set from the given information TODO: version
func RandValidator ¶
func RandValidator(randPower bool, minPower int64) (*Validator, *PrivValidator)
func RandValidatorSet ¶
func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []*PrivValidator)
NOTE: PrivValidator are in order.
Types ¶
type Block ¶
type Block struct { *Header `json:"header"` *Data `json:"data"` LastCommit *Commit `json:"last_commit"` }
Block defines the atomic unit of a Tendermint blockchain
func (*Block) FillHeader ¶
func (b *Block) FillHeader()
FillHeader fills in any remaining header fields that are a function of the block data
func (*Block) Hash ¶
Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*Block) HashesTo ¶
HashesTo is a convenience function that checks if a block hashes to the given argument. A nil block never hashes to anything, and nothing hashes to a nil hash.
func (*Block) MakePartSet ¶
MakePartSet returns a PartSet containing parts of a serialized block. This is the form in which the block is gossipped to peers.
func (*Block) StringIndented ¶
StringIndented returns a string representation of the block
func (*Block) StringShort ¶
StringShort returns a shortened string representation of the block
type BlockID ¶ added in v0.9.2
type BlockID struct { Hash data.Bytes `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
func (BlockID) Equals ¶ added in v0.9.2
Equals returns true if the BlockID matches the given BlockID
func (BlockID) Key ¶ added in v0.9.2
Key returns a machine-readable string representation of the BlockID
type BlockMeta ¶
type BlockMeta struct { BlockID BlockID `json:"block_id"` // the block hash and partsethash Header *Header `json:"header"` // The block's Header }
func NewBlockMeta ¶
type BlockStore ¶ added in v0.9.2
type BlockStore interface { BlockStoreRPC SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit) }
type BlockStoreRPC ¶ added in v0.9.2
type CanonicalJSONBlockID ¶ added in v0.9.2
type CanonicalJSONBlockID struct { Hash data.Bytes `json:"hash,omitempty"` PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"` }
func CanonicalBlockID ¶ added in v0.9.2
func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID
type CanonicalJSONHeartbeat ¶ added in v0.15.0
type CanonicalJSONHeartbeat struct { Height int `json:"height"` Round int `json:"round"` Sequence int `json:"sequence"` ValidatorAddress data.Bytes `json:"validator_address"` ValidatorIndex int `json:"validator_index"` }
func CanonicalHeartbeat ¶ added in v0.15.0
func CanonicalHeartbeat(heartbeat *Heartbeat) CanonicalJSONHeartbeat
type CanonicalJSONOnceHeartbeat ¶ added in v0.15.0
type CanonicalJSONOnceHeartbeat struct { ChainID string `json:"chain_id"` Heartbeat CanonicalJSONHeartbeat `json:"heartbeat"` }
type CanonicalJSONOnceProposal ¶ added in v0.9.2
type CanonicalJSONOnceProposal struct { ChainID string `json:"chain_id"` Proposal CanonicalJSONProposal `json:"proposal"` }
type CanonicalJSONOnceVote ¶ added in v0.9.2
type CanonicalJSONOnceVote struct { ChainID string `json:"chain_id"` Vote CanonicalJSONVote `json:"vote"` }
type CanonicalJSONPartSetHeader ¶ added in v0.9.2
func CanonicalPartSetHeader ¶ added in v0.9.2
func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader
type CanonicalJSONProposal ¶ added in v0.9.2
type CanonicalJSONProposal struct { BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"` Height int `json:"height"` POLBlockID CanonicalJSONBlockID `json:"pol_block_id"` POLRound int `json:"pol_round"` Round int `json:"round"` }
func CanonicalProposal ¶ added in v0.9.2
func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal
type CanonicalJSONVote ¶ added in v0.9.2
type CanonicalJSONVote struct { BlockID CanonicalJSONBlockID `json:"block_id"` Height int `json:"height"` Round int `json:"round"` Type byte `json:"type"` }
func CanonicalVote ¶ added in v0.9.2
func CanonicalVote(vote *Vote) CanonicalJSONVote
type Commit ¶
type Commit struct { // NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order. // Any peer with a block can gossip precommits by index with a peer without recalculating the // active ValidatorSet. BlockID BlockID `json:"blockID"` Precommits []*Vote `json:"precommits"` // contains filtered or unexported fields }
Commit contains the evidence that a block was committed by a set of validators. NOTE: Commit is empty for height 1, but never nil.
func (*Commit) FirstPrecommit ¶
FirstPrecommit returns the first non-nil precommit in the commit
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data.
type Data ¶
type Data struct { // Txs that will be applied by state @ block.Height+1. // NOTE: not all txs here are valid. We're just agreeing on the order first. // This means that block.AppHash does not include these txs. Txs Txs `json:"txs"` // contains filtered or unexported fields }
Data contains the set of transactions included in the block
func (*Data) StringIndented ¶
StringIndented returns a string representation of the transactions
type DefaultSigner ¶
type DefaultSigner struct {
// contains filtered or unexported fields
}
Implements Signer
func NewDefaultSigner ¶
func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner
type ErrVoteConflictingVotes ¶ added in v0.9.2
func (*ErrVoteConflictingVotes) Error ¶ added in v0.9.2
func (err *ErrVoteConflictingVotes) Error() string
type EventCache ¶ added in v0.9.2
type EventCache interface { Fireable Flush() }
func NewEventCache ¶ added in v0.9.2
func NewEventCache(evsw EventSwitch) EventCache
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *Block `json:"block"`
}
func (EventDataNewBlock) AssertIsTMEventData ¶
func (_ EventDataNewBlock) AssertIsTMEventData()
type EventDataNewBlockHeader ¶
type EventDataNewBlockHeader struct {
Header *Header `json:"header"`
}
light weight event for benchmarking
func (EventDataNewBlockHeader) AssertIsTMEventData ¶
func (_ EventDataNewBlockHeader) AssertIsTMEventData()
type EventDataProposalHeartbeat ¶ added in v0.15.0
type EventDataProposalHeartbeat struct {
Heartbeat *Heartbeat
}
func (EventDataProposalHeartbeat) AssertIsTMEventData ¶ added in v0.19.7
func (_ EventDataProposalHeartbeat) AssertIsTMEventData()
type EventDataRoundState ¶
type EventDataRoundState struct { Height int `json:"height"` Round int `json:"round"` Step string `json:"step"` // private, not exposed to websockets RoundState interface{} `json:"-"` }
NOTE: This goes into the replay WAL
func (EventDataRoundState) AssertIsTMEventData ¶
func (_ EventDataRoundState) AssertIsTMEventData()
type EventDataTx ¶
type EventDataTx struct { Height int `json:"height"` Tx Tx `json:"tx"` Data data.Bytes `json:"data"` Log string `json:"log"` Code abci.CodeType `json:"code"` Error string `json:"error"` // this is redundant information for now }
All txs fire EventDataTx
func (EventDataTx) AssertIsTMEventData ¶
func (_ EventDataTx) AssertIsTMEventData()
type EventDataVote ¶
type EventDataVote struct {
Vote *Vote
}
func (EventDataVote) AssertIsTMEventData ¶
func (_ EventDataVote) AssertIsTMEventData()
type EventSwitch ¶ added in v0.9.2
type EventSwitch interface { events.EventSwitch }
func NewEventSwitch ¶ added in v0.9.2
func NewEventSwitch() EventSwitch
type Eventable ¶ added in v0.9.2
type Eventable interface {
SetEventSwitch(EventSwitch)
}
type GenesisDoc ¶
type GenesisDoc struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` Validators []GenesisValidator `json:"validators"` AppHash data.Bytes `json:"app_hash"` }
GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
func GenesisDocFromFile ¶ added in v0.15.0
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error)
GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)
GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
SaveAs is a utility method for saving GenensisDoc as a JSON file.
func (*GenesisDoc) ValidatorHash ¶ added in v0.15.0
func (genDoc *GenesisDoc) ValidatorHash() []byte
ValidatorHash returns the hash of the validator set contained in the GenesisDoc
type GenesisValidator ¶
type GenesisValidator struct { PubKey crypto.PubKey `json:"pub_key"` Amount int64 `json:"amount"` Name string `json:"name"` }
GenesisValidator is an initial validator.
type Header ¶
type Header struct { ChainID string `json:"chain_id"` Height int `json:"height"` Time time.Time `json:"time"` NumTxs int `json:"num_txs"` // XXX: Can we get rid of this? LastBlockID BlockID `json:"last_block_id"` LastCommitHash data.Bytes `json:"last_commit_hash"` // commit from validators from the last block DataHash data.Bytes `json:"data_hash"` // transactions ValidatorsHash data.Bytes `json:"validators_hash"` // validators for the current block AppHash data.Bytes `json:"app_hash"` // state after txs from the previous block }
Header defines the structure of a Tendermint block header
func (*Header) Hash ¶
Hash returns the hash of the header. NOTE: hash is nil if required fields are missing.
func (*Header) StringIndented ¶
StringIndented returns a string representation of the header
type Heartbeat ¶ added in v0.15.0
type Mempool ¶ added in v0.9.2
type Mempool interface { Lock() Unlock() Size() int CheckTx(Tx, func(*abci.Response)) error Reap(int) Txs Update(height int, txs Txs) Flush() TxsAvailable() <-chan int EnableTxsAvailable() }
Updates to the mempool need to be synchronized with committing a block so apps can reset their transient state on Commit
type MockMempool ¶ added in v0.9.2
type MockMempool struct { }
func (MockMempool) CheckTx ¶ added in v0.9.2
func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error
func (MockMempool) EnableTxsAvailable ¶ added in v0.15.0
func (m MockMempool) EnableTxsAvailable()
func (MockMempool) Flush ¶ added in v0.9.2
func (m MockMempool) Flush()
func (MockMempool) Lock ¶ added in v0.9.2
func (m MockMempool) Lock()
func (MockMempool) Reap ¶ added in v0.9.2
func (m MockMempool) Reap(n int) Txs
func (MockMempool) Size ¶ added in v0.9.2
func (m MockMempool) Size() int
func (MockMempool) TxsAvailable ¶ added in v0.15.0
func (m MockMempool) TxsAvailable() <-chan int
func (MockMempool) Unlock ¶ added in v0.9.2
func (m MockMempool) Unlock()
func (MockMempool) Update ¶ added in v0.9.2
func (m MockMempool) Update(height int, txs Txs)
type Part ¶
type Part struct { Index int `json:"index"` Bytes data.Bytes `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` // contains filtered or unexported fields }
func (*Part) StringIndented ¶
type PartSet ¶
type PartSet struct {
// contains filtered or unexported fields
}
func NewPartSetFromData ¶
Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
Returns an empty PartSet ready to be populated.
func (*PartSet) HasHeader ¶
func (ps *PartSet) HasHeader(header PartSetHeader) bool
func (*PartSet) Header ¶
func (ps *PartSet) Header() PartSetHeader
func (*PartSet) IsComplete ¶
func (*PartSet) StringShort ¶
type PartSetHeader ¶
func (PartSetHeader) Equals ¶
func (psh PartSetHeader) Equals(other PartSetHeader) bool
func (PartSetHeader) IsZero ¶
func (psh PartSetHeader) IsZero() bool
func (PartSetHeader) String ¶
func (psh PartSetHeader) String() string
func (PartSetHeader) WriteSignBytes ¶
func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int, err *error)
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type PrivValidator ¶
type PrivValidator struct { Address data.Bytes `json:"address"` PubKey crypto.PubKey `json:"pub_key"` LastHeight int `json:"last_height"` LastRound int `json:"last_round"` LastStep int8 `json:"last_step"` LastSignature crypto.Signature `json:"last_signature,omitempty"` // so we dont lose signatures LastSignBytes data.Bytes `json:"last_signbytes,omitempty"` // so we dont lose signatures // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.PrivKey `json:"priv_key"` Signer `json:"-"` // contains filtered or unexported fields }
func GenPrivValidator ¶
func GenPrivValidator() *PrivValidator
Generates a new validator with private key.
func LoadOrGenPrivValidator ¶
func LoadOrGenPrivValidator(filePath string, logger log.Logger) *PrivValidator
func LoadPrivValidator ¶
func LoadPrivValidator(filePath string) *PrivValidator
func (*PrivValidator) GetAddress ¶ added in v0.9.2
func (privVal *PrivValidator) GetAddress() []byte
func (*PrivValidator) Save ¶
func (privVal *PrivValidator) Save()
func (*PrivValidator) SetFile ¶
func (privVal *PrivValidator) SetFile(filePath string)
func (*PrivValidator) SetSigner ¶
func (privVal *PrivValidator) SetSigner(s Signer)
func (*PrivValidator) SignHeartbeat ¶ added in v0.15.0
func (privVal *PrivValidator) SignHeartbeat(chainID string, heartbeat *Heartbeat) error
func (*PrivValidator) SignProposal ¶
func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
func (*PrivValidator) SignVote ¶
func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
func (*PrivValidator) String ¶
func (privVal *PrivValidator) String() string
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []*PrivValidator
func (PrivValidatorsByAddress) Len ¶
func (pvs PrivValidatorsByAddress) Len() int
func (PrivValidatorsByAddress) Less ¶
func (pvs PrivValidatorsByAddress) Less(i, j int) bool
func (PrivValidatorsByAddress) Swap ¶
func (pvs PrivValidatorsByAddress) Swap(i, j int)
type Proposal ¶
type Proposal struct { Height int `json:"height"` Round int `json:"round"` BlockPartsHeader PartSetHeader `json:"block_parts_header"` POLRound int `json:"pol_round"` // -1 if null. POLBlockID BlockID `json:"pol_block_id"` // zero if null. Signature crypto.Signature `json:"signature"` }
func NewProposal ¶
func NewProposal(height int, round int, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID) *Proposal
polRound: -1 if no polRound.
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type Signer ¶
This is used to sign votes. It is the caller's duty to verify the msg before calling Sign, eg. to avoid double signing. Currently, the only callers are SignVote and SignProposal
type TMEventData ¶
type TMEventData struct {
TMEventDataInner `json:"unwrap"`
}
func (TMEventData) Empty ¶ added in v0.15.0
func (tmr TMEventData) Empty() bool
func (TMEventData) MarshalJSON ¶ added in v0.15.0
func (tmr TMEventData) MarshalJSON() ([]byte, error)
func (*TMEventData) UnmarshalJSON ¶ added in v0.15.0
func (tmr *TMEventData) UnmarshalJSON(data []byte) (err error)
func (TMEventData) Unwrap ¶ added in v0.15.0
func (tmr TMEventData) Unwrap() TMEventDataInner
type TMEventDataInner ¶ added in v0.15.0
implements events.EventData
type Tx ¶
type Tx []byte
type TxResult ¶ added in v0.9.2
type TxResult struct { Height uint64 `json:"height"` Index uint32 `json:"index"` Tx Tx `json:"tx"` Result abci.ResponseDeliverTx `json:"result"` }
TxResult contains results of executing the transaction.
One usage is indexing transaction results.
type Txs ¶
type Txs []Tx
func (Txs) Index ¶ added in v0.9.2
Index returns the index of this transaction in the list, or -1 if not found
func (Txs) IndexByHash ¶ added in v0.9.2
Index returns the index of this transaction hash in the list, or -1 if not found
type Validator ¶
type Validator struct { Address data.Bytes `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` }
Volatile state for each Validator NOTE: The Accum is not included in Validator.Hash(); make sure to update that method if changes are made here
func NewValidator ¶ added in v0.9.2
func (*Validator) CompareAccum ¶
Returns the one with higher Accum.
func (*Validator) Copy ¶
Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.
type ValidatorSet ¶
type ValidatorSet struct { // NOTE: persisted via reflect, must be exported. Validators []*Validator `json:"validators"` Proposer *Validator `json:"proposer"` // contains filtered or unexported fields }
ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety. TODO: consider validator Accum overflow
func NewValidatorSet ¶
func NewValidatorSet(vals []*Validator) *ValidatorSet
func (*ValidatorSet) Add ¶
func (valSet *ValidatorSet) Add(val *Validator) (added bool)
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
func (*ValidatorSet) FromBytes ¶ added in v0.9.2
func (valSet *ValidatorSet) FromBytes(b []byte)
func (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
func (*ValidatorSet) GetProposer ¶ added in v0.9.2
func (valSet *ValidatorSet) GetProposer() (proposer *Validator)
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address []byte) bool
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times int)
incrementAccum and update the proposer TODO: mind the overflow when times and votingPower shares too large.
func (*ValidatorSet) Iterate ¶
func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() int
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
func (*ValidatorSet) ToBytes ¶ added in v0.9.2
func (valSet *ValidatorSet) ToBytes() []byte
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes
func (*ValidatorSet) VerifyCommitAny ¶ added in v0.9.2
func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error
Verify that +2/3 of this set had signed the given signBytes. Unlike VerifyCommit(), this function can verify commits with differeent sets.
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
func (ValidatorsByAddress) Len ¶
func (vs ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (vs ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (vs ValidatorsByAddress) Swap(i, j int)
type Vote ¶
type Vote struct { ValidatorAddress data.Bytes `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int `json:"height"` Round int `json:"round"` Type byte `json:"type"` BlockID BlockID `json:"block_id"` // zero if vote is nil. Signature crypto.Signature `json:"signature"` }
Represents a prevote, precommit, or commit vote from validators for consensus.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet helps collect signatures from validators at each height+round for a predefined vote type.
We need VoteSet to be able to keep track of conflicting votes when validators double-sign. Yet, we can't keep track of *all* the votes seen, as that could be a DoS attack vector.
There are two storage areas for votes. 1. voteSet.votes 2. voteSet.votesByBlock
`.votes` is the "canonical" list of votes. It always has at least one vote, if a vote from a validator had been seen at all. Usually it keeps track of the first vote seen, but when a 2/3 majority is found, votes for that get priority and are copied over from `.votesByBlock`.
`.votesByBlock` keeps track of a list of votes for a particular block. There are two ways a &blockVotes{} gets created in `.votesByBlock`. 1. the first vote seen by a validator was for the particular block. 2. a peer claims to have seen 2/3 majority for the particular block.
Since the first vote from a validator will always get added in `.votesByBlock` , all votes in `.votes` will have a corresponding entry in `.votesByBlock`.
When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its votes are copied into `.votes`.
All this is memory bounded because conflicting votes only get added if a peer told us to track that block, each peer only gets to tell us 1 such block, and, there's only a limited number of peers.
NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func NewVoteSet ¶
Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddVote ¶ added in v0.9.2
Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[
UnexpectedStep | InvalidIndex | InvalidAddress | InvalidSignature | InvalidBlockHash | ConflictingVotes ]
Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil
func (*VoteSet) BitArrayByBlockID ¶ added in v0.9.2
func (*VoteSet) GetByAddress ¶
func (*VoteSet) GetByIndex ¶
NOTE: if validator has conflicting votes, returns "canonical" vote
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeCommit ¶
func (*VoteSet) SetPeerMaj23 ¶ added in v0.9.2
If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil
func (*VoteSet) StringIndented ¶
func (*VoteSet) StringShort ¶
func (*VoteSet) TwoThirdsMajority ¶
Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).