Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalTime(t time.Time) string
- func CopyFile(src, dst string) (err error)
- func EventQueryTxFor(tx Tx) tmpubsub.Query
- func FillUpWithContractCode(conf *cfg.Config, appStateJSON json.RawMessage) (json.RawMessage, error)
- func IsVoteTypeValid(type_ byte) bool
- func QueryForEvent(eventType string) tmpubsub.Query
- func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)
- func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)
- func RegisterEventDatas(cdc *amino.Codec)
- func RegisterEvidences(cdc *amino.Codec)
- func ValidatorsFromFile(genDoc GenesisDoc, validatorsFile string) *[]GenesisValidator
- type ABCIResult
- type ABCIResults
- type AccountInfo
- type Allocation
- type Block
- func (b *Block) AddEvidence(evidence []Evidence)
- func (b *Block) Hash() cmn.HexBytes
- 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() error
- type BlockEventPublisher
- type BlockGossip
- type BlockID
- type BlockMeta
- type BlockSize
- type BlockStore
- type BlockStoreRPC
- type CanonicalJSONBlockID
- type CanonicalJSONHeartbeat
- 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() cmn.HexBytes
- func (commit *Commit) Height() int64
- 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 ConsensusParams
- type Data
- type DuplicateVoteEvidence
- func (dve *DuplicateVoteEvidence) Address() string
- func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
- func (dve *DuplicateVoteEvidence) Hash() []byte
- func (dve *DuplicateVoteEvidence) Height() int64
- func (dve *DuplicateVoteEvidence) Index() int
- func (dve *DuplicateVoteEvidence) String() string
- func (dve *DuplicateVoteEvidence) Verify(chainID string) error
- type ErrEvidenceInvalid
- type ErrVoteConflictingVotes
- type EventBus
- func (b *EventBus) OnStart() error
- func (b *EventBus) OnStop()
- func (b *EventBus) Publish(eventType string, eventData TMEventData) error
- func (b *EventBus) PublishEventCompleteProposal(event EventDataRoundState) error
- func (b *EventBus) PublishEventLock(event EventDataRoundState) error
- func (b *EventBus) PublishEventNewBlock(event EventDataNewBlock) error
- func (b *EventBus) PublishEventNewBlockHeader(event EventDataNewBlockHeader) error
- func (b *EventBus) PublishEventNewRound(event EventDataRoundState) error
- func (b *EventBus) PublishEventNewRoundStep(event EventDataRoundState) error
- func (b *EventBus) PublishEventPolka(event EventDataRoundState) error
- func (b *EventBus) PublishEventProposalHeartbeat(event EventDataProposalHeartbeat) error
- func (b *EventBus) PublishEventRelock(event EventDataRoundState) error
- func (b *EventBus) PublishEventTimeoutPropose(event EventDataRoundState) error
- func (b *EventBus) PublishEventTimeoutWait(event EventDataRoundState) error
- func (b *EventBus) PublishEventTx(event EventDataTx) error
- func (b *EventBus) PublishEventUnlock(event EventDataRoundState) error
- func (b *EventBus) PublishEventVote(event EventDataVote) error
- func (b *EventBus) SetLogger(l log.Logger)
- func (b *EventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, ...) error
- func (b *EventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
- func (b *EventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
- type EventBusSubscriber
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataProposalHeartbeat
- type EventDataRoundState
- type EventDataString
- type EventDataTx
- type EventDataVote
- type Evidence
- type EvidenceData
- type EvidenceList
- type EvidenceParams
- type EvidencePool
- type GenesisDoc
- type GenesisValidator
- type HashList
- type Header
- type Heartbeat
- type Mempool
- type MockBadEvidence
- type MockEvidencePool
- type MockGoodEvidence
- func (e MockGoodEvidence) Address() string
- func (e MockGoodEvidence) Equal(ev Evidence) bool
- func (e MockGoodEvidence) Hash() []byte
- func (e MockGoodEvidence) Height() int64
- func (e MockGoodEvidence) Index() int
- func (e MockGoodEvidence) String() string
- func (e MockGoodEvidence) Verify(chainID string) error
- type MockMempool
- func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error
- func (m MockMempool) EnableTxsAvailable()
- func (m MockMempool) Flush()
- func (m MockMempool) FlushAppConn() error
- func (m MockMempool) GiTxCache(tx cmn.HexBytes, a interface{})
- func (m MockMempool) GiTxSearch(tx string) (*abci.ResponseCheckTx, error)
- func (m MockMempool) Lock()
- func (m MockMempool) Reap(n int) Txs
- func (m MockMempool) Size() int
- func (m MockMempool) TxsAvailable() <-chan int64
- func (m MockMempool) Unlock()
- func (m MockMempool) Update(height int64, txs Txs) error
- type MockPV
- func (pv *MockPV) DisableChecks()
- func (pv *MockPV) GetAddress() crypto.Address
- func (pv *MockPV) GetPubKey() crypto.PubKey
- func (pv *MockPV) SignHeartbeat(chainID string, heartbeat *Heartbeat) error
- func (pv *MockPV) SignProposal(chainID string, proposal *Proposal) error
- func (pv *MockPV) SignVote(chainID string, vote *Vote) error
- func (pv *MockPV) String() string
- type NopEventBus
- func (NopEventBus) PublishEventCompleteProposal(rs EventDataRoundState) error
- func (NopEventBus) PublishEventLock(rs EventDataRoundState) error
- func (NopEventBus) PublishEventNewBlock(block EventDataNewBlock) error
- func (NopEventBus) PublishEventNewBlockHeader(header EventDataNewBlockHeader) error
- func (NopEventBus) PublishEventNewRound(rs EventDataRoundState) error
- func (NopEventBus) PublishEventNewRoundStep(rs EventDataRoundState) error
- func (NopEventBus) PublishEventPolka(rs EventDataRoundState) error
- func (NopEventBus) PublishEventRelock(rs EventDataRoundState) error
- func (NopEventBus) PublishEventTimeoutPropose(rs EventDataRoundState) error
- func (NopEventBus) PublishEventTimeoutWait(rs EventDataRoundState) error
- func (NopEventBus) PublishEventTx(tx EventDataTx) error
- func (NopEventBus) PublishEventUnlock(rs EventDataRoundState) error
- func (NopEventBus) PublishEventVote(vote EventDataVote) error
- func (NopEventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, ...) error
- func (NopEventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
- func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
- type P2PID
- 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) MarshalJSON() ([]byte, error)
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() int
- type PartSetHeader
- type PartSetReader
- type PrivValidator
- type PrivValidatorsByAddress
- type Proposal
- type Relayer
- type SideChainOrg
- type Signable
- type SignedHeader
- type TMEventData
- type TooManyProposalEvidence
- func (tmpe *TooManyProposalEvidence) Address() string
- func (tmpe *TooManyProposalEvidence) Equal(ev Evidence) bool
- func (tmpe *TooManyProposalEvidence) Hash() []byte
- func (tmpe *TooManyProposalEvidence) Height() int64
- func (tmpe *TooManyProposalEvidence) Index() int
- func (tmpe *TooManyProposalEvidence) String() string
- func (tmpe *TooManyProposalEvidence) Verify(chainID string) error
- type Tx
- type TxEventBuffer
- type TxEventPublisher
- type TxProof
- type TxResult
- type TxSize
- type Txs
- type Validator
- type ValidatorSet
- func (valSet *ValidatorSet) Add(val *Validator) (added bool)
- func (valSet *ValidatorSet) Copy() *ValidatorSet
- func (valSet *ValidatorSet) GetByAddress(address string) (index int, val *Validator)
- func (valSet *ValidatorSet) GetByIndex(index int) (address string, val *Validator)
- func (valSet *ValidatorSet) GetProposer(invalidProposer *[]crypto.Address, cb func(v *Validator)) (proposer *Validator)
- func (valSet *ValidatorSet) HasAddress(address string) 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 string) (val *Validator, removed bool)
- func (valSet *ValidatorSet) Size() int
- func (valSet *ValidatorSet) String() string
- func (valSet *ValidatorSet) StringIndented(indent string) string
- func (valSet *ValidatorSet) TotalVotingPower() int64
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
- func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string, blockID BlockID, height int64, ...) error
- type ValidatorsByAddress
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *cmn.BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *cmn.BitArray
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address string) *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() int64
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *Commit
- func (voteSet *VoteSet) MarshalJSON() ([]byte, error)
- func (voteSet *VoteSet) Round() int
- func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error
- 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 ( EventBond = "Bond" EventCompleteProposal = "CompleteProposal" EventDupeout = "Dupeout" EventFork = "Fork" EventLock = "Lock" EventNewBlock = "NewBlock" EventNewBlockHeader = "NewBlockHeader" EventNewRound = "NewRound" EventNewRoundStep = "NewRoundStep" EventPolka = "Polka" EventRebond = "Rebond" EventRelock = "Relock" EventTimeoutPropose = "TimeoutPropose" EventTimeoutWait = "TimeoutWait" EventTx = "Tx" EventUnbond = "Unbond" EventUnlock = "Unlock" EventVote = "Vote" EventProposalHeartbeat = "ProposalHeartbeat" )
Reserved event types
const ( // EventTypeKey is a reserved key, used to specify event type in tags. EventTypeKey = "tm.event" // TxHashKey is a reserved key, used to specify transaction's hash. // see EventBus#PublishEventTx TxHashKey = "tx.hash" // TxHeightKey is a reserved key, used to specify transaction block's height. // see EventBus#PublishEventTx TxHeightKey = "tx.height" )
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
const BlockVersion = "2.2.0"
const (
MaxBlockSizeBytes = 104857600 // 100MB
)
const TimeFormat = amino.RFC3339Millis
TimeFormat is used for generating the sigs
Variables ¶
var ( EventQueryBond = QueryForEvent(EventBond) EventQueryUnbond = QueryForEvent(EventUnbond) EventQueryRebond = QueryForEvent(EventRebond) EventQueryDupeout = QueryForEvent(EventDupeout) EventQueryFork = QueryForEvent(EventFork) EventQueryNewBlock = QueryForEvent(EventNewBlock) EventQueryNewBlockHeader = QueryForEvent(EventNewBlockHeader) EventQueryNewRound = QueryForEvent(EventNewRound) EventQueryNewRoundStep = QueryForEvent(EventNewRoundStep) EventQueryTimeoutPropose = QueryForEvent(EventTimeoutPropose) EventQueryCompleteProposal = QueryForEvent(EventCompleteProposal) EventQueryPolka = QueryForEvent(EventPolka) EventQueryUnlock = QueryForEvent(EventUnlock) EventQueryLock = QueryForEvent(EventLock) EventQueryRelock = QueryForEvent(EventRelock) EventQueryTimeoutWait = QueryForEvent(EventTimeoutWait) EventQueryVote = QueryForEvent(EventVote) EventQueryProposalHeartbeat = QueryForEvent(EventProposalHeartbeat) EventQueryTx = QueryForEvent(EventTx) )
var ( PeerStateKey = "ConsensusReactor.peerState" PeerMempoolChKey = "MempoolReactor.peerMempoolCh" )
UNSTABLE
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 validator index") ErrVoteInvalidValidatorAddress = errors.New("Invalid validator address") ErrVoteInvalidSignature = errors.New("Invalid signature") ErrVoteInvalidBlockHash = errors.New("Invalid block hash") ErrVoteNonDeterministicSignature = errors.New("Non-deterministic signature") ErrVoteNil = errors.New("Nil vote") )
var TM2PB = tm2pb{}
TM2PB is used for converting Tendermint types to protobuf types. UNSTABLE
Functions ¶
func CanonicalTime ¶
func CopyFile ¶
CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.
func EventQueryTxFor ¶
func FillUpWithContractCode ¶
func FillUpWithContractCode(conf *cfg.Config, appStateJSON json.RawMessage) (json.RawMessage, error)
FillUpWithContractCode -
func IsVoteTypeValid ¶
func QueryForEvent ¶
func RandValidator ¶
func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)
RandValidator returns a randomized validator, useful for testing. UNSTABLE
func RandValidatorSet ¶
func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)
RandValidatorSet returns a randomized validator set, useful for testing. NOTE: PrivValidator are in order. UNSTABLE
func RegisterEventDatas ¶
func RegisterEventDatas(cdc *amino.Codec)
func RegisterEvidences ¶
func RegisterEvidences(cdc *amino.Codec)
func ValidatorsFromFile ¶
func ValidatorsFromFile(genDoc GenesisDoc, validatorsFile string) *[]GenesisValidator
Types ¶
type ABCIResult ¶
ABCIResult is the deterministic component of a ResponseDeliverTx. TODO: add Tags
func NewResultFromResponse ¶
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult
func (ABCIResult) Hash ¶
func (a ABCIResult) Hash() []byte
Hash returns the canonical hash of the ABCIResult
type ABCIResults ¶
type ABCIResults []ABCIResult
ABCIResults wraps the deliver tx results to return a proof
func NewResults ¶
func NewResults(del []*abci.ResponseDeliverTx) ABCIResults
NewResults creates ABCIResults from ResponseDeliverTx
func (ABCIResults) Bytes ¶
func (a ABCIResults) Bytes() []byte
Bytes serializes the ABCIResponse using wire
func (ABCIResults) Hash ¶
func (a ABCIResults) Hash() []byte
Hash returns a merkle hash of all results
func (ABCIResults) ProveResult ¶
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof
ProveResult returns a merkle proof of one result from the set
type AccountInfo ¶
type Allocation ¶
type Allocation []types.Allocation
func (*Allocation) StringIndented ¶
func (as *Allocation) StringIndented(indent string) string
type Block ¶
type Block struct { *Header `json:"header"` *Data `json:"data"` Evidence EvidenceData `json:"evidence"` LastCommit *Commit `json:"last_commit"` // contains filtered or unexported fields }
Block defines the atomic unit of a Tendermint blockchain. TODO: add Version byte
func GIMakeBlock ¶
func GIMakeBlock(height int64, txs []Tx, commit *Commit, txHashList [][]byte, proposer string, lastFee uint64, rewardAddr string, lastAllocation []types.Allocation, chainVersion int64, lastMining *int64) *Block
将上一次交易hashlist存入到下一个block的data中
func MakeBlock ¶
MakeBlock returns a new block with an empty header, except what can be computed from itself. It populates the same set of fields validated by ValidateBasic
func (*Block) AddEvidence ¶
AddEvidence appends the given evidence to the block
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
func (*Block) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. It checks the internal consistency of the block.
type BlockEventPublisher ¶
type BlockEventPublisher interface { PublishEventNewBlock(block EventDataNewBlock) error PublishEventNewBlockHeader(header EventDataNewBlockHeader) error PublishEventTx(EventDataTx) error }
BlockEventPublisher publishes all block related events
type BlockGossip ¶
type BlockGossip struct {
BlockPartSizeBytes int `json:"block_part_size_bytes"` // NOTE: must not be 0
}
BlockGossip determine consensus critical elements of how blocks are gossiped
func DefaultBlockGossip ¶
func DefaultBlockGossip() BlockGossip
DefaultBlockGossip returns a default BlockGossip.
type BlockID ¶
type BlockID struct { Hash cmn.HexBytes `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
type BlockMeta ¶
type BlockMeta struct { BlockID BlockID `json:"block_id"` // the block hash and partsethash Header *Header `json:"header"` // The block's Header }
BlockMeta contains meta information about a block - namely, it's ID and Header.
func NewBlockMeta ¶
NewBlockMeta returns a new BlockMeta from the block and its blockParts.
type BlockSize ¶
type BlockSize struct { MaxBytes int `json:"max_bytes"` // NOTE: must not be 0 nor greater than 100MB MaxTxs int `json:"max_txs"` MaxGas int64 `json:"max_gas"` }
BlockSize contain limits on the block size.
func DefaultBlockSize ¶
func DefaultBlockSize() BlockSize
DefaultBlockSize returns a default BlockSize.
type BlockStore ¶
type BlockStore interface { BlockStoreRPC SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit) }
BlockStore defines the BlockStore interface used by the ConsensusState. UNSTABLE
type BlockStoreRPC ¶
type BlockStoreRPC interface { Height() int64 LoadBlockMeta(height int64) *BlockMeta LoadBlock(height int64) *Block LoadBlockPart(height int64, index int) *Part LoadBlockCommit(height int64) *Commit LoadSeenCommit(height int64) *Commit }
BlockStoreRPC is the block store interface used by the RPC. UNSTABLE
type CanonicalJSONBlockID ¶
type CanonicalJSONBlockID struct { Hash cmn.HexBytes `json:"hash,omitempty"` PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"` }
func CanonicalBlockID ¶
func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID
type CanonicalJSONHeartbeat ¶
type CanonicalJSONHeartbeat struct { ChainID string `json:"@chain_id"` Type string `json:"@type"` Height int64 `json:"height"` Round int `json:"round"` Sequence int `json:"sequence"` ValidatorAddress crypto.Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` }
func CanonicalHeartbeat ¶
func CanonicalHeartbeat(chainID string, heartbeat *Heartbeat) CanonicalJSONHeartbeat
type CanonicalJSONPartSetHeader ¶
type CanonicalJSONPartSetHeader struct { Hash cmn.HexBytes `json:"hash,omitempty"` Total int `json:"total,omitempty"` }
func CanonicalPartSetHeader ¶
func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader
type CanonicalJSONProposal ¶
type CanonicalJSONProposal struct { ChainID string `json:"@chain_id"` Type string `json:"@type"` BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"` Height int64 `json:"height"` POLBlockID CanonicalJSONBlockID `json:"pol_block_id"` POLRound int `json:"pol_round"` Round int `json:"round"` Timestamp string `json:"timestamp"` }
func CanonicalProposal ¶
func CanonicalProposal(chainID string, proposal *Proposal) CanonicalJSONProposal
type CanonicalJSONVote ¶
type CanonicalJSONVote struct { ChainID string `json:"@chain_id"` Type string `json:"@type"` BlockID CanonicalJSONBlockID `json:"block_id"` Height int64 `json:"height"` Round int `json:"round"` Timestamp string `json:"timestamp"` VoteType byte `json:"type"` }
func CanonicalVote ¶
func CanonicalVote(chainID string, 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:"block_id"` 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 MakeCommit ¶
func (*Commit) FirstPrecommit ¶
FirstPrecommit returns the first non-nil precommit in the commit. If all precommits are nil, it returns an empty precommit with height 0.
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 ConsensusParams ¶
type ConsensusParams struct { BlockSize `json:"block_size_params"` TxSize `json:"tx_size_params"` BlockGossip `json:"block_gossip_params"` EvidenceParams `json:"evidence_params"` }
ConsensusParams contains consensus critical parameters that determine the validity of blocks.
func DefaultConsensusParams ¶
func DefaultConsensusParams() *ConsensusParams
DefaultConsensusParams returns a default ConsensusParams.
func (*ConsensusParams) Hash ¶
func (params *ConsensusParams) Hash() []byte
Hash returns a merkle hash of the parameters to store in the block header
func (ConsensusParams) Update ¶
func (params ConsensusParams) Update(params2 *abci.ConsensusParams) ConsensusParams
Update returns a copy of the params with updates from the non-zero fields of p2. NOTE: note: must not modify the original
func (*ConsensusParams) Validate ¶
func (params *ConsensusParams) Validate() error
Validate validates the ConsensusParams to ensure all values are within their allowed limits, and returns an error if they are not.
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"` //txs hash list for all txs in last block LastTxsHashList HashList `json:"lastTxsHashList"` // 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 DuplicateVoteEvidence ¶
DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.
func (*DuplicateVoteEvidence) Address ¶
func (dve *DuplicateVoteEvidence) Address() string
Address returns the address of the validator.
func (*DuplicateVoteEvidence) Equal ¶
func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
Equal checks if two pieces of evidence are equal.
func (*DuplicateVoteEvidence) Hash ¶
func (dve *DuplicateVoteEvidence) Hash() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) Height ¶
func (dve *DuplicateVoteEvidence) Height() int64
Height returns the height this evidence refers to.
func (*DuplicateVoteEvidence) Index ¶
func (dve *DuplicateVoteEvidence) Index() int
Index returns the index of the validator.
func (*DuplicateVoteEvidence) String ¶
func (dve *DuplicateVoteEvidence) String() string
String returns a string representation of the evidence.
func (*DuplicateVoteEvidence) Verify ¶
func (dve *DuplicateVoteEvidence) Verify(chainID string) error
Verify returns an error if the two votes aren't conflicting. To be conflicting, they must be from the same validator, for the same H/R/S, but for different blocks.
type ErrEvidenceInvalid ¶
ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.
func NewEvidenceInvalidErr ¶
func NewEvidenceInvalidErr(ev Evidence, err error) *ErrEvidenceInvalid
func (*ErrEvidenceInvalid) Error ¶
func (err *ErrEvidenceInvalid) Error() string
Error returns a string representation of the error.
type ErrVoteConflictingVotes ¶
type ErrVoteConflictingVotes struct {
*DuplicateVoteEvidence
}
func NewConflictingVoteError ¶
func NewConflictingVoteError(val *Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type EventBus ¶
type EventBus struct { cmn.BaseService // contains filtered or unexported fields }
EventBus is a common bus for all events going through the system. All calls are proxied to underlying pubsub server. All events must be published using EventBus to ensure correct data types.
func NewEventBusWithBufferCapacity ¶
NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.
func (*EventBus) Publish ¶
func (b *EventBus) Publish(eventType string, eventData TMEventData) error
func (*EventBus) PublishEventCompleteProposal ¶
func (b *EventBus) PublishEventCompleteProposal(event EventDataRoundState) error
func (*EventBus) PublishEventLock ¶
func (b *EventBus) PublishEventLock(event EventDataRoundState) error
func (*EventBus) PublishEventNewBlock ¶
func (b *EventBus) PublishEventNewBlock(event EventDataNewBlock) error
func (*EventBus) PublishEventNewBlockHeader ¶
func (b *EventBus) PublishEventNewBlockHeader(event EventDataNewBlockHeader) error
func (*EventBus) PublishEventNewRound ¶
func (b *EventBus) PublishEventNewRound(event EventDataRoundState) error
func (*EventBus) PublishEventNewRoundStep ¶
func (b *EventBus) PublishEventNewRoundStep(event EventDataRoundState) error
func (*EventBus) PublishEventPolka ¶
func (b *EventBus) PublishEventPolka(event EventDataRoundState) error
func (*EventBus) PublishEventProposalHeartbeat ¶
func (b *EventBus) PublishEventProposalHeartbeat(event EventDataProposalHeartbeat) error
func (*EventBus) PublishEventRelock ¶
func (b *EventBus) PublishEventRelock(event EventDataRoundState) error
func (*EventBus) PublishEventTimeoutPropose ¶
func (b *EventBus) PublishEventTimeoutPropose(event EventDataRoundState) error
func (*EventBus) PublishEventTimeoutWait ¶
func (b *EventBus) PublishEventTimeoutWait(event EventDataRoundState) error
func (*EventBus) PublishEventTx ¶
func (b *EventBus) PublishEventTx(event EventDataTx) error
PublishEventTx publishes tx event with tags from Result. Note it will add predefined tags (EventTypeKey, TxHashKey). Existing tags with the same names will be overwritten.
func (*EventBus) PublishEventUnlock ¶
func (b *EventBus) PublishEventUnlock(event EventDataRoundState) error
func (*EventBus) PublishEventVote ¶
func (b *EventBus) PublishEventVote(event EventDataVote) error
func (*EventBus) Unsubscribe ¶
type EventBusSubscriber ¶
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 ¶
type EventDataProposalHeartbeat struct {
Heartbeat *Heartbeat
}
func (EventDataProposalHeartbeat) AssertIsTMEventData ¶
func (_ EventDataProposalHeartbeat) AssertIsTMEventData()
type EventDataRoundState ¶
type EventDataRoundState struct { Height int64 `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 EventDataString ¶
type EventDataString string
func (EventDataString) AssertIsTMEventData ¶
func (_ EventDataString) AssertIsTMEventData()
type EventDataTx ¶
type EventDataTx struct {
TxResult
}
All txs fire EventDataTx
func (EventDataTx) AssertIsTMEventData ¶
func (_ EventDataTx) AssertIsTMEventData()
type EventDataVote ¶
type EventDataVote struct {
Vote *Vote
}
func (EventDataVote) AssertIsTMEventData ¶
func (_ EventDataVote) AssertIsTMEventData()
type Evidence ¶
type Evidence interface { Height() int64 // height of the equivocation Address() string // address of the equivocating validator Index() int // index of the validator in the validator set Hash() []byte // hash of the evidence Verify(chainID string) error // verify the evidence Equal(Evidence) bool // check equality of evidence String() string }
Evidence represents any provable malicious activity by a validator
type EvidenceData ¶
type EvidenceData struct { Evidence EvidenceList `json:"evidence"` // contains filtered or unexported fields }
EvidenceData contains any evidence of malicious wrong-doing by validators
func (*EvidenceData) Hash ¶
func (data *EvidenceData) Hash() cmn.HexBytes
Hash returns the hash of the data.
func (*EvidenceData) StringIndented ¶
func (data *EvidenceData) StringIndented(indent string) string
StringIndented returns a string representation of the evidence.
type EvidenceList ¶
type EvidenceList []Evidence
EvidenceList is a list of Evidence. Evidences is not a word.
func (EvidenceList) Has ¶
func (evl EvidenceList) Has(evidence Evidence) bool
Has returns true if the evidence is in the EvidenceList.
func (EvidenceList) Hash ¶
func (evl EvidenceList) Hash() []byte
Hash returns the simple merkle root hash of the EvidenceList.
func (EvidenceList) String ¶
func (evl EvidenceList) String() string
type EvidenceParams ¶
type EvidenceParams struct {
MaxAge int64 `json:"max_age"` // only accept new evidence more recent than this
}
EvidenceParams determine how we handle evidence of malfeasance
func DefaultEvidenceParams ¶
func DefaultEvidenceParams() EvidenceParams
DefaultEvidence Params returns a default EvidenceParams.
type EvidencePool ¶
type EvidencePool interface { PendingEvidence() []Evidence AddEvidence(Evidence) error Update(*Block) }
EvidencePool defines the EvidencePool interface used by the ConsensusState. UNSTABLE
type GenesisDoc ¶
type GenesisDoc struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` ChainVersion string `json:"chain_version"` ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators"` AppHash cmn.HexBytes `json:"app_hash"` AppStateJSON json.RawMessage `json:"app_state,omitempty"` }
GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
func GenesisDocFromFile ¶
func GenesisDocFromFile(config *cfg.Config) (*GenesisDoc, error)
GenesisDocFromFile reads JSON data from a file and unmarshals it into a GenesisDoc.
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)
GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.
func (*GenesisDoc) AppState ¶
func (genDoc *GenesisDoc) AppState() json.RawMessage
AppState returns raw application state. TODO: replace with AppState field during next breaking release (0.18)
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
SaveAs is a utility method for saving GenesisDoc as a JSON file.
func (*GenesisDoc) ValidateAndComplete ¶
func (genDoc *GenesisDoc) ValidateAndComplete() error
ValidateAndComplete checks that all necessary fields are present and fills in defaults for optional fields left empty
func (*GenesisDoc) ValidatorHash ¶
func (genDoc *GenesisDoc) ValidatorHash() []byte
ValidatorHash returns the hash of the validator set contained in the GenesisDoc
type GenesisValidator ¶
type GenesisValidator struct { RewardAddr string `json:"reward_addr"` PubKey crypto.PubKey `json:"pub_key,omitempty"` // No Key In Genesis File,so omit empty Power int64 `json:"power"` Name string `json:"name"` }
GenesisValidator is an initial validator.
type Header ¶
type Header struct { // basic block info ChainID string `json:"chain_id"` Height int64 `json:"height"` Time time.Time `json:"time"` NumTxs int64 `json:"num_txs"` // prev block info LastBlockID BlockID `json:"last_block_id"` TotalTxs int64 `json:"total_txs"` // hashes of block data LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block DataHash cmn.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block LastAppHash cmn.HexBytes `json:"last_app_hash"` // state after txs from the previous block LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block // consensus info EvidenceHash cmn.HexBytes `json:"evidence_hash"` // evidence included in the block // Proposer Address LastFee uint64 `json:"last_fee"` LastAllocation Allocation `json:"last_allocation"` ProposerAddress string `json:"proposer_address"` RewardAddress string `json:"reward_address"` // added 06 August 2018 RandomOfBlock cmn.HexBytes `json:"random_of_block,omitempty"` LastMining *int64 `json:"last_mining,omitempty"` // added 24 May 2019 // version of proposer's tendermint - added 14 Dec. 2018 Version *string `json:"version,omitempty"` // added 26 Mar. 2019 ChainVersion *int64 `json:"chain_version,omitempty"` // added 17 Sep. 2019 LastQueueChains *ibc.QueueChain `json:"last_queue_chains,omitempty"` // added 12 Oct. 2019 Relayer *Relayer `json:"relayer,omitempty"` // version of block BlockVersion *string `json:"block_version,omitempty"` // todo 这个字段有问题 并且sdk和中继要加这个字段 区块版本常量?? }
Header defines the structure of a Tendermint block header TODO: limit header size NOTE: changes to the Header should be duplicated in the abci Header
func (*Header) Hash ¶
Hash returns the hash of the header. Returns nil if ValidatorHash is missing, since a Header is not valid unless there is a ValidatorsHash (corresponding to the validator set).
func (*Header) StringIndented ¶
StringIndented returns a string representation of the header
type Heartbeat ¶
type Heartbeat struct { ValidatorAddress crypto.Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int `json:"round"` Sequence int `json:"sequence"` Signature crypto.Signature `json:"signature"` }
Heartbeat is a simple vote-like structure so validators can alert others that they are alive and waiting for transactions. Note: We aren't adding ",omitempty" to Heartbeat's json field tags because we always want the JSON representation to be in its canonical form.
type Mempool ¶
type Mempool interface { Lock() Unlock() Size() int CheckTx(Tx, func(*abci.Response)) error Reap(int) Txs Update(height int64, txs Txs) error Flush() FlushAppConn() error TxsAvailable() <-chan int64 EnableTxsAvailable() GiTxSearch(string) (*abci.ResponseCheckTx, error) GiTxCache(cmn.HexBytes, interface{}) }
Mempool defines the mempool interface as used by the ConsensusState. Updates to the mempool need to be synchronized with committing a block so apps can reset their transient state on Commit UNSTABLE
type MockBadEvidence ¶
type MockBadEvidence struct {
MockGoodEvidence
}
UNSTABLE
func (MockBadEvidence) Equal ¶
func (e MockBadEvidence) Equal(ev Evidence) bool
func (MockBadEvidence) String ¶
func (e MockBadEvidence) String() string
func (MockBadEvidence) Verify ¶
func (e MockBadEvidence) Verify(chainID string) error
type MockEvidencePool ¶
type MockEvidencePool struct { }
MockMempool is an empty implementation of a Mempool, useful for testing. UNSTABLE
func (MockEvidencePool) AddEvidence ¶
func (m MockEvidencePool) AddEvidence(Evidence) error
func (MockEvidencePool) PendingEvidence ¶
func (m MockEvidencePool) PendingEvidence() []Evidence
func (MockEvidencePool) Update ¶
func (m MockEvidencePool) Update(*Block)
type MockGoodEvidence ¶
UNSTABLE
func NewMockGoodEvidence ¶
func NewMockGoodEvidence(height int64, index int, address string) MockGoodEvidence
UNSTABLE
func (MockGoodEvidence) Address ¶
func (e MockGoodEvidence) Address() string
func (MockGoodEvidence) Equal ¶
func (e MockGoodEvidence) Equal(ev Evidence) bool
func (MockGoodEvidence) Hash ¶
func (e MockGoodEvidence) Hash() []byte
func (MockGoodEvidence) Height ¶
func (e MockGoodEvidence) Height() int64
func (MockGoodEvidence) Index ¶
func (e MockGoodEvidence) Index() int
func (MockGoodEvidence) String ¶
func (e MockGoodEvidence) String() string
func (MockGoodEvidence) Verify ¶
func (e MockGoodEvidence) Verify(chainID string) error
type MockMempool ¶
type MockMempool struct { }
MockMempool is an empty implementation of a Mempool, useful for testing. UNSTABLE
func (MockMempool) EnableTxsAvailable ¶
func (m MockMempool) EnableTxsAvailable()
func (MockMempool) Flush ¶
func (m MockMempool) Flush()
func (MockMempool) FlushAppConn ¶
func (m MockMempool) FlushAppConn() error
func (MockMempool) GiTxCache ¶
func (m MockMempool) GiTxCache(tx cmn.HexBytes, a interface{})
func (MockMempool) GiTxSearch ¶
func (m MockMempool) GiTxSearch(tx string) (*abci.ResponseCheckTx, error)
func (MockMempool) Lock ¶
func (m MockMempool) Lock()
func (MockMempool) Reap ¶
func (m MockMempool) Reap(n int) Txs
func (MockMempool) Size ¶
func (m MockMempool) Size() int
func (MockMempool) TxsAvailable ¶
func (m MockMempool) TxsAvailable() <-chan int64
func (MockMempool) Unlock ¶
func (m MockMempool) Unlock()
type MockPV ¶
type MockPV struct {
// contains filtered or unexported fields
}
MockPV implements PrivValidator without any safety or persistence. Only use it for testing.
func (*MockPV) SignHeartbeat ¶
signHeartbeat signs the heartbeat without any checking.
func (*MockPV) SignProposal ¶
Implements PrivValidator.
type NopEventBus ¶
type NopEventBus struct{}
func (NopEventBus) PublishEventCompleteProposal ¶
func (NopEventBus) PublishEventCompleteProposal(rs EventDataRoundState) error
func (NopEventBus) PublishEventLock ¶
func (NopEventBus) PublishEventLock(rs EventDataRoundState) error
func (NopEventBus) PublishEventNewBlock ¶
func (NopEventBus) PublishEventNewBlock(block EventDataNewBlock) error
func (NopEventBus) PublishEventNewBlockHeader ¶
func (NopEventBus) PublishEventNewBlockHeader(header EventDataNewBlockHeader) error
func (NopEventBus) PublishEventNewRound ¶
func (NopEventBus) PublishEventNewRound(rs EventDataRoundState) error
func (NopEventBus) PublishEventNewRoundStep ¶
func (NopEventBus) PublishEventNewRoundStep(rs EventDataRoundState) error
func (NopEventBus) PublishEventPolka ¶
func (NopEventBus) PublishEventPolka(rs EventDataRoundState) error
func (NopEventBus) PublishEventRelock ¶
func (NopEventBus) PublishEventRelock(rs EventDataRoundState) error
func (NopEventBus) PublishEventTimeoutPropose ¶
func (NopEventBus) PublishEventTimeoutPropose(rs EventDataRoundState) error
func (NopEventBus) PublishEventTimeoutWait ¶
func (NopEventBus) PublishEventTimeoutWait(rs EventDataRoundState) error
func (NopEventBus) PublishEventTx ¶
func (NopEventBus) PublishEventTx(tx EventDataTx) error
func (NopEventBus) PublishEventUnlock ¶
func (NopEventBus) PublishEventUnlock(rs EventDataRoundState) error
func (NopEventBus) PublishEventVote ¶
func (NopEventBus) PublishEventVote(vote EventDataVote) error
func (NopEventBus) Unsubscribe ¶
func (NopEventBus) UnsubscribeAll ¶
func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
type P2PID ¶
type P2PID string
UNSTABLE XXX: duplicate of p2p.ID to avoid dependence between packages. Perhaps we can have a minimal types package containing this (and other things?) that both `types` and `p2p` import ?
type Part ¶
type Part struct { Index int `json:"index"` Bytes cmn.HexBytes `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) MarshalJSON ¶
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
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type PrivValidator ¶
type PrivValidator interface { GetAddress() crypto.Address // redundant since .PubKey().Address() GetPubKey() crypto.PubKey SignVote(chainID string, vote *Vote) error SignProposal(chainID string, proposal *Proposal) error SignHeartbeat(chainID string, heartbeat *Heartbeat) error }
PrivValidator defines the functionality of a local Tendermint validator that signs votes, proposals, and heartbeats, and never double signs.
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 int64 `json:"height"` Round int `json:"round"` Timestamp time.Time `json:"timestamp"` 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"` }
Proposal defines a block proposal for the consensus. It refers to the block only by its PartSetHeader. It must be signed by the correct proposer for the given Height/Round to be considered valid. It may depend on votes from a previous round, a so-called Proof-of-Lock (POL) round, as noted in the POLRound and POLBlockID.
func NewProposal ¶
func NewProposal(height int64, round int, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID) *Proposal
NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.
type SideChainOrg ¶
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing. SignBytes returns the bytes to be signed NOTE: chainIDs are part of the SignBytes but not necessarily the object themselves. NOTE: Expected to panic if there is an error marshalling.
type SignedHeader ¶
SignedHeader is a header along with the commits that prove it
type TooManyProposalEvidence ¶
type TooManyProposalEvidence struct { PubKey crypto.PubKey H int64 }
TooManyProposalEvidence contains evidence: a validator propose too many times, disproportional to its voting power.
func (*TooManyProposalEvidence) Address ¶
func (tmpe *TooManyProposalEvidence) Address() string
func (*TooManyProposalEvidence) Equal ¶
func (tmpe *TooManyProposalEvidence) Equal(ev Evidence) bool
func (*TooManyProposalEvidence) Hash ¶
func (tmpe *TooManyProposalEvidence) Hash() []byte
func (*TooManyProposalEvidence) Height ¶
func (tmpe *TooManyProposalEvidence) Height() int64
func (*TooManyProposalEvidence) Index ¶
func (tmpe *TooManyProposalEvidence) Index() int
func (*TooManyProposalEvidence) String ¶
func (tmpe *TooManyProposalEvidence) String() string
func (*TooManyProposalEvidence) Verify ¶
func (tmpe *TooManyProposalEvidence) Verify(chainID string) error
type Tx ¶
type Tx []byte
Tx is an arbitrary byte array. NOTE: Tx has no types at this level, so when wire encoded it's just length-prefixed. Alternatively, it may make sense to add types here and let []byte be type 0x1 so we can have versioned txs if need be in the future.
type TxEventBuffer ¶
type TxEventBuffer struct {
// contains filtered or unexported fields
}
TxEventBuffer is a buffer of events, which uses a slice to temporarily store events.
func NewTxEventBuffer ¶
func NewTxEventBuffer(next TxEventPublisher, capacity int) *TxEventBuffer
NewTxEventBuffer accepts a TxEventPublisher and returns a new buffer with the given capacity.
func (*TxEventBuffer) Flush ¶
func (b *TxEventBuffer) Flush() error
Flush publishes events by running next.PublishWithTags on all cached events. Blocks. Clears cached events.
func (TxEventBuffer) Len ¶
func (b TxEventBuffer) Len() int
Len returns the number of events cached.
func (*TxEventBuffer) PublishEventTx ¶
func (b *TxEventBuffer) PublishEventTx(e EventDataTx) error
PublishEventTx buffers an event to be fired upon finality.
type TxEventPublisher ¶
type TxEventPublisher interface {
PublishEventTx(EventDataTx) error
}
type TxProof ¶
TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type TxResult ¶
type TxResult struct { Height int64 `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
Txs is a slice of Tx.
func (Txs) IndexByHash ¶
IndexByHash returns the index of this transaction hash in the list, or -1 if not found
type Validator ¶
type Validator struct { Address crypto.Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower uint64 `json:"voting_power"` RewardAddr crypto.Address `json:"reward_addr"` Name string `json:"name"` 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 ¶
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.
func NewValidatorSet ¶
func NewValidatorSet(vals []*Validator) *ValidatorSet
func (*ValidatorSet) Add ¶
func (valSet *ValidatorSet) Add(val *Validator) (added bool)
Add adds val to the validator set and returns true. It returns false if val is already in the set.
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet
func (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address string) (index int, val *Validator)
GetByAddress returns an index of the validator with address and validator itself if found. Otherwise, -1 and nil are returned.
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index int) (address string, val *Validator)
GetByIndex returns the validator's address and validator itself by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).
func (*ValidatorSet) GetProposer ¶
func (valSet *ValidatorSet) GetProposer(invalidProposer *[]crypto.Address, cb func(v *Validator)) (proposer *Validator)
GetProposer returns the current proposer. If the validator set is empty, nil is returned.
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address string) bool
HasAddress returns true if address given is in the validator set, false - otherwise.
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
Hash returns the Merkle root hash build using validators (as leaves) in the set.
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times int)
incrementAccum and update the proposer
func (*ValidatorSet) Iterate ¶
func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
Iterate will run the given function over the set.
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address string) (val *Validator, removed bool)
Remove deletes the validator with address. It returns the validator removed and true. If returns nil and false if validator is not present in the set.
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() int
Size returns the length of the validator set.
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
String
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
TotalVotingPower returns the sum of the voting powers of all validators.
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
Update updates val and returns true. It returns false if val is not present in the set.
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes
func (*ValidatorSet) VerifyCommitAny ¶
func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyCommitAny will check to see if the set would be valid with a different validator set.
valSet is the validator set that we know * over 2/3 of the power in old signed this block
newSet is the validator set that signed this block
- only votes from old are sufficient for 2/3 majority in the new set as well
That means that: * 10% of the valset can't just declare themselves kings * If the validator set is 3x old size, we need more proof to trust
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
Sort validators by address
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 crypto.Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int `json:"round"` Timestamp time.Time `json:"timestamp"` 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 ¶
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 NOTE: Vote must not be nil
func (*VoteSet) BitArrayByBlockID ¶
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) MarshalJSON ¶
Marshal the VoteSet to JSON. Same as String(), just in JSON, and without the height/round/type_ (since its already included in the votes).
func (*VoteSet) SetPeerMaj23 ¶
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).
Source Files ¶
- block.go
- block_meta.go
- canonical_json.go
- event_buffer.go
- event_bus.go
- events.go
- evidence.go
- genesis.go
- heartbeat.go
- keys.go
- nop_event_bus.go
- params.go
- part_set.go
- priv_validator.go
- proposal.go
- protobuf.go
- results.go
- services.go
- signable.go
- test_util.go
- tx.go
- validator.go
- validator_set.go
- vote.go
- vote_set.go
- wire.go