Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalTime(t time.Time) string
- func Exit(s string)
- func Fingerprint(slice []byte) []byte
- func GenAddressByPubKey(pubkey crypto.PubKey) []byte
- func Init()
- func InitMessageMap()
- func IsVoteTypeValid(voteType byte) bool
- func Kill() error
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func PanicCrisis(v interface{})
- func PanicQ(v interface{})
- func PanicSanity(v interface{})
- func Parallel(tasks ...func())
- func PubKeyFromString(pubkeystring string) (crypto.PubKey, error)
- func RandInt63n(n int64) int64
- func RandIntn(n int) int
- func RandUint32() uint32
- func SignBytes(chainID string, o Signable) []byte
- func SignatureFromString(sigString string) (crypto.Signature, error)
- func SimpleHashFromBinary(item *DuplicateVoteEvidence) []byte
- func Tempfile(prefix string) (*os.File, string)
- func WriteFile(filePath string, contents []byte, mode os.FileMode) error
- func WriteFileAtomic(filePath string, newBytes []byte, mode os.FileMode) error
- type BitArray
- func (bA *BitArray) And(o *BitArray) *BitArray
- func (bA *BitArray) Bytes() []byte
- func (bA *BitArray) Copy() *BitArray
- func (bA *BitArray) GetIndex(i int) bool
- func (bA *BitArray) IsEmpty() bool
- func (bA *BitArray) IsFull() bool
- func (bA *BitArray) Not() *BitArray
- func (bA *BitArray) Or(o *BitArray) *BitArray
- func (bA *BitArray) PickRandom() (int, bool)
- func (bA *BitArray) SetIndex(i int, v bool) bool
- func (bA *BitArray) Size() int
- func (bA *BitArray) String() string
- func (bA *BitArray) StringIndented(indent string) string
- func (bA *BitArray) Sub(o *BitArray) *BitArray
- func (bA *BitArray) Update(o *BitArray)
- type BlockGossip
- type BlockID
- type BlockSize
- type CanonicalJSONBlockID
- type CanonicalJSONHeartbeat
- type CanonicalJSONOnceHeartbeat
- type CanonicalJSONOnceProposal
- type CanonicalJSONOnceVote
- type CanonicalJSONPartSetHeader
- type CanonicalJSONProposal
- type CanonicalJSONVote
- type Commit
- func (commit *Commit) BitArray() *BitArray
- func (commit *Commit) FirstPrecommit() *tmtypes.Vote
- func (commit *Commit) GetByIndex(index int) *Vote
- func (commit *Commit) Hash() []byte
- 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 Comparable
- type ConsensusParams
- type DefaultSigner
- type DuplicateVoteEvidence
- func (dve *DuplicateVoteEvidence) Address() []byte
- func (dve *DuplicateVoteEvidence) Child() proto.Message
- func (dve *DuplicateVoteEvidence) Copy() Evidence
- 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) SetChild(child proto.Message)
- func (dve *DuplicateVoteEvidence) String() string
- func (dve *DuplicateVoteEvidence) TypeName() string
- func (dve *DuplicateVoteEvidence) Verify(chainID string) error
- type ErrEvidenceInvalid
- type ErrVoteConflictingVotes
- type Evidence
- type EvidenceData
- type EvidenceEnvelope
- type EvidenceEnvelopeList
- type EvidenceList
- type EvidenceParams
- type EvidencePool
- type GenesisDoc
- type GenesisValidator
- type Header
- type Heap
- type Heartbeat
- type HeightVoteSet
- func (hvs *HeightVoteSet) AddVote(vote *Vote, peerID string) (added bool, err error)
- func (hvs *HeightVoteSet) Height() int64
- func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID BlockID)
- func (hvs *HeightVoteSet) Precommits(round int) *VoteSet
- func (hvs *HeightVoteSet) Prevotes(round int) *VoteSet
- func (hvs *HeightVoteSet) Reset(height int64, valSet *ValidatorSet)
- func (hvs *HeightVoteSet) Round() int
- func (hvs *HeightVoteSet) SetPeerMaj23(round int, voteType byte, peerID string, blockID *tmtypes.BlockID)
- func (hvs *HeightVoteSet) SetRound(round int)
- func (hvs *HeightVoteSet) String() string
- func (hvs *HeightVoteSet) StringIndented(indent string) string
- type KeyText
- type MockBadEvidence
- func (e MockBadEvidence) Child() proto.Message
- func (e MockBadEvidence) Copy() Evidence
- func (e MockBadEvidence) Equal(ev Evidence) bool
- func (e MockBadEvidence) SetChild(proto.Message)
- func (e MockBadEvidence) String() string
- func (e MockBadEvidence) TypeName() string
- func (e MockBadEvidence) Verify(chainID string) error
- type MockEvidencePool
- type MockGoodEvidence
- func (e MockGoodEvidence) Address() []byte
- func (e MockGoodEvidence) Child() proto.Message
- func (e MockGoodEvidence) Copy() Evidence
- 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) SetChild(proto.Message)
- func (e MockGoodEvidence) String() string
- func (e MockGoodEvidence) TypeName() string
- func (e MockGoodEvidence) Verify(chainID string) error
- type PeerRoundState
- type Percent
- type PrivValidator
- type PrivValidatorFS
- type PrivValidatorImp
- func (pv *PrivValidatorImp) GetAddress() []byte
- func (pv *PrivValidatorImp) GetLastHeight() int64
- func (pv *PrivValidatorImp) GetLastRound() int
- func (pv *PrivValidatorImp) GetLastStep() int8
- func (pv *PrivValidatorImp) GetPubKey() crypto.PubKey
- func (pv *PrivValidatorImp) Reset()
- func (pv *PrivValidatorImp) ResetLastHeight(height int64)
- func (pv *PrivValidatorImp) Save()
- func (pv *PrivValidatorImp) SignHeartbeat(chainID string, heartbeat *Heartbeat) error
- func (pv *PrivValidatorImp) SignProposal(chainID string, proposal *Proposal) error
- func (pv *PrivValidatorImp) SignVote(chainID string, vote *Vote) error
- func (pv *PrivValidatorImp) String() string
- type PrivValidatorsByAddress
- type Proposal
- type RoundState
- type RoundStepType
- type RoundVoteSet
- type Signable
- type SignedHeader
- type Signer
- type TendermintBlock
- func (b *TendermintBlock) AddEvidence(evidence []Evidence)
- func (b *TendermintBlock) FillHeader()
- func (b *TendermintBlock) Hash() []byte
- func (b *TendermintBlock) HashesTo(hash []byte) bool
- func (b *TendermintBlock) String() string
- func (b *TendermintBlock) StringIndented(indent string) string
- func (b *TendermintBlock) StringShort() string
- func (b *TendermintBlock) ValidateBasic() (int64, error)
- type TxSize
- type Validator
- type ValidatorSet
- func (valSet *ValidatorSet) Add(val *Validator) (added bool)
- func (valSet *ValidatorSet) Copy() *ValidatorSet
- 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) 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() *BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID *tmtypes.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() int64
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *tmtypes.TendermintCommit
- func (voteSet *VoteSet) Round() int
- func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID *tmtypes.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 tmtypes.BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- type VoteSetReader
Constants ¶
const ( DuplicateVote = "DuplicateVote" MockGood = "MockGood" MockBad = "MockBad" )
-------------------------------------------
const ( RoundStepNewHeight = RoundStepType(0x01) // Wait til CommitTime + timeoutCommit RoundStepNewRound = RoundStepType(0x02) // Setup new round and go to RoundStepPropose RoundStepPropose = RoundStepType(0x03) // Did propose, gossip proposal RoundStepPrevote = RoundStepType(0x04) // Did prevote, gossip prevotes RoundStepPrevoteWait = RoundStepType(0x05) // Did receive any +2/3 prevotes, start timeout RoundStepPrecommit = RoundStepType(0x06) // Did precommit, gossip precommits RoundStepPrecommitWait = RoundStepType(0x07) // Did receive any +2/3 precommits, start timeout RoundStepCommit = RoundStepType(0x08) // Entered commit state machine EvidenceListID = byte(0x01) NewRoundStepID = byte(0x02) CommitStepID = byte(0x03) ProposalID = byte(0x04) ProposalPOLID = byte(0x05) VoteID = byte(0x06) HasVoteID = byte(0x07) VoteSetMaj23ID = byte(0X08) VoteSetBitsID = byte(0x09) ProposalHeartbeatID = byte(0x0a) ProposalBlockID = byte(0x0b) PacketTypePing = byte(0xff) PacketTypePong = byte(0xfe) )
step and message id define
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
const ( // RFC3339Millis ... RFC3339Millis = "2006-01-02T15:04:05.000Z" // forced microseconds )
Variables ¶
EvidenceType map define
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") )
error defines
var ( // ConsensusCrypto define ConsensusCrypto crypto.Crypto )
var ( // Fmt ... Fmt = fmt.Sprintf )
var ( // MsgMap define MsgMap map[byte]reflect.Type )
Functions ¶
func GenAddressByPubKey ¶
GenAddressByPubKey ...
func PubKeyFromString ¶
PubKeyFromString ...
func SignatureFromString ¶
SignatureFromString ...
func SimpleHashFromBinary ¶
func SimpleHashFromBinary(item *DuplicateVoteEvidence) []byte
SimpleHashFromBinary ...
Types ¶
type BitArray ¶
type BitArray struct { *tmtypes.TendermintBitArray // contains filtered or unexported fields }
BitArray ...
func NewBitArray ¶
NewBitArray There is no BitArray whose Size is 0. Use nil instead.
func (*BitArray) StringIndented ¶
StringIndented ...
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 ¶
BlockID struct
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 CanonicalJSONBlockID ¶
type CanonicalJSONBlockID struct { Hash []byte `json:"hash,omitempty"` PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"` }
CanonicalJSONBlockID ...
func CanonicalBlockID ¶
func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID
CanonicalBlockID ...
type CanonicalJSONHeartbeat ¶
type CanonicalJSONHeartbeat struct { Height int64 `json:"height"` Round int `json:"round"` Sequence int `json:"sequence"` ValidatorAddress []byte `json:"validator_address"` ValidatorIndex int `json:"validator_index"` }
CanonicalJSONHeartbeat ...
func CanonicalHeartbeat ¶
func CanonicalHeartbeat(heartbeat *Heartbeat) CanonicalJSONHeartbeat
CanonicalHeartbeat ...
type CanonicalJSONOnceHeartbeat ¶
type CanonicalJSONOnceHeartbeat struct { ChainID string `json:"chain_id"` Heartbeat CanonicalJSONHeartbeat `json:"heartbeat"` }
CanonicalJSONOnceHeartbeat ...
type CanonicalJSONOnceProposal ¶
type CanonicalJSONOnceProposal struct { ChainID string `json:"chain_id"` Proposal CanonicalJSONProposal `json:"proposal"` }
CanonicalJSONOnceProposal ...
type CanonicalJSONOnceVote ¶
type CanonicalJSONOnceVote struct { ChainID string `json:"chain_id"` Vote CanonicalJSONVote `json:"vote"` }
CanonicalJSONOnceVote ...
type CanonicalJSONPartSetHeader ¶
CanonicalJSONPartSetHeader ...
type CanonicalJSONProposal ¶
type CanonicalJSONProposal struct { BlockBytes []byte `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"` }
CanonicalJSONProposal ...
func CanonicalProposal ¶
func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal
CanonicalProposal ...
type CanonicalJSONVote ¶
type CanonicalJSONVote struct { BlockID CanonicalJSONBlockID `json:"block_id"` Height int64 `json:"height"` Round int `json:"round"` Timestamp string `json:"timestamp"` Type byte `json:"type"` }
CanonicalJSONVote ...
type Commit ¶
type Commit struct { *tmtypes.TendermintCommit // contains filtered or unexported fields }
Commit struct
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 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) 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 DefaultSigner ¶
DefaultSigner implements Signer. It uses a standard, unencrypted crypto.PrivKey.
func NewDefaultSigner ¶
func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner
NewDefaultSigner returns an instance of DefaultSigner.
type DuplicateVoteEvidence ¶
type DuplicateVoteEvidence struct {
*tmtypes.DuplicateVoteEvidence
}
DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.
func (*DuplicateVoteEvidence) Address ¶
func (dve *DuplicateVoteEvidence) Address() []byte
Address returns the address of the validator.
func (*DuplicateVoteEvidence) Child ¶
func (dve *DuplicateVoteEvidence) Child() proto.Message
Child ...
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) SetChild ¶
func (dve *DuplicateVoteEvidence) SetChild(child proto.Message)
SetChild ...
func (*DuplicateVoteEvidence) String ¶
func (dve *DuplicateVoteEvidence) String() string
String returns a string representation of the evidence.
func (*DuplicateVoteEvidence) TypeName ¶
func (dve *DuplicateVoteEvidence) TypeName() string
TypeName ...
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
NewEvidenceInvalidErr ...
func (*ErrEvidenceInvalid) Error ¶
func (err *ErrEvidenceInvalid) Error() string
Error returns a string representation of the error.
type ErrVoteConflictingVotes ¶
type ErrVoteConflictingVotes struct {
*DuplicateVoteEvidence
}
ErrVoteConflictingVotes ...
func NewConflictingVoteError ¶
func NewConflictingVoteError(val *Validator, voteA, voteB *tmtypes.Vote) *ErrVoteConflictingVotes
NewConflictingVoteError ...
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type Evidence ¶
type Evidence interface { Height() int64 // height of the equivocation Address() []byte // 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 Copy() Evidence TypeName() string SetChild(child proto.Message) Child() proto.Message }
Evidence represents any provable malicious activity by a validator
func EvidenceEnvelope2Evidence ¶
func EvidenceEnvelope2Evidence(envelope *tmtypes.EvidenceEnvelope) Evidence
EvidenceEnvelope2Evidence ...
type EvidenceData ¶
type EvidenceData struct { *tmtypes.EvidenceData // contains filtered or unexported fields }
EvidenceData ...
func (*EvidenceData) Hash ¶
func (data *EvidenceData) Hash() []byte
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 EvidenceEnvelope ¶
type EvidenceEnvelope struct {
*tmtypes.EvidenceEnvelope
}
EvidenceEnvelope ...
func (EvidenceEnvelope) String ¶
func (env EvidenceEnvelope) String() string
type EvidenceEnvelopeList ¶
type EvidenceEnvelopeList []EvidenceEnvelope
EvidenceEnvelopeList contains any evidence of malicious wrong-doing by validators
func (EvidenceEnvelopeList) Has ¶
func (evl EvidenceEnvelopeList) Has(evidence Evidence) bool
Has returns true if the evidence is in the EvidenceList.
func (EvidenceEnvelopeList) Hash ¶
func (evl EvidenceEnvelopeList) Hash() []byte
Hash returns the simple merkle root hash of the EvidenceList.
func (EvidenceEnvelopeList) String ¶
func (evl EvidenceEnvelopeList) String() string
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
DefaultEvidenceParams returns a default EvidenceParams.
type EvidencePool ¶
type EvidencePool interface { PendingEvidence() []Evidence AddEvidence(Evidence) error Update(*TendermintBlock) }
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"` ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators"` AppHash []byte `json:"app_hash"` AppOptions interface{} `json:"app_options,omitempty"` }
GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
func GenesisDocFromFile ¶
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) 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 { PubKey KeyText `json:"pub_key"` Power int64 `json:"power"` Name string `json:"name"` }
GenesisValidator is an initial validator.
type Header ¶
type Header struct {
*tmtypes.TendermintBlockHeader
}
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) StringIndented ¶
StringIndented returns a string representation of the header
type HeightVoteSet ¶
type HeightVoteSet struct {
// contains filtered or unexported fields
}
HeightVoteSet ...
func NewHeightVoteSet ¶
func NewHeightVoteSet(chainID string, height int64, valSet *ValidatorSet) *HeightVoteSet
NewHeightVoteSet ...
func (*HeightVoteSet) AddVote ¶
func (hvs *HeightVoteSet) AddVote(vote *Vote, peerID string) (added bool, err error)
AddVote Duplicate votes return added=false, err=nil. By convention, peerKey is "" if origin is self.
func (*HeightVoteSet) POLInfo ¶
func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID BlockID)
POLInfo Last round and blockID that has +2/3 prevotes for a particular block or nil. Returns -1 if no such round exists.
func (*HeightVoteSet) Precommits ¶
func (hvs *HeightVoteSet) Precommits(round int) *VoteSet
Precommits ...
func (*HeightVoteSet) Prevotes ¶
func (hvs *HeightVoteSet) Prevotes(round int) *VoteSet
Prevotes ...
func (*HeightVoteSet) Reset ¶
func (hvs *HeightVoteSet) Reset(height int64, valSet *ValidatorSet)
Reset ...
func (*HeightVoteSet) SetPeerMaj23 ¶
func (hvs *HeightVoteSet) SetPeerMaj23(round int, voteType byte, peerID string, blockID *tmtypes.BlockID)
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
func (*HeightVoteSet) SetRound ¶
func (hvs *HeightVoteSet) SetRound(round int)
SetRound Create more RoundVoteSets up to round.
func (*HeightVoteSet) String ¶
func (hvs *HeightVoteSet) String() string
func (*HeightVoteSet) StringIndented ¶
func (hvs *HeightVoteSet) StringIndented(indent string) string
StringIndented ...
type MockBadEvidence ¶
type MockBadEvidence struct {
MockGoodEvidence
}
MockBadEvidence UNSTABLE
func (MockBadEvidence) String ¶
func (e MockBadEvidence) String() string
type MockEvidencePool ¶
type MockEvidencePool struct { }
MockEvidencePool is an empty implementation of a Mempool, useful for testing. UNSTABLE
func (MockEvidencePool) AddEvidence ¶
func (m MockEvidencePool) AddEvidence(Evidence) error
AddEvidence ...
func (MockEvidencePool) PendingEvidence ¶
func (m MockEvidencePool) PendingEvidence() []Evidence
PendingEvidence ...
type MockGoodEvidence ¶
MockGoodEvidence UNSTABLE
func NewMockGoodEvidence ¶
func NewMockGoodEvidence(height int64, index int, address []byte) MockGoodEvidence
NewMockGoodEvidence UNSTABLE
func (MockGoodEvidence) String ¶
func (e MockGoodEvidence) String() string
type PeerRoundState ¶
type PeerRoundState struct { Height int64 // Height peer is at Round int // Round peer is at, -1 if unknown. Step RoundStepType // Step peer is at StartTime time.Time // Estimated start of round 0 at this height Proposal bool // True if peer has proposal for this round ProposalBlock bool // True if peer has proposal block for this round ProposalPOLRound int // Proposal's POL round. -1 if none. ProposalPOL *BitArray // nil until ProposalPOLMessage received. Prevotes *BitArray // All votes peer has for this round Precommits *BitArray // All precommits peer has for this round LastCommitRound int // Round of commit for last height. -1 if none. LastCommit *BitArray // All commit precommits of commit for last height. CatchupCommitRound int // Round that we have commit for. Not necessarily unique. -1 if none. CatchupCommit *BitArray // All commit precommits peer has for this height & CatchupCommitRound }
PeerRoundState ...
func (PeerRoundState) String ¶
func (prs PeerRoundState) String() string
String returns a string representation of the PeerRoundState
func (PeerRoundState) StringIndented ¶
func (prs PeerRoundState) StringIndented(indent string) string
StringIndented returns a string representation of the PeerRoundState
type Percent ¶
type Percent uint32
Percent represents a percentage in increments of 1/1000th of a percent.
type PrivValidator ¶
type PrivValidator interface { GetAddress() []byte // 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 GetLastHeight() int64 GetLastRound() int GetLastStep() int8 //reset height,round,step used by start to catch up ResetLastHeight(height int64) }
PrivValidator defines the functionality of a local Tendermint validator that signs votes, proposals, and heartbeats, and never double signs.
type PrivValidatorFS ¶
type PrivValidatorFS struct { Address string `json:"address"` PubKey KeyText `json:"pub_key"` LastHeight int64 `json:"last_height"` LastRound int `json:"last_round"` LastStep int8 `json:"last_step"` LastSignature *KeyText `json:"last_signature,omitempty"` // so we dont lose signatures LastSignBytes string `json:"last_signbytes,omitempty"` // so we dont lose signatures // PrivKey should be empty if a Signer other than the default is being used. PrivKey KeyText `json:"priv_key"` }
PrivValidatorFS implements PrivValidator using data persisted to disk to prevent double signing. The Signer itself can be mutated to use something besides the default, for instance a hardware signer.
type PrivValidatorImp ¶
type PrivValidatorImp struct { Address []byte PubKey crypto.PubKey LastHeight int64 LastRound int LastStep int8 LastSignature crypto.Signature LastSignBytes []byte // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.PrivKey Signer `json:"-"` // contains filtered or unexported fields }
PrivValidatorImp ...
func GenPrivValidatorImp ¶
func GenPrivValidatorImp(filePath string) *PrivValidatorImp
GenPrivValidatorImp generates a new validator with randomly generated private key and sets the filePath, but does not call Save().
func LoadOrGenPrivValidatorFS ¶
func LoadOrGenPrivValidatorFS(filePath string) *PrivValidatorImp
LoadOrGenPrivValidatorFS loads a PrivValidatorFS from the given filePath or else generates a new one and saves it to the filePath.
func LoadPrivValidatorFS ¶
func LoadPrivValidatorFS(filePath string) *PrivValidatorImp
LoadPrivValidatorFS loads a PrivValidatorImp from the filePath.
func LoadPrivValidatorFSWithSigner ¶
func LoadPrivValidatorFSWithSigner(filePath string, signerFunc func(PrivValidator) Signer) *PrivValidatorImp
LoadPrivValidatorFSWithSigner loads a PrivValidatorFS with a custom signer object. The PrivValidatorFS handles double signing prevention by persisting data to the filePath, while the Signer handles the signing. If the filePath does not exist, the PrivValidatorFS must be created manually and saved.
func (*PrivValidatorImp) GetAddress ¶
func (pv *PrivValidatorImp) GetAddress() []byte
GetAddress returns the address of the validator. Implements PrivValidator.
func (*PrivValidatorImp) GetLastHeight ¶
func (pv *PrivValidatorImp) GetLastHeight() int64
GetLastHeight ...
func (*PrivValidatorImp) GetLastRound ¶
func (pv *PrivValidatorImp) GetLastRound() int
GetLastRound ...
func (*PrivValidatorImp) GetLastStep ¶
func (pv *PrivValidatorImp) GetLastStep() int8
GetLastStep ...
func (*PrivValidatorImp) GetPubKey ¶
func (pv *PrivValidatorImp) GetPubKey() crypto.PubKey
GetPubKey returns the public key of the validator. Implements PrivValidator.
func (*PrivValidatorImp) Reset ¶
func (pv *PrivValidatorImp) Reset()
Reset resets all fields in the PrivValidatorFS. NOTE: Unsafe!
func (*PrivValidatorImp) ResetLastHeight ¶
func (pv *PrivValidatorImp) ResetLastHeight(height int64)
ResetLastHeight ...
func (*PrivValidatorImp) Save ¶
func (pv *PrivValidatorImp) Save()
Save persists the PrivValidatorFS to disk.
func (*PrivValidatorImp) SignHeartbeat ¶
func (pv *PrivValidatorImp) SignHeartbeat(chainID string, heartbeat *Heartbeat) error
SignHeartbeat signs a canonical representation of the heartbeat, along with the chainID. Implements PrivValidator.
func (*PrivValidatorImp) SignProposal ¶
func (pv *PrivValidatorImp) SignProposal(chainID string, proposal *Proposal) error
SignProposal signs a canonical representation of the proposal, along with the chainID. Implements PrivValidator.
func (*PrivValidatorImp) SignVote ¶
func (pv *PrivValidatorImp) SignVote(chainID string, vote *Vote) error
SignVote signs a canonical representation of the vote, along with the chainID. Implements PrivValidator.
func (*PrivValidatorImp) String ¶
func (pv *PrivValidatorImp) String() string
String returns a string representation of the PrivValidatorImp.
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []*PrivValidatorImp
PrivValidatorsByAddress ...
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 ¶
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, blockhash []byte, polRound int, polBlockID tmtypes.BlockID) *Proposal
NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.
type RoundState ¶
type RoundState struct { Height int64 // Height we are working on Round int Step RoundStepType StartTime time.Time CommitTime time.Time // Subjective time when +2/3 precommits for Block at Round were found Validators *ValidatorSet Proposal *tmtypes.Proposal ProposalBlock *TendermintBlock LockedRound int LockedBlock *TendermintBlock Votes *HeightVoteSet CommitRound int LastCommit *VoteSet // Last precommits at Height-1 LastValidators *ValidatorSet }
RoundState defines the internal consensus state. It is Immutable when returned from ConsensusState.GetRoundState() TODO: Actually, only the top pointer is copied, so access to field pointers is still racey NOTE: Not thread safe. Should only be manipulated by functions downstream of the cs.receiveRoutine
func (*RoundState) RoundStateMessage ¶
func (rs *RoundState) RoundStateMessage() *tmtypes.NewRoundStepMsg
RoundStateMessage ...
func (*RoundState) StringIndented ¶
func (rs *RoundState) StringIndented(indent string) string
StringIndented returns a string
func (*RoundState) StringShort ¶
func (rs *RoundState) StringShort() string
StringShort returns a string
type RoundStepType ¶
type RoundStepType uint8 // These must be numeric, ordered.
RoundStepType enumerates the state of the consensus state machine
type RoundVoteSet ¶
RoundVoteSet ...
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type SignedHeader ¶
SignedHeader is a header along with the commits that prove it
type Signer ¶
Signer is an interface that defines how to sign messages. It is the caller's duty to verify the msg before calling Sign, eg. to avoid double signing. Currently, the only callers are SignVote, SignProposal, and SignHeartbeat.
type TendermintBlock ¶
type TendermintBlock struct {
*tmtypes.TendermintBlock
}
TendermintBlock struct
func MakeBlock ¶
func MakeBlock(height int64, round int64, Txs []*types.Transaction, commit *tmtypes.TendermintCommit) *TendermintBlock
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 (*TendermintBlock) AddEvidence ¶
func (b *TendermintBlock) AddEvidence(evidence []Evidence)
AddEvidence appends the given evidence to the block
func (*TendermintBlock) FillHeader ¶
func (b *TendermintBlock) FillHeader()
FillHeader fills in any remaining header fields that are a function of the block data
func (*TendermintBlock) Hash ¶
func (b *TendermintBlock) Hash() []byte
Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*TendermintBlock) HashesTo ¶
func (b *TendermintBlock) HashesTo(hash []byte) bool
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 (*TendermintBlock) String ¶
func (b *TendermintBlock) String() string
String returns a string representation of the block
func (*TendermintBlock) StringIndented ¶
func (b *TendermintBlock) StringIndented(indent string) string
StringIndented returns a string representation of the block
func (*TendermintBlock) StringShort ¶
func (b *TendermintBlock) StringShort() string
StringShort returns a shortened string representation of the block
func (*TendermintBlock) ValidateBasic ¶
func (b *TendermintBlock) ValidateBasic() (int64, error)
ValidateBasic performs basic validation that doesn't involve state data. It checks the internal consistency of the block.
type Validator ¶
type Validator struct { Address []byte `json:"address"` PubKey []byte `json:"pub_key"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` }
Validator ...
func NewValidator ¶
NewValidator ...
func (*Validator) CompareAccum ¶
CompareAccum Returns the one with higher Accum.
func (*Validator) Copy ¶
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 (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
GetByAddress ...
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
GetByIndex returns the validator by index. It returns nil values if index < 0 or index >= len(ValidatorSet.Validators)
func (*ValidatorSet) GetProposer ¶
func (valSet *ValidatorSet) GetProposer() (proposer *Validator)
GetProposer ...
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address []byte) bool
HasAddress ...
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times int)
IncrementAccum 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)
Iterate ...
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
Remove ...
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
StringIndented ...
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
TotalVotingPower ...
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
Update ...
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyCommit 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
ValidatorsByAddress ...
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 ¶
Vote Represents a prevote, precommit, or commit vote from validators for consensus.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet ...
func NewVoteSet ¶
func NewVoteSet(chainID string, height int64, round int, voteType byte, valSet *ValidatorSet) *VoteSet
NewVoteSet Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddVote ¶
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 ¶
BitArrayByBlockID ...
func (*VoteSet) GetByAddress ¶
GetByAddress ...
func (*VoteSet) GetByIndex ¶
GetByIndex if validator has conflicting votes, returns "canonical" vote
func (*VoteSet) HasTwoThirdsAny ¶
HasTwoThirdsAny ...
func (*VoteSet) HasTwoThirdsMajority ¶
HasTwoThirdsMajority ...
func (*VoteSet) MakeCommit ¶
func (voteSet *VoteSet) MakeCommit() *tmtypes.TendermintCommit
MakeCommit ...
func (*VoteSet) SetPeerMaj23 ¶
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 ¶
StringIndented ...
func (*VoteSet) TwoThirdsMajority ¶
TwoThirdsMajority Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).