Documentation ¶
Index ¶
- Constants
- Variables
- func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
- func Byte64Tobyte(bytes64 [64]byte) (bytes []byte)
- func BytesToByte64(bytes []byte) (b64 [64]byte)
- func EventStringBond() string
- func EventStringCompleteProposal() string
- func EventStringDupeout() string
- func EventStringFork() string
- func EventStringHookCommit() string
- func EventStringHookExecute() string
- func EventStringHookNewRound() string
- func EventStringHookPrecommit() string
- func EventStringHookPrevote() string
- func EventStringHookPropose() string
- func EventStringLock() string
- func EventStringNewBlock() string
- func EventStringNewBlockHeader() string
- func EventStringNewRound() string
- func EventStringNewRoundStep() string
- func EventStringPolka() string
- func EventStringRebond() string
- func EventStringRelock() string
- func EventStringSwitchToConsensus() string
- func EventStringTimeoutPropose() string
- func EventStringTimeoutWait() string
- func EventStringTx(tx Tx) string
- func EventStringUnbond() string
- func EventStringUnlock() string
- func EventStringVote() string
- func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
- func FireEventHookCommit(fireable events.Fireable, d EventDataHookCommit)
- func FireEventHookExecute(fireable events.Fireable, d EventDataHookExecute)
- func FireEventHookNewRound(fireable events.Fireable, d EventDataHookNewRound)
- func FireEventHookPrecommit(fireable events.Fireable, d EventDataHookPrecommit)
- func FireEventHookPrevote(fireable events.Fireable, d EventDataHookPrevote)
- func FireEventHookPropose(fireable events.Fireable, d EventDataHookPropose)
- func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)
- func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)
- func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)
- func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)
- func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)
- func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventSwitchToConsensus(fireable events.Fireable)
- func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)
- func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)
- func FireEventTx(fireable events.Fireable, tx EventDataTx)
- func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventVote(fireable events.Fireable, vote EventDataVote)
- func GenTxsForTest(numtx, numExTx int) ([]Tx, []Tx)
- func HashSignBytes(chainID string, o Signable) []byte
- func IsAdminOP(tx []byte) bool
- func IsVoteTypeValid(type_ byte) bool
- func MakeBlock(height int64, chainID string, txs []Tx, extxs []Tx, commit *Commit, ...) (*Block, *PartSet)
- func PrivKeyByteToByte64(bytes []byte) (byte64 [64]byte)
- func RandValidator(randPower bool, minPower int64) (*Validator, *PrivValidator)
- func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []*PrivValidator)
- func SignBytes(chainID string, o Signable) []byte
- func SignCA(priv crypto.PrivKey, pubbytes []byte) string
- func StrToSmallStr(str string) (smallstr string)
- func StringTo32byte(key string) ([32]byte, error)
- func StringTo64byte(key string) ([64]byte, error)
- func StringToAnybyte(key string) ([]byte, error)
- func Substr(str string, start int, length int) string
- func TagAdminOPTx(tx []byte) []byte
- func TxsLenForTest() int
- func TxsNumForTest() int
- func UnwrapTx(tx []byte) []byte
- func WrapTx(prefix []byte, tx []byte) []byte
- type AdminOPCmd
- type AdminVoteResult
- type Application
- type BaseApplication
- func (ba *BaseApplication) InitBaseApplication(name string, datadir string) (err error)
- func (ba *BaseApplication) Initialized() bool
- func (ba *BaseApplication) LoadLastBlock(t interface{}) (res interface{}, err error)
- func (ba *BaseApplication) SaveLastBlock(lastBlock interface{})
- func (ba *BaseApplication) SaveLastBlockByKey(key []byte, lastBlock interface{})
- func (ba *BaseApplication) Stop()
- type Block
- func (b *Block) FillHeader()
- func (b *Block) Hash() []byte
- 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) TxsIsNil() bool
- func (b *Block) ValidateBasic(chainID string, lastBlockHeight int64, lastBlockID BlockID, ...) error
- func (b *Block) ValidateCommit() error
- type BlockID
- type BlockMeta
- type CanonicalJSONBlockID
- type CanonicalJSONOnceProposal
- type CanonicalJSONOnceVote
- type CanonicalJSONPartSetHeader
- type CanonicalJSONProposal
- type CanonicalJSONVote
- type CmdType
- type CodeType
- type Commit
- func (commit *Commit) BitArray() *gcmn.BitArray
- func (commit *Commit) FirstPrecommit() *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() int64
- func (commit *Commit) Size() int
- func (commit *Commit) StringIndented(indent string) string
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- type CommitResult
- type Core
- type Data
- type DefaultSigner
- type ErrVoteConflictingVotes
- type EventCache
- type EventDataHookCommit
- type EventDataHookExecute
- type EventDataHookNewRound
- type EventDataHookPrecommit
- type EventDataHookPrevote
- type EventDataHookPropose
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataRoundState
- type EventDataSwitchToConsensus
- type EventDataTx
- type EventDataVote
- type EventSwitch
- type Eventable
- type ExecuteInvalidTx
- type ExecuteResult
- type Fireable
- type GenesisDoc
- type GenesisValidator
- type GenesisValidatorJson
- type Header
- type Hook
- type Hooker
- type Hooks
- type IFilter
- type IMempool
- type NewRoundResult
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error)
- func (ps *PartSet) BitArray() *gcmn.BitArray
- func (ps *PartSet) Count() int
- func (ps *PartSet) GetPart(index int) *Part
- func (ps *PartSet) GetReader() io.Reader
- func (ps *PartSet) HasHeader(header PartSetHeader) bool
- func (ps *PartSet) Hash() []byte
- func (ps *PartSet) HashesTo(hash []byte) bool
- func (ps *PartSet) Header() PartSetHeader
- func (ps *PartSet) IsComplete() bool
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() int
- type PartSetHeader
- type PartSetReader
- type Peer
- type PrivValidator
- func (pv *PrivValidator) CopyReset() (cp PrivValidator)
- func (privVal *PrivValidator) GetAddress() []byte
- func (pv *PrivValidator) GetLastSignature() crypto.Signature
- func (pv *PrivValidator) GetPrivKey() crypto.PrivKey
- func (privVal *PrivValidator) GetPrivateKey() crypto.PrivKey
- func (pv *PrivValidator) GetPubKey() crypto.PubKey
- func (privVal *PrivValidator) Reset()
- func (privVal *PrivValidator) Save() error
- func (privVal *PrivValidator) SetFile(filePath string)
- func (privVal *PrivValidator) SetSigner(s Signer)
- func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
- func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
- func (privVal *PrivValidator) String() string
- func (pv *PrivValidator) UnmarshalJSON(data []byte) error
- type PrivValidatorTool
- func (pt *PrivValidatorTool) BackupData(branchName string) error
- func (pt *PrivValidatorTool) DelBackup(branchName string)
- func (pt *PrivValidatorTool) Init(dir string) error
- func (pt *PrivValidatorTool) RevertFromBackup(branchName string) error
- func (pt *PrivValidatorTool) SaveNewPrivV(toHeight int64) error
- type PrivValidatorsByAddress
- type Proposal
- type RPCResult
- type Result
- func (res Result) AppendLog(log string) Result
- func (res Result) Error() string
- func (res Result) IsErr() bool
- func (res Result) IsOK() bool
- func (res Result) PrependLog(log string) Result
- func (res Result) SetData(data []byte) Result
- func (res Result) SetLog(log string) Result
- func (res Result) String() string
- type ResultBlock
- type ResultBlockchainInfo
- type ResultBroadcastTx
- type ResultBroadcastTxCommit
- type ResultCoreVersion
- type ResultDialSeeds
- type ResultDumpConsensusState
- type ResultEvent
- type ResultGenesis
- type ResultHealthInfo
- type ResultInfo
- type ResultLastHeight
- type ResultNetInfo
- type ResultNumArchivedBlocks
- type ResultNumLimitTx
- type ResultQuery
- type ResultRefuseList
- type ResultRequestAdminOP
- type ResultShards
- type ResultStatus
- type ResultSubscribe
- type ResultSurveillance
- type ResultTransaction
- type ResultUnconfirmedTxs
- type ResultUnsafeFlushMempool
- type ResultUnsafeProfile
- type ResultUnsafeSetConfig
- type ResultUnsubscribe
- type ResultValidator
- type ResultValidators
- type SigInfo
- type Signable
- type Signer
- type TMEventData
- type Tx
- type TxExecutionResult
- type TxInPool
- type TxPool
- type TxPoolApplication
- type TxpoolFilter
- type Txs
- type Validator
- type ValidatorAttr
- type ValidatorCmd
- 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) HasAddress(address []byte) bool
- func (valSet *ValidatorSet) Hash() []byte
- func (valSet *ValidatorSet) IncrementAccum(times int64)
- func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) Proposer() (proposer *Validator)
- 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
- type ValidatorsByAddress
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *gcmn.BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *gcmn.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() *Commit
- func (voteSet *VoteSet) Round() int64
- func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID)
- func (voteSet *VoteSet) Size() int
- func (voteSet *VoteSet) String() string
- func (voteSet *VoteSet) StringIndented(indent string) string
- func (voteSet *VoteSet) StringShort() string
- func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- type VoteSetReader
Constants ¶
const ( EventDataTypeNewBlock = byte(0x01) EventDataTypeFork = byte(0x02) EventDataTypeTx = byte(0x03) EventDataTypeNewBlockHeader = byte(0x04) EventDataTypeSwitchToConsensus = byte(0x5) EventDataTypeRoundState = byte(0x11) EventDataTypeVote = byte(0x12) EventDataTypeHookNewRound = byte(0x21) EventDataTypeHookPropose = byte(0x22) EventDataTypeHookPrevote = byte(0x23) EventDataTypeHookPrecommit = byte(0x24) EventDataTypeHookCommit = byte(0x25) EventDataTypeHookExecute = byte(0x26) )
const ( // angine takes query id from 0x01 to 0x2F QueryTxExecution = 0x01 QueryTx = 0x02 )
const ( // 0x0 bytes are for the blockchain ResultTypeGenesis = byte(0x01) ResultTypeBlockchainInfo = byte(0x02) ResultTypeBlock = byte(0x03) ResultTypeLastHeight = byte(0x04) ResultTypeHealthInfo = byte(0x05) // 0x2 bytes are for the network ResultTypeStatus = byte(0x20) ResultTypeNetInfo = byte(0x21) ResultTypeDialSeeds = byte(0x22) ResultTypeShards = byte(0x23) // 0x1 bytes are for refuseList ResultTypeRefuseList = byte(0x10) // 0x4 bytes are for the consensus ResultTypeValidators = byte(0x40) ResultTypeDumpConsensusState = byte(0x41) // 0x6 bytes are for txs / the application ResultTypeBroadcastTx = byte(0x60) ResultTypeUnconfirmedTxs = byte(0x61) ResultTypeBroadcastTxCommit = byte(0x62) ResultTypeRequestAdminOP = byte(0x63) ResultTypeNumArchivedBlocks = byte(0x64) ResultTypeNumLimitTx = byte(0x65) // 0x7 bytes are for querying the application ResultTypeQuery = byte(0x70) ResultTypeInfo = byte(0x71) // 0x8 bytes are for events ResultTypeSubscribe = byte(0x80) ResultTypeUnsubscribe = byte(0x81) ResultTypeEvent = byte(0x82) // 0xa bytes for testing ResultTypeUnsafeSetConfig = byte(0xa0) ResultTypeUnsafeStartCPUProfiler = byte(0xa1) ResultTypeUnsafeStopCPUProfiler = byte(0xa2) ResultTypeUnsafeWriteHeapProfile = byte(0xa3) ResultTypeUnsafeFlushMempool = byte(0xa4) ResultTypeCoreVersion = byte(0xaf) // 0x9 bytes are for za_surveillance ResultTypeSurveillance = byte(0x90) )
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
const (
AdminOpChangeValidator = "changeValidator"
)
const MaxBlockSize = 22020096 // 21MB TODO make it configurable
const (
PRIV_FILE_NAME = "priv_validator.json"
)
Variables ¶
var ( PeerStateKey = "ConsensusReactor.peerState" PeerMempoolChKey = "MempoolReactor.peerMempoolCh" )
var ( ErrPartSetUnexpectedIndex = errors.New("Error part set unexpected index") ErrPartSetInvalidProof = errors.New("Error part set invalid proof") )
var ( ErrFileNotFound = errors.New("priv_validator.json not found") ErrBranchIsUsed = errors.New("priv_validator:branch name is used") ErrPVRevertFromBackup = errors.New("priv_validator:revert from backup, not find data") )
var ( ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature") ErrInvalidBlockPartHash = errors.New("Error invalid block part hash") )
var ( ErrVoteUnexpectedStep = errors.New("Unexpected step") ErrVoteInvalidValidatorIndex = errors.New("Invalid round vote validator index") ErrVoteInvalidValidatorAddress = errors.New("Invalid round vote validator address") ErrVoteInvalidSignature = errors.New("Invalid round vote signature") ErrVoteInvalidBlockHash = errors.New("Invalid block hash") )
var (
AdminTag = []byte("zaop")
)
var CodeType_name = map[int32]string{
0: "OK",
1: "InternalError",
2: "EncodingError",
3: "BadNonce",
4: "Unauthorized",
5: "InsufficientFunds",
6: "UnknownRequest",
101: "BaseDuplicateAddress",
102: "BaseEncodingError",
103: "BaseInsufficientFees",
104: "BaseInsufficientFunds",
105: "BaseInsufficientGasPrice",
106: "BaseInvalidInput",
107: "BaseInvalidOutput",
108: "BaseInvalidPubKey",
109: "BaseInvalidSequence",
110: "BaseInvalidSignature",
111: "BaseUnknownAddress",
112: "BaseUnknownPubKey",
113: "BaseUnknownPlugin",
114: "WrongRLP",
115: "SaveFailed",
201: "GovUnknownEntity",
202: "GovUnknownGroup",
203: "GovUnknownProposal",
204: "GovDuplicateGroup",
205: "GovDuplicateMember",
206: "GovDuplicateProposal",
207: "GovDuplicateVote",
208: "GovInvalidMember",
209: "GovInvalidVote",
210: "GovInvalidVotingPower",
}
var CodeType_value = map[string]int32{
"OK": 0,
"InternalError": 1,
"EncodingError": 2,
"BadNonce": 3,
"Unauthorized": 4,
"InsufficientFunds": 5,
"UnknownRequest": 6,
"BaseDuplicateAddress": 101,
"BaseEncodingError": 102,
"BaseInsufficientFees": 103,
"BaseInsufficientFunds": 104,
"BaseInsufficientGasPrice": 105,
"BaseInvalidInput": 106,
"BaseInvalidOutput": 107,
"BaseInvalidPubKey": 108,
"BaseInvalidSequence": 109,
"BaseInvalidSignature": 110,
"BaseUnknownAddress": 111,
"BaseUnknownPubKey": 112,
"BaseUnknownPlugin": 113,
"WrongRLP": 114,
"SaveFailed": 115,
"GovUnknownEntity": 201,
"GovUnknownGroup": 202,
"GovUnknownProposal": 203,
"GovDuplicateGroup": 204,
"GovDuplicateMember": 205,
"GovDuplicateProposal": 206,
"GovDuplicateVote": 207,
"GovInvalidMember": 208,
"GovInvalidVote": 209,
"GovInvalidVotingPower": 210,
}
var GenDocKey = []byte("GenDocKey")
var ValidatorCodec = validatorCodec{}
Functions ¶
func AddListenerForEvent ¶
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
func Byte64Tobyte ¶
func BytesToByte64 ¶
func EventStringCompleteProposal ¶
func EventStringCompleteProposal() string
func EventStringDupeout ¶
func EventStringDupeout() string
func EventStringFork ¶
func EventStringFork() string
func EventStringHookCommit ¶
func EventStringHookCommit() string
func EventStringHookExecute ¶
func EventStringHookExecute() string
func EventStringHookNewRound ¶
func EventStringHookNewRound() string
func EventStringHookPrecommit ¶
func EventStringHookPrecommit() string
func EventStringHookPrevote ¶
func EventStringHookPrevote() string
func EventStringHookPropose ¶
func EventStringHookPropose() string
func EventStringLock ¶
func EventStringLock() string
func EventStringNewBlock ¶
func EventStringNewBlock() string
func EventStringNewBlockHeader ¶
func EventStringNewBlockHeader() string
func EventStringNewRound ¶
func EventStringNewRound() string
func EventStringNewRoundStep ¶
func EventStringNewRoundStep() string
func EventStringPolka ¶
func EventStringPolka() string
func EventStringRebond ¶
func EventStringRebond() string
func EventStringRelock ¶
func EventStringRelock() string
func EventStringSwitchToConsensus ¶
func EventStringSwitchToConsensus() string
func EventStringTimeoutPropose ¶
func EventStringTimeoutPropose() string
func EventStringTimeoutWait ¶
func EventStringTimeoutWait() string
func EventStringTx ¶
func EventStringUnbond ¶
func EventStringUnbond() string
func EventStringUnlock ¶
func EventStringUnlock() string
func EventStringVote ¶
func EventStringVote() string
func FireEventCompleteProposal ¶
func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
func FireEventHookCommit ¶
func FireEventHookCommit(fireable events.Fireable, d EventDataHookCommit)
func FireEventHookExecute ¶
func FireEventHookExecute(fireable events.Fireable, d EventDataHookExecute)
func FireEventHookNewRound ¶
func FireEventHookNewRound(fireable events.Fireable, d EventDataHookNewRound)
func FireEventHookPrecommit ¶
func FireEventHookPrecommit(fireable events.Fireable, d EventDataHookPrecommit)
func FireEventHookPrevote ¶
func FireEventHookPrevote(fireable events.Fireable, d EventDataHookPrevote)
func FireEventHookPropose ¶
func FireEventHookPropose(fireable events.Fireable, d EventDataHookPropose)
func FireEventLock ¶
func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
func FireEventNewBlock ¶
func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)
func FireEventNewBlockHeader ¶
func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)
func FireEventNewRound ¶
func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)
func FireEventNewRoundStep ¶
func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)
func FireEventPolka ¶
func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)
func FireEventRelock ¶
func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)
func FireEventSwitchToConsensus ¶
func FireEventSwitchToConsensus(fireable events.Fireable)
func FireEventTimeoutPropose ¶
func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)
func FireEventTimeoutWait ¶
func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)
func FireEventTx ¶
func FireEventTx(fireable events.Fireable, tx EventDataTx)
func FireEventUnlock ¶
func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)
func FireEventVote ¶
func FireEventVote(fireable events.Fireable, vote EventDataVote)
func GenTxsForTest ¶
func HashSignBytes ¶
HashSignBytes is a convenience method for getting the hash of the bytes of a signable
func IsVoteTypeValid ¶
func MakeBlock ¶
func MakeBlock(height int64, chainID string, txs []Tx, extxs []Tx, commit *Commit, proposer []byte, prevBlockID BlockID, valHash, appHash, receiptsHash []byte, partSize int) (*Block, *PartSet)
TODO: version
func PrivKeyByteToByte64 ¶
func RandValidator ¶
func RandValidator(randPower bool, minPower int64) (*Validator, *PrivValidator)
func RandValidatorSet ¶
func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []*PrivValidator)
NOTE: PrivValidator are in order.
func StrToSmallStr ¶
func StringTo32byte ¶
func StringTo64byte ¶
func StringToAnybyte ¶
func TagAdminOPTx ¶
func TxsLenForTest ¶
func TxsLenForTest() int
func TxsNumForTest ¶
func TxsNumForTest() int
Types ¶
type AdminOPCmd ¶
type AdminOPCmd struct { CmdType string `json:"cmdtype"` //type for what kind of adminOp Msg []byte `json:"msg"` SelfSign []byte `json:"sigs"` Time time.Time `json:"time"` Nonce uint64 `json:"nonce"` SInfos []SigInfo `json:"siginfos"` }
func (*AdminOPCmd) ExtractMsg ¶
func (cmd *AdminOPCmd) ExtractMsg(o interface{}) (interface{}, error)
func (*AdminOPCmd) LoadMsg ¶
func (cmd *AdminOPCmd) LoadMsg(o interface{}) error
type AdminVoteResult ¶
type Application ¶
type BaseApplication ¶
type BaseApplication struct { Database db.DB InitializedState bool }
func (*BaseApplication) InitBaseApplication ¶
func (ba *BaseApplication) InitBaseApplication(name string, datadir string) (err error)
InitBaseApplication must be the first thing to be called when an application embeds BaseApplication
func (*BaseApplication) Initialized ¶
func (ba *BaseApplication) Initialized() bool
Initialized returns if a BaseApplication based app has been fully initialized
func (*BaseApplication) LoadLastBlock ¶
func (ba *BaseApplication) LoadLastBlock(t interface{}) (res interface{}, err error)
func (*BaseApplication) SaveLastBlock ¶
func (ba *BaseApplication) SaveLastBlock(lastBlock interface{})
func (*BaseApplication) SaveLastBlockByKey ¶
func (ba *BaseApplication) SaveLastBlockByKey(key []byte, lastBlock interface{})
func (*BaseApplication) Stop ¶
func (ba *BaseApplication) Stop()
Stop handles freeing resources taken by BaseApplication
type Block ¶
type Block struct { *Header `json:"header"` *Data `json:"data"` LastCommit *Commit `json:"last_commit"` }
func GenBlockForTest ¶
func GenBlocksForTest ¶
func (*Block) FillHeader ¶
func (b *Block) FillHeader()
func (*Block) Hash ¶
Computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*Block) HashesTo ¶
Convenience. A nil block never hashes to anything. Nothing hashes to a nil hash.
func (*Block) MakePartSet ¶
func (*Block) StringIndented ¶
func (*Block) StringShort ¶
func (*Block) ValidateBasic ¶
func (b *Block) ValidateBasic(chainID string, lastBlockHeight int64, lastBlockID BlockID, lastBlockTime time.Time, appHash, receiptsHash []byte) error
Basic validation that doesn't involve state data.
func (*Block) ValidateCommit ¶ added in v1.4.0
type BlockID ¶
type BlockID struct { Hash []byte `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
func GenBlockID ¶
func GenBlockID() BlockID
type BlockMeta ¶
type BlockMeta struct { Hash []byte `json:"hash"` // The block hash Header *Header `json:"header"` // The block's Header PartsHeader PartSetHeader `json:"parts_header"` // The PartSetHeader, for transfer }
func NewBlockMeta ¶
type CanonicalJSONBlockID ¶
type CanonicalJSONBlockID struct { Hash []byte `json:"hash,omitempty"` PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"` }
func CanonicalBlockID ¶
func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID
type CanonicalJSONOnceProposal ¶
type CanonicalJSONOnceProposal struct { ChainID string `json:"chain_id"` Proposal CanonicalJSONProposal `json:"proposal"` }
type CanonicalJSONOnceVote ¶
type CanonicalJSONOnceVote struct { ChainID string `json:"chain_id"` Vote CanonicalJSONVote `json:"vote"` }
type CanonicalJSONPartSetHeader ¶
func CanonicalPartSetHeader ¶
func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader
type CanonicalJSONProposal ¶
type CanonicalJSONProposal struct { BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"` Height int64 `json:"height"` POLBlockID CanonicalJSONBlockID `json:"pol_block_id"` POLRound int64 `json:"pol_round"` Round int64 `json:"round"` }
func CanonicalProposal ¶
func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal
type CanonicalJSONVote ¶
type CanonicalJSONVote struct { BlockID CanonicalJSONBlockID `json:"block_id"` Height int64 `json:"height"` Round int64 `json:"round"` Type byte `json:"type"` }
func CanonicalVote ¶
func CanonicalVote(vote *Vote) CanonicalJSONVote
type CodeType ¶
type CodeType int32
const ( CodeType_OK CodeType = 0 // General response codes, 0 ~ 99 CodeType_InternalError CodeType = 1 CodeType_EncodingError CodeType = 2 CodeType_BadNonce CodeType = 3 CodeType_InsufficientFunds CodeType = 5 CodeType_UnknownRequest CodeType = 6 CodeType_InvalidTx CodeType = 7 // Reserved for basecoin, 100 ~ 199 CodeType_BaseDuplicateAddress CodeType = 101 CodeType_BaseEncodingError CodeType = 102 CodeType_BaseInsufficientFees CodeType = 103 CodeType_BaseInsufficientFunds CodeType = 104 CodeType_BaseInsufficientGasPrice CodeType = 105 CodeType_BaseInvalidInput CodeType = 106 CodeType_BaseInvalidOutput CodeType = 107 CodeType_BaseInvalidPubKey CodeType = 108 CodeType_BaseInvalidSequence CodeType = 109 CodeType_BaseInvalidSignature CodeType = 110 CodeType_BaseUnknownAddress CodeType = 111 CodeType_BaseUnknownPubKey CodeType = 112 CodeType_BaseUnknownPlugin CodeType = 113 CodeType_WrongRLP CodeType = 114 CodeType_SaveFailed CodeType = 115 // Reserved for governance, 200 ~ 299 CodeType_GovUnknownEntity CodeType = 201 CodeType_GovUnknownGroup CodeType = 202 CodeType_GovUnknownProposal CodeType = 203 CodeType_GovDuplicateGroup CodeType = 204 CodeType_GovDuplicateMember CodeType = 205 CodeType_GovDuplicateProposal CodeType = 206 CodeType_GovDuplicateVote CodeType = 207 CodeType_GovInvalidMember CodeType = 208 CodeType_GovInvalidVote CodeType = 209 CodeType_GovInvalidVotingPower CodeType = 210 )
type Commit ¶
type Commit struct { // NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order. // Any peer with a block can gossip precommits by index with a peer without recalculating the // active ValidatorSet. BlockID BlockID `json:"blockID"` Precommits []*Vote `json:"precommits"` // contains filtered or unexported fields }
NOTE: Commit is empty for height 1, but never nil.
func GenCommitForTest ¶
func (*Commit) FirstPrecommit ¶
func (*Commit) GetByIndex ¶
func (*Commit) StringIndented ¶
func (*Commit) ValidateBasic ¶
type CommitResult ¶
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"` ExTxs Txs `json:"extxs"` // this is for all other txs which won't be delivered to app // contains filtered or unexported fields }
func (*Data) StringIndented ¶
type DefaultSigner ¶
type DefaultSigner struct {
// contains filtered or unexported fields
}
Implements Signer
func NewDefaultSigner ¶
func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner
func (*DefaultSigner) Sign ¶
func (ds *DefaultSigner) Sign(msg []byte) crypto.Signature
Implements Signer
type ErrVoteConflictingVotes ¶
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type EventCache ¶
type EventCache interface { Fireable Flush() }
func NewEventCache ¶
func NewEventCache(evsw EventSwitch) EventCache
type EventDataHookCommit ¶
type EventDataHookCommit struct { Height int64 Round int64 Block *Block ResCh chan CommitResult }
func NewEventDataHookCommit ¶
func NewEventDataHookCommit(height, round int64, block *Block) EventDataHookCommit
func (EventDataHookCommit) AssertIsTMEventData ¶
func (_ EventDataHookCommit) AssertIsTMEventData()
type EventDataHookExecute ¶
type EventDataHookExecute struct { Height int64 Round int64 Block *Block ResCh chan ExecuteResult }
func NewEventDataHookExecute ¶
func NewEventDataHookExecute(height, round int64, block *Block) EventDataHookExecute
func (EventDataHookExecute) AssertIsTMEventData ¶
func (_ EventDataHookExecute) AssertIsTMEventData()
type EventDataHookNewRound ¶
type EventDataHookNewRound struct { Height int64 Round int64 ResCh chan NewRoundResult }
func NewEventDataHookNewRound ¶
func NewEventDataHookNewRound(height, round int64) EventDataHookNewRound
func (EventDataHookNewRound) AssertIsTMEventData ¶
func (_ EventDataHookNewRound) AssertIsTMEventData()
type EventDataHookPrecommit ¶
func (EventDataHookPrecommit) AssertIsTMEventData ¶
func (_ EventDataHookPrecommit) AssertIsTMEventData()
type EventDataHookPrevote ¶
func (EventDataHookPrevote) AssertIsTMEventData ¶
func (_ EventDataHookPrevote) AssertIsTMEventData()
type EventDataHookPropose ¶
func (EventDataHookPropose) AssertIsTMEventData ¶
func (_ EventDataHookPropose) AssertIsTMEventData()
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 EventDataRoundState ¶
type EventDataRoundState struct { Height int64 `json:"height"` Round int64 `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 EventDataSwitchToConsensus ¶
type EventDataSwitchToConsensus struct {
State interface{}
}
func (EventDataSwitchToConsensus) AssertIsTMEventData ¶
func (_ EventDataSwitchToConsensus) AssertIsTMEventData()
type EventDataTx ¶
type EventDataTx struct { Tx Tx `json:"tx"` Data []byte `json:"data"` Log string `json:"log"` Code CodeType `json:"code"` Error string `json:"error"` // this is redundant information for now }
All txs fire EventDataTx
func (EventDataTx) AssertIsTMEventData ¶
func (_ EventDataTx) AssertIsTMEventData()
type EventDataVote ¶
type EventDataVote struct {
Vote *Vote
}
func (EventDataVote) AssertIsTMEventData ¶
func (_ EventDataVote) AssertIsTMEventData()
type EventSwitch ¶
type EventSwitch interface { events.EventSwitch }
func NewEventSwitch ¶
func NewEventSwitch() EventSwitch
type Eventable ¶
type Eventable interface {
SetEventSwitch(EventSwitch)
}
type ExecuteInvalidTx ¶
type ExecuteResult ¶
type ExecuteResult struct { ValidTxs Txs InvalidTxs []ExecuteInvalidTx Error error }
type GenesisDoc ¶
type GenesisDoc struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` Validators []GenesisValidator `json:"validators"` AppHash []byte `json:"app_hash"` Plugins string `json:"plugins"` }
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) *GenesisDoc
func GenesisDocFromJSONRet ¶
func GenesisDocFromJSONRet(jsonBlob []byte) (genState *GenesisDoc, err error)
func (*GenesisDoc) JSONBytes ¶
func (genDoc *GenesisDoc) JSONBytes() []byte
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
Utility method for saving GenensisDoc as JSON file.
type GenesisValidator ¶
type GenesisValidator struct { PubKey crypto.PubKey `json:"pub_key"` Amount int64 `json:"amount"` Name string `json:"name"` IsCA bool `json:"is_ca"` RPCAddress string `json:"rpc"` }
func (*GenesisValidator) UnmarshalJSON ¶
func (gv *GenesisValidator) UnmarshalJSON(b []byte) error
type GenesisValidatorJson ¶
type Header ¶
type Header struct { ChainID string `json:"chain_id"` Height int64 `json:"height"` Time time.Time `json:"time"` NumTxs int64 `json:"num_txs"` // XXX: Can we get rid of this? LastBlockID BlockID `json:"last_block_id"` LastCommitHash []byte `json:"last_commit_hash"` // commit from validators from the last block DataHash []byte `json:"data_hash"` // transactions ValidatorsHash []byte `json:"validators_hash"` // validators for the current block AppHash []byte `json:"app_hash"` // state after txs from the previous block ReceiptsHash []byte `json:"recepits_hash"` // recepits_hash from previous block ProposerAddress []byte `json:"proposer_address"` Extra []byte `json:"extra"` // doesn't included in header hash }
func (*Header) StringIndented ¶
type NewRoundResult ¶
type NewRoundResult struct { }
type Part ¶
type Part struct { Index int `json:"index"` Bytes []byte `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` // contains filtered or unexported fields }
func (*Part) StringIndented ¶
type PartSet ¶
type PartSet struct {
// contains filtered or unexported fields
}
func NewPartSetFromData ¶
Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
Returns an empty PartSet ready to be populated.
func (*PartSet) HasHeader ¶
func (ps *PartSet) HasHeader(header PartSetHeader) bool
func (*PartSet) Header ¶
func (ps *PartSet) Header() PartSetHeader
func (*PartSet) IsComplete ¶
func (*PartSet) StringShort ¶
type PartSetHeader ¶
func (PartSetHeader) Equals ¶
func (psh PartSetHeader) Equals(other PartSetHeader) bool
func (PartSetHeader) IsZero ¶
func (psh PartSetHeader) IsZero() bool
func (PartSetHeader) String ¶
func (psh PartSetHeader) String() string
func (PartSetHeader) WriteSignBytes ¶
func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int, err *error)
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type Peer ¶
type Peer struct { p2p.NodeInfo `json:"node_info"` IsOutbound bool `json:"is_outbound"` ConnectionStatus p2p.ConnectionStatus `json:"connection_status"` }
type PrivValidator ¶
type PrivValidator struct { Address []byte `json:"address"` PubKey crypto.PubKey `json:"pub_key"` LastHeight int64 `json:"last_height"` LastRound int64 `json:"last_round"` LastStep int8 `json:"last_step"` LastSignature crypto.Signature `json:"last_signature"` // so we dont lose signatures LastSignBytes []byte `json:"last_signbytes"` // so we dont lose signatures // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.PrivKey `json:"priv_key"` Signer `json:"-"` // contains filtered or unexported fields }
func GenPrivValidator ¶
func GenPrivValidator(cryptoType string, privkey crypto.PrivKey) (*PrivValidator, error)
Generates a new validator with private key.
func LoadOrGenPrivValidator ¶
func LoadOrGenPrivValidator(filePath string) *PrivValidator
func LoadPrivValidator ¶
func LoadPrivValidator(filePath string) (*PrivValidator, error)
func (*PrivValidator) CopyReset ¶
func (pv *PrivValidator) CopyReset() (cp PrivValidator)
func (*PrivValidator) GetAddress ¶
func (privVal *PrivValidator) GetAddress() []byte
func (*PrivValidator) GetLastSignature ¶
func (pv *PrivValidator) GetLastSignature() crypto.Signature
func (*PrivValidator) GetPrivKey ¶
func (pv *PrivValidator) GetPrivKey() crypto.PrivKey
func (*PrivValidator) GetPrivateKey ¶
func (privVal *PrivValidator) GetPrivateKey() crypto.PrivKey
func (*PrivValidator) GetPubKey ¶
func (pv *PrivValidator) GetPubKey() crypto.PubKey
func (*PrivValidator) Save ¶
func (privVal *PrivValidator) Save() error
func (*PrivValidator) SetFile ¶
func (privVal *PrivValidator) SetFile(filePath string)
func (*PrivValidator) SetSigner ¶
func (privVal *PrivValidator) SetSigner(s Signer)
func (*PrivValidator) SignProposal ¶
func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
func (*PrivValidator) SignVote ¶
func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
func (*PrivValidator) String ¶
func (privVal *PrivValidator) String() string
func (*PrivValidator) UnmarshalJSON ¶
func (pv *PrivValidator) UnmarshalJSON(data []byte) error
type PrivValidatorTool ¶
type PrivValidatorTool struct {
// contains filtered or unexported fields
}
func (*PrivValidatorTool) BackupData ¶
func (pt *PrivValidatorTool) BackupData(branchName string) error
func (*PrivValidatorTool) DelBackup ¶
func (pt *PrivValidatorTool) DelBackup(branchName string)
func (*PrivValidatorTool) Init ¶
func (pt *PrivValidatorTool) Init(dir string) error
func (*PrivValidatorTool) RevertFromBackup ¶
func (pt *PrivValidatorTool) RevertFromBackup(branchName string) error
func (*PrivValidatorTool) SaveNewPrivV ¶
func (pt *PrivValidatorTool) SaveNewPrivV(toHeight int64) error
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 int64 `json:"round"` BlockPartsHeader PartSetHeader `json:"block_parts_header"` POLRound int64 `json:"pol_round"` // -1 if null. POLBlockID BlockID `json:"pol_block_id"` // zero if null. Signature crypto.Signature `json:"signature"` }
func NewProposal ¶
func NewProposal(height int64, round int64, blockPartsHeader PartSetHeader, polRound int64, polBlockID BlockID) *Proposal
polRound: -1 if no polRound.
type Result ¶
CONTRACT: a zero Result is OK.
func NewResultOK ¶
NOTE: if data == nil and log == "", same as zero Result.
func (Result) PrependLog ¶
type ResultBlock ¶
type ResultBlockchainInfo ¶
type ResultBroadcastTx ¶
type ResultBroadcastTxCommit ¶
type ResultCoreVersion ¶
type ResultDialSeeds ¶
type ResultDialSeeds struct { }
type ResultEvent ¶
type ResultEvent struct { Name string `json:"name"` Data TMEventData `json:"data"` }
type ResultGenesis ¶
type ResultGenesis struct {
Genesis *GenesisDoc `json:"genesis"`
}
type ResultHealthInfo ¶
type ResultHealthInfo struct {
Status int `json:"status"`
}
type ResultInfo ¶
type ResultLastHeight ¶
type ResultLastHeight struct {
LastHeight int64 `json:"last_height"`
}
type ResultNetInfo ¶
type ResultNumArchivedBlocks ¶
type ResultNumArchivedBlocks struct {
Num int64 `json:"num"`
}
type ResultNumLimitTx ¶
type ResultNumLimitTx struct {
Num uint64 `json:"num"`
}
type ResultQuery ¶
type ResultQuery struct {
Result Result `json:"result"`
}
type ResultRefuseList ¶
type ResultRefuseList struct {
Result []string `json:"result"`
}
type ResultRequestAdminOP ¶
type ResultShards ¶
type ResultShards struct {
Names []string `json:"names"`
}
type ResultStatus ¶
type ResultStatus struct { NodeInfo *p2p.NodeInfo `json:"node_info"` PubKey crypto.PubKey `json:"pub_key"` LatestBlockHash []byte `json:"latest_block_hash"` LatestAppHash []byte `json:"latest_app_hash"` LatestBlockHeight int64 `json:"latest_block_height"` LatestBlockTime int64 `json:"latest_block_time"` // nano }
type ResultSubscribe ¶
type ResultSubscribe struct { }
type ResultSurveillance ¶
type ResultTransaction ¶
type ResultUnconfirmedTxs ¶
type ResultUnsafeFlushMempool ¶
type ResultUnsafeFlushMempool struct{}
type ResultUnsafeProfile ¶
type ResultUnsafeProfile struct{}
type ResultUnsafeSetConfig ¶
type ResultUnsafeSetConfig struct{}
type ResultUnsubscribe ¶
type ResultUnsubscribe struct { }
type ResultValidator ¶
type ResultValidator struct { Address []byte `json:"address"` PubKey string `json:"pub_key"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` IsCA bool `json:"is_ca"` }
func MakeResultValidators ¶
func MakeResultValidators(vs []*Validator) []*ResultValidator
type ResultValidators ¶
type ResultValidators struct { BlockHeight int64 `json:"block_height"` Validators []*ResultValidator `json:"validators"` }
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type Signer ¶
type Signer interface {
Sign(msg []byte) crypto.Signature
}
This is used to sign votes. It is the caller's duty to verify the msg before calling Sign, eg. to avoid double signing. Currently, the only callers are SignVote and SignProposal
type TMEventData ¶
type TMEventData interface {
events.EventData
AssertIsTMEventData()
}
implements events.EventData
type TxExecutionResult ¶
type TxExecutionResult struct { Height uint64 `json:"height"` BlockHash []byte `json:"blockhash"` Index uint64 `json:"index"` }
func (*TxExecutionResult) FromBytes ¶
func (i *TxExecutionResult) FromBytes(data []byte) error
func (*TxExecutionResult) ToBytes ¶
func (i *TxExecutionResult) ToBytes() ([]byte, error)
type TxInPool ¶
type TxInPool struct { Counter int64 // a simple incrementing counter Height int64 // height that this tx had been validated in Tx Tx }
A transaction that successfully ran
type TxPoolApplication ¶
type TxPoolApplication interface { Application GetTxPool() TxPool }
type TxpoolFilter ¶
type TxpoolFilter struct {
// contains filtered or unexported fields
}
func NewTxpoolFilter ¶
func NewTxpoolFilter(f func([]byte) (bool, error)) TxpoolFilter
type Validator ¶
type Validator struct { Address []byte `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` IsCA bool `json:"is_ca"` }
Volatile state for each Validator TODO: make non-volatile identity
- Remove Accum - it can be computed, and now valset becomes identifying
func NewValidator ¶
func (*Validator) CompareAccum ¶
Returns the one with higher Accum.
type ValidatorAttr ¶
type ValidatorAttr struct { PubKey []byte `json:"pubKey,omitempty"` //hex of pubkey; Power int64 `json:"power,omitempty"` Cmd ValidatorCmd `json:"cmd"` Addr []byte `json:"addr"` Nonce uint64 `json:"nonce"` }
func (*ValidatorAttr) GetIsCA ¶
func (m *ValidatorAttr) GetIsCA() bool
func (*ValidatorAttr) GetPower ¶
func (m *ValidatorAttr) GetPower() int64
func (*ValidatorAttr) GetPubKey ¶
func (m *ValidatorAttr) GetPubKey() []byte
func (*ValidatorAttr) Reset ¶
func (m *ValidatorAttr) Reset()
func (*ValidatorAttr) String ¶
func (m *ValidatorAttr) String() string
type ValidatorCmd ¶
type ValidatorCmd string
const ( ValidatorCmdAddPeer ValidatorCmd = "add_peer" ValidatorCmdUpdateNode ValidatorCmd = "update_node" ValidatorCmdRemoveNode ValidatorCmd = "remove_node" )
type ValidatorSet ¶
type ValidatorSet struct { Validators []*Validator // NOTE: persisted via reflect, must be exported. // 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 .Proposer() 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 TODO: move valset into an iavl tree where key is 'blockbonded|pubkey'
func NewValidatorSet ¶
func NewValidatorSet(vals []*Validator) *ValidatorSet
func (*ValidatorSet) Add ¶
func (valSet *ValidatorSet) Add(val *Validator) (added bool)
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
func (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address []byte) bool
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times int64)
TODO: mind the overflow when times and votingPower shares too large.
func (*ValidatorSet) Iterate ¶
func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
func (*ValidatorSet) Proposer ¶
func (valSet *ValidatorSet) Proposer() (proposer *Validator)
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() int
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
func (ValidatorsByAddress) Len ¶
func (vs ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (vs ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (vs ValidatorsByAddress) Swap(i, j int)
type Vote ¶
type Vote struct { ValidatorAddress []byte `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int64 `json:"round"` Type byte `json:"type"` BlockID BlockID `json:"block_id"` // zero if vote is nil. Signature crypto.Signature `json:"signature"` }
Represents a prevote, precommit, or commit vote from validators for consensus.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet helps collect signatures from validators at each height+round for a predefined vote type.
We need VoteSet to be able to keep track of conflicting votes when validators double-sign. Yet, we can't keep track of *all* the votes seen, as that could be a DoS attack vector.
There are two storage areas for votes. 1. voteSet.votes 2. voteSet.votesByBlock
`.votes` is the "canonical" list of votes. It always has at least one vote, if a vote from a validator had been seen at all. Usually it keeps track of the first vote seen, but when a 2/3 majority is found, votes for that get priority and are copied over from `.votesByBlock`.
`.votesByBlock` keeps track of a list of votes for a particular block. There are two ways a &blockVotes{} gets created in `.votesByBlock`. 1. the first vote seen by a validator was for the particular block. 2. a peer claims to have seen 2/3 majority for the particular block.
Since the first vote from a validator will always get added in `.votesByBlock` , all votes in `.votes` will have a corresponding entry in `.votesByBlock`.
When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its votes are copied into `.votes`.
All this is memory bounded because conflicting votes only get added if a peer told us to track that block, each peer only gets to tell us 1 such block, and, there's only a limited number of peers.
NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func NewVoteSet ¶
func NewVoteSet(chainID string, height int64, round int64, type_ byte, valSet *ValidatorSet) *VoteSet
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
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) 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 ¶
- admin_op.go
- application.go
- block.go
- block_meta.go
- blockcache_other.go
- canonical_json.go
- common.go
- events.go
- genesis.go
- hooks.go
- keys.go
- mempool.go
- part_set.go
- priv_validator.go
- priv_validator_tool.go
- proposal.go
- query.go
- result.go
- resultcode.go
- rpc.go
- signable.go
- tools.go
- tx.go
- tx_pool.go
- validator.go
- validator_set.go
- vote.go
- vote_set.go