Documentation ¶
Index ¶
- Constants
- Variables
- func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
- func AtoHeight(heightStr string) (def.INT, error)
- func Byte64Tobyte(bytes64 [64]byte) (bytes []byte)
- func BytesToByte32(bytes []byte) (b32 [32]byte)
- func BytesToByte64(bytes []byte) (b64 [64]byte)
- func CheckBytesZero(bys []byte) bool
- 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 GenBlockID() pbtypes.BlockID
- func GenBlocksPbForTest(num int) []*pbtypes.Block
- func HashSignBytes(chainID string, o Signable) []byte
- func HeightToA(height def.INT) string
- func IsExtendedTx(tx []byte) bool
- func IsSpecialOP(tx []byte) bool
- func IsSuspectTx(tx []byte) bool
- func IsVoteChannel(tx []byte) bool
- func MakeBlock(maker []byte, height def.INT, chainID string, alltxs []Tx, commit *CommitCache, ...) (*BlockCache, *PartSet)
- func MarshalData(pb proto.Message) ([]byte, error)
- func NanoToTime(nano def.INT) time.Time
- func NewBlockMeta(block *BlockCache, blockParts *PartSet) *pbtypes.BlockMeta
- func NewDefaultPubKey(pkeybytes []byte) crypto.PubKey
- func NewDefaultSignature(sigbytes []byte) crypto.Signature
- func NewProposal(height, round def.INT, blockPartsHeader pbtypes.PartSetHeader, ...) *pbtypes.Proposal
- func PrivKeyByteToByte64(bytes []byte) (byte64 [64]byte)
- func RandValidator(logger *zap.Logger, randPower bool, minPower def.INT) (*Validator, *PrivValidator)
- func RandValidatorSet(logger *zap.Logger, numValidators int, votingPower def.INT) (*ValidatorSet, []*PrivValidator)
- func SignBytes(chainID string, o Signable) []byte
- func SignCA(secbytes []byte, plainTxt []byte) (string, error)
- 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 TagSpecialOPTx(tx []byte) []byte
- func TagVoteChannelTx(tx []byte) []byte
- func TxsLenForTest() int
- func TxsNumForTest() int
- func UnmarshalData(buf []byte, pb proto.Message) error
- func UnwrapTx(tx []byte) []byte
- func VoteChannelGetBody(tx []byte) []byte
- func WrapTx(prefix []byte, tx []byte) []byte
- type Application
- type BaseAppTool
- 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()
- func (ba *BaseApplication) SuspectValidator(pubkey []byte, reason string)
- func (ba *BaseApplication) ValSetLoader() func(height, round, size int) *ValidatorSet
- type BlockCache
- func (b *BlockCache) CommitCache() *CommitCache
- func (b *BlockCache) DataCache() *DataCache
- func (b *BlockCache) FillHeader()
- func (b *BlockCache) Hash() []byte
- func (b *BlockCache) HashesTo(hash []byte) bool
- func (b *BlockCache) MakePartSet(partSize def.INT) *PartSet
- func (b *BlockCache) String() string
- func (b *BlockCache) StringIndented(indent string) string
- func (b *BlockCache) StringShort() string
- func (b *BlockCache) ValidateBasic(chainID string, lastBlockHeight def.INT, lastBlockID pbtypes.BlockID, ...) error
- type Bytes
- type CmdType
- type CommApplication
- type CommitCache
- func (commit *CommitCache) BitArray() *BitArray
- func (commit *CommitCache) CSize() int
- func (commit *CommitCache) FirstPrecommit() *pbtypes.Vote
- func (commit *CommitCache) GetByIndex(index int) *pbtypes.Vote
- func (commit *CommitCache) Hash() []byte
- func (commit *CommitCache) Height() def.INT
- func (commit *CommitCache) IsCommit() bool
- func (commit *CommitCache) Round() def.INT
- func (commit *CommitCache) StringIndented(indent string) string
- func (commit *CommitCache) Type() pbtypes.VoteType
- func (commit *CommitCache) ValidateBasic() error
- type CommitResult
- type DataCache
- type DefaultSigner
- type ErrVoteConflictingVotes
- type ErrWrongAppHash
- type ErrWrongBasic
- type ErrWrongBlockID
- type ErrWrongChainID
- type ErrWrongDataHash
- type ErrWrongHeight
- type ErrWrongLastCommitHash
- type ErrWrongNonEmptyHeight
- type ErrWrongNumTxs
- type ErrWrongReceiptsHash
- type EventCache
- type EventDataHookCommit
- type EventDataHookExecute
- type EventDataHookNewRound
- type EventDataHookPrecommit
- type EventDataHookPrevote
- type EventDataHookPropose
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataRoundState
- type EventDataRoundStateJson
- type EventDataSwitchToConsensus
- type EventDataTx
- type EventDataVote
- type EventSwitch
- type Eventable
- type ExecuteInvalidTx
- type ExecuteResult
- type Fireable
- type GenesisDoc
- type GenesisValidator
- type GenesisValidatorJson
- type Hook
- type HookCallbackFunc
- type Hooker
- type Hooks
- type HypoBadVoteEvidence
- type HypoDisconnectEvidence
- type HypoProposalTimeoutEvidence
- type Hypocrite
- type Hypocrites
- type IBadVoteCollector
- type IBlockTick
- type IDisconnectCollector
- type IMempool
- type NewRoundResult
- type PartCache
- type PartSet
- func (ps *PartSet) AddPart(part *pbtypes.Part, verify bool) (bool, error)
- func (ps *PartSet) AssembleToBlock(partSize def.INT) *BlockCache
- func (ps *PartSet) BitArray() *BitArray
- func (ps *PartSet) Count() def.INT
- func (ps *PartSet) GetPart(index int) *pbtypes.Part
- func (ps *PartSet) HasHeader(header *pbtypes.PartSetHeader) bool
- func (ps *PartSet) Hash() []byte
- func (ps *PartSet) HashesTo(hash []byte) bool
- func (ps *PartSet) Header() *pbtypes.PartSetHeader
- func (ps *PartSet) IsComplete() bool
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() def.INT
- 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()
- func (privVal *PrivValidator) SetFile(filePath string)
- func (privVal *PrivValidator) SetSigner(s Signer)
- func (privVal *PrivValidator) SignProposal(chainID string, proposal *pbtypes.Proposal) error
- func (privVal *PrivValidator) SignVote(chainID string, vote *pbtypes.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 def.INT) error
- type PrivValidatorsByAddress
- 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 ResultInfo
- type ResultLastHeight
- type ResultNetInfo
- type ResultNonEmptyHeights
- type ResultNumArchivedBlocks
- type ResultOrgs
- type ResultQuery
- type ResultRefuseList
- type ResultRequestSpecialOP
- type ResultRequestVoteChannel
- type ResultStatus
- type ResultSubscribe
- type ResultSurveillance
- type ResultUnconfirmedTxs
- type ResultUnsafeFlushMempool
- type ResultUnsafeProfile
- type ResultUnsafeSetConfig
- type ResultUnsubscribe
- type ResultValidators
- type Signable
- type Signer
- type SpecialOPCmd
- type SpecialVoteResult
- type SuspectTx
- type TMEventData
- type Time
- type Tx
- type TxExecutionResult
- type Txs
- type Validator
- type ValidatorAttr
- 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 def.INT)
- func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) JSONBytes() ([]byte, error)
- 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() def.INT
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID pbtypes.BlockID, height def.INT, commit *CommitCache) error
- type ValidatorsByAddress
- type VoteChannelCmd
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *pbtypes.Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID *pbtypes.BlockID) *BitArray
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address []byte) *pbtypes.Vote
- func (voteSet *VoteSet) GetByIndex(valIndex int) *pbtypes.Vote
- func (voteSet *VoteSet) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() def.INT
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *CommitCache
- func (voteSet *VoteSet) Round() def.INT
- func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID *pbtypes.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 pbtypes.BlockID, ok bool)
- func (voteSet *VoteSet) Type() pbtypes.VoteType
- 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 ( REASON_CONNECTION byte REASON_BADVOTE REASON_PROPOSETO )
const ( // 0x0 bytes are for the blockchain ResultTypeGenesis = byte(0x01) ResultTypeBlockchainInfo = byte(0x02) ResultTypeBlock = byte(0x03) ResultTypeNonEmptyHeights = byte(0x04) ResultTypeNumArchivedBlocks = byte(0x05) // 0x2 bytes are for the network ResultTypeStatus = byte(0x20) ResultTypeNetInfo = byte(0x21) ResultTypeDialSeeds = byte(0x22) ResultTypeOrgs = 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) ResultTypeRequestSpecialOP = byte(0x63) ResultTypeVoteChannel = byte(0x64) // 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 ( SpecialOP = "specialOP" SpecialOP_ChangeValidator = "changeValidator" SpecialOP_Disconnect = "disconnect" SpecialOP_PromoteValidator = "promoteValidator" SpecialOP_DeleteValidator = "deleteValidator" SpecialOP_ChangePower = "changePower" SpecialOP_AddRefuseKey = "addRefuseKey" SpecialOP_DeleteRefuseKey = "deleteRefuseKey" )
const ( VoteChannel = "votechannel" VoteChannel_NewRequest = "newVoteRequest" VoteChannel_Sign = "signForRequest" VoteChannel_Exec = "executeRequest" VoteChannel_query = "queryRequests" )
sub command
const MaxBlockSize = 22020096 // 21MB TODO make it configurable
const (
PRIV_FILE_NAME = "priv_validator.json"
)
const (
// angine takes query id from 0x01 to 0x2F
QueryTxExecution = 0x01
)
Variables ¶
var ( ErrRevertFromBackup = errors.New("revert from backup,not find data") ErrBranchNameUsed = errors.New("app:branch name has been used") )
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") ErrVoteMultiSignature = errors.New("Multi round vote signature") ErrVoteInvalidBlockHash = errors.New("Invalid block hash") ErrVoteNilVoteSet = errors.New("VoteSet is nil") )
var GenDocKey = []byte("GenDocKey")
var (
SpecialTag = []byte{'z', 'a', 0x00, 0x01}
)
var (
SuspectTxTag = []byte{'s', 'p', 't', 0x01}
)
var Votetag = []byte{'v', 'o', 't', 0x01}
Functions ¶
func AddListenerForEvent ¶
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
func Byte64Tobyte ¶
func BytesToByte32 ¶
func BytesToByte64 ¶
func CheckBytesZero ¶
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 GenBlockID ¶
func GenBlocksPbForTest ¶
func HashSignBytes ¶
HashSignBytes is a convenience method for getting the hash of the bytes of a signable
func IsExtendedTx ¶
func IsSpecialOP ¶
func IsSuspectTx ¶
func IsVoteChannel ¶
func MakeBlock ¶
func MakeBlock(maker []byte, height def.INT, chainID string, alltxs []Tx, commit *CommitCache, prevBlockID pbtypes.BlockID, valHash, appHash, receiptsHash []byte, partSize, nonEmptyHeight def.INT) (*BlockCache, *PartSet)
TODO: version
func NewBlockMeta ¶
func NewBlockMeta(block *BlockCache, blockParts *PartSet) *pbtypes.BlockMeta
func NewDefaultPubKey ¶
func NewDefaultSignature ¶
func NewProposal ¶
func NewProposal(height, round def.INT, blockPartsHeader pbtypes.PartSetHeader, polRound def.INT, polBlockID pbtypes.BlockID) *pbtypes.Proposal
polRound: -1 if no polRound.
func PrivKeyByteToByte64 ¶
func RandValidator ¶
func RandValidatorSet ¶
func RandValidatorSet(logger *zap.Logger, numValidators int, votingPower def.INT) (*ValidatorSet, []*PrivValidator)
NOTE: PrivValidator are in order.
func StrToSmallStr ¶
func StringTo32byte ¶
func StringTo64byte ¶
func StringToAnybyte ¶
func TagSpecialOPTx ¶
func TagVoteChannelTx ¶
func TxsLenForTest ¶
func TxsLenForTest() int
func TxsNumForTest ¶
func TxsNumForTest() int
func VoteChannelGetBody ¶
Types ¶
type Application ¶
type BaseAppTool ¶
type BaseAppTool struct {
BaseApplication
}
func (*BaseAppTool) BackupLastBlockData ¶
func (t *BaseAppTool) BackupLastBlockData(branchName string, lastBlock interface{}) error
func (*BaseAppTool) DelBackup ¶
func (t *BaseAppTool) DelBackup(branchName string)
func (*BaseAppTool) RevertFromBackup ¶
func (t *BaseAppTool) RevertFromBackup(branchName string) error
type BaseApplication ¶
BaseApplication defines the default save/load last block implementations You can write all on your own, but embed this will save u some breath
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
func (*BaseApplication) SuspectValidator ¶
func (ba *BaseApplication) SuspectValidator(pubkey []byte, reason string)
SuspectValidator suggest punishment when needed
func (*BaseApplication) ValSetLoader ¶
func (ba *BaseApplication) ValSetLoader() func(height, round, size int) *ValidatorSet
ValSetLoader default funtion that return nil
type BlockCache ¶
func GenBlockForTest ¶
func GenBlockForTest(height def.INT, txs, exTxs int) *BlockCache
func GenBlocksForTest ¶
func GenBlocksForTest(num int) []*BlockCache
func MakeBlockCache ¶
func MakeBlockCache(block *pbtypes.Block) *BlockCache
func (*BlockCache) CommitCache ¶
func (b *BlockCache) CommitCache() *CommitCache
func (*BlockCache) DataCache ¶
func (b *BlockCache) DataCache() *DataCache
func (*BlockCache) FillHeader ¶
func (b *BlockCache) FillHeader()
func (*BlockCache) Hash ¶
func (b *BlockCache) Hash() []byte
Computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*BlockCache) HashesTo ¶
func (b *BlockCache) HashesTo(hash []byte) bool
Convenience. A nil block never hashes to anything. Nothing hashes to a nil hash.
func (*BlockCache) MakePartSet ¶
func (b *BlockCache) MakePartSet(partSize def.INT) *PartSet
func (*BlockCache) String ¶
func (b *BlockCache) String() string
func (*BlockCache) StringIndented ¶
func (b *BlockCache) StringIndented(indent string) string
func (*BlockCache) StringShort ¶
func (b *BlockCache) StringShort() string
type CommApplication ¶
CommApplication defines an app with basic net io ability
func (*CommApplication) Listen ¶
func (ca *CommApplication) Listen(addr string) (net.Listener, error)
func (*CommApplication) Lock ¶
func (ca *CommApplication) Lock()
func (*CommApplication) Stop ¶
func (ca *CommApplication) Stop()
func (*CommApplication) Unlock ¶
func (ca *CommApplication) Unlock()
type CommitCache ¶
NOTE: Commit is empty for height 1, but never nil.
func GenCommitCacheForTest ¶
func GenCommitCacheForTest(height def.INT, chainID string) *CommitCache
func NewCommitCache ¶
func NewCommitCache(c *pbtypes.Commit) *CommitCache
func (*CommitCache) BitArray ¶
func (commit *CommitCache) BitArray() *BitArray
func (*CommitCache) CSize ¶
func (commit *CommitCache) CSize() int
func (*CommitCache) FirstPrecommit ¶
func (commit *CommitCache) FirstPrecommit() *pbtypes.Vote
func (*CommitCache) GetByIndex ¶
func (commit *CommitCache) GetByIndex(index int) *pbtypes.Vote
func (*CommitCache) Hash ¶
func (commit *CommitCache) Hash() []byte
func (*CommitCache) Height ¶
func (commit *CommitCache) Height() def.INT
func (*CommitCache) IsCommit ¶
func (commit *CommitCache) IsCommit() bool
func (*CommitCache) Round ¶
func (commit *CommitCache) Round() def.INT
func (*CommitCache) StringIndented ¶
func (commit *CommitCache) StringIndented(indent string) string
func (*CommitCache) Type ¶
func (commit *CommitCache) Type() pbtypes.VoteType
func (*CommitCache) ValidateBasic ¶
func (commit *CommitCache) ValidateBasic() error
type CommitResult ¶
type DataCache ¶
func (*DataCache) 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 ErrWrongAppHash ¶
type ErrWrongAppHash error
func NewErrWrongAppHash ¶
func NewErrWrongAppHash(chainID string, expected, got []byte) ErrWrongAppHash
type ErrWrongBasic ¶
type ErrWrongBasic error
func NewErrWrongBasic ¶
func NewErrWrongBasic(err error) ErrWrongBasic
type ErrWrongBlockID ¶
type ErrWrongBlockID error
func NewErrWrongBlockID ¶
func NewErrWrongBlockID(chainID string, expected, got pbtypes.BlockID) ErrWrongBlockID
type ErrWrongChainID ¶
type ErrWrongChainID error
func NewErrWrongChainID ¶
func NewErrWrongChainID(expected, got string) ErrWrongChainID
type ErrWrongDataHash ¶
type ErrWrongDataHash error
func NewErrWrongDataHash ¶
func NewErrWrongDataHash(chainID string, expected, got []byte) ErrWrongDataHash
type ErrWrongHeight ¶
type ErrWrongHeight error
func NewErrWrongHeight ¶
func NewErrWrongHeight(chainID string, expected, got int) ErrWrongHeight
type ErrWrongLastCommitHash ¶
type ErrWrongLastCommitHash error
func NewErrWrongLastCommitHash ¶
func NewErrWrongLastCommitHash(chainID string, expected, got []byte) ErrWrongLastCommitHash
type ErrWrongNonEmptyHeight ¶
type ErrWrongNonEmptyHeight error
func NewErrWrongNonEmptyHeight ¶
func NewErrWrongNonEmptyHeight(chainID string, expected, got int) ErrWrongNonEmptyHeight
type ErrWrongNumTxs ¶
type ErrWrongNumTxs error
func NewErrWrongNumTxs ¶
func NewErrWrongNumTxs(chainID string, expected, got int) ErrWrongNumTxs
type ErrWrongReceiptsHash ¶
type ErrWrongReceiptsHash error
func NewErrWrongReceiptsHash ¶
func NewErrWrongReceiptsHash(chainID string, expected, got []byte) ErrWrongReceiptsHash
type EventCache ¶
type EventCache interface { Fireable Flush() }
func NewEventCache ¶
func NewEventCache(evsw EventSwitch) EventCache
type EventDataHookCommit ¶
type EventDataHookCommit struct { Height def.INT Round def.INT Block *BlockCache ResCh chan CommitResult }
func NewEventDataHookCommit ¶
func NewEventDataHookCommit(height, round def.INT, block *BlockCache) EventDataHookCommit
func (EventDataHookCommit) AssertIsTMEventData ¶
func (_ EventDataHookCommit) AssertIsTMEventData()
type EventDataHookExecute ¶
type EventDataHookExecute struct { Height def.INT Round def.INT Block *BlockCache ResCh chan ExecuteResult }
func NewEventDataHookExecute ¶
func NewEventDataHookExecute(height, round def.INT, block *BlockCache) EventDataHookExecute
func (EventDataHookExecute) AssertIsTMEventData ¶
func (_ EventDataHookExecute) AssertIsTMEventData()
type EventDataHookNewRound ¶
type EventDataHookNewRound struct { Height def.INT Round def.INT ResCh chan NewRoundResult }
func NewEventDataHookNewRound ¶
func NewEventDataHookNewRound(height, round def.INT) EventDataHookNewRound
func (EventDataHookNewRound) AssertIsTMEventData ¶
func (_ EventDataHookNewRound) AssertIsTMEventData()
type EventDataHookPrecommit ¶
type EventDataHookPrecommit struct { Height def.INT Round def.INT Block *BlockCache }
func (EventDataHookPrecommit) AssertIsTMEventData ¶
func (_ EventDataHookPrecommit) AssertIsTMEventData()
type EventDataHookPrevote ¶
type EventDataHookPrevote struct { Height def.INT Round def.INT Block *BlockCache }
func (EventDataHookPrevote) AssertIsTMEventData ¶
func (_ EventDataHookPrevote) AssertIsTMEventData()
type EventDataHookPropose ¶
type EventDataHookPropose struct { Height def.INT Round def.INT Block *BlockCache }
func (EventDataHookPropose) AssertIsTMEventData ¶
func (_ EventDataHookPropose) AssertIsTMEventData()
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *BlockCache `json:"block"`
}
func (EventDataNewBlock) AssertIsTMEventData ¶
func (_ EventDataNewBlock) AssertIsTMEventData()
type EventDataNewBlockHeader ¶
light weight event for benchmarking
func (EventDataNewBlockHeader) AssertIsTMEventData ¶
func (_ EventDataNewBlockHeader) AssertIsTMEventData()
type EventDataRoundState ¶
type EventDataRoundState struct {
EventDataRoundStateJson
}
NOTE: This goes into the replay WAL
func (EventDataRoundState) AssertIsTMEventData ¶
func (_ EventDataRoundState) AssertIsTMEventData()
func (EventDataRoundState) MarshalJSON ¶
func (ed EventDataRoundState) MarshalJSON() ([]byte, error)
func (*EventDataRoundState) UnmarshalJSON ¶
func (ed *EventDataRoundState) UnmarshalJSON(data []byte) error
type EventDataRoundStateJson ¶
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 pbtypes.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 ¶
func (EventDataVote) AssertIsTMEventData ¶
func (_ EventDataVote) AssertIsTMEventData()
type EventSwitch ¶
type EventSwitch interface { events.EventSwitch }
func NewEventSwitch ¶
func NewEventSwitch(logger *zap.Logger) 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 `json:"genesis_time"` ChainID string `json:"chain_id"` Validators []GenesisValidator `json:"validators"` AppHash Bytes `json:"app_hash"` Plugins string `json:"plugins"` }
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc)
func GenesisDocFromJSONRet ¶
func GenesisDocFromJSONRet(jsonBlob []byte) (genState *GenesisDoc, err error)
func (*GenesisDoc) JSONBytes ¶
func (genDoc *GenesisDoc) JSONBytes() ([]byte, error)
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.StPubKey `json:"pub_key"` Amount int64 `json:"amount"` Name string `json:"name"` IsCA bool `json:"is_ca"` }
func (*GenesisValidator) UnmarshalJSON ¶
func (gv *GenesisValidator) UnmarshalJSON(data []byte) error
type GenesisValidatorJson ¶
type GenesisValidatorJson struct { PubKey [32]byte `json:"pub_key"` Amount int64 `json:"amount"` Name string `json:"name"` IsCA bool `json:"is_ca"` }
func (*GenesisValidatorJson) UnmarshalJSON ¶
func (gv *GenesisValidatorJson) UnmarshalJSON(b []byte) error
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
func NewHook ¶
func NewHook(cb HookCallbackFunc) *Hook
type HookCallbackFunc ¶
type HookCallbackFunc func(height, round def.INT, block *BlockCache) (interface{}, error)
type HypoBadVoteEvidence ¶
type HypoDisconnectEvidence ¶
type HypoDisconnectEvidence struct {
PubKey string
}
type Hypocrite ¶
func NewHypocrite ¶
func (*Hypocrite) MarshalJSON ¶
func (*Hypocrite) UnmarshalJSON ¶
type IBadVoteCollector ¶
type IBadVoteCollector interface {
ReportBadVote(crypto.PubKey, interface{})
}
type IBlockTick ¶
type IBlockTick interface {
Tick(*BlockCache)
}
type IDisconnectCollector ¶
type IDisconnectCollector interface {
ReportDisconnect(crypto.PubKey, interface{})
}
type NewRoundResult ¶
type NewRoundResult struct { }
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 *pbtypes.PartSetHeader) *PartSet
Returns an empty PartSet ready to be populated.
func (*PartSet) AssembleToBlock ¶
func (ps *PartSet) AssembleToBlock(partSize def.INT) *BlockCache
func (*PartSet) Header ¶
func (ps *PartSet) Header() *pbtypes.PartSetHeader
func (*PartSet) IsComplete ¶
func (*PartSet) StringShort ¶
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 Bytes `json:"address"` PubKey crypto.StPubKey `json:"pub_key"` LastHeight def.INT `json:"last_height"` LastRound def.INT `json:"last_round"` LastStep int8 `json:"last_step"` LastSignature crypto.StSignature `json:"last_signature"` // so we dont lose signatures LastSignBytes Bytes `json:"last_signbytes"` // so we dont lose signatures // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.StPrivKey `json:"priv_key"` Signer `json:"-"` // contains filtered or unexported fields }
func GenPrivValidator ¶
func GenPrivValidator(logger *zap.Logger, privkey crypto.PrivKey) *PrivValidator
Generates a new validator with private key.
func LoadOrGenPrivValidator ¶
func LoadOrGenPrivValidator(logger *zap.Logger, filePath string) *PrivValidator
func LoadPrivValidator ¶
func LoadPrivValidator(logger *zap.Logger, filePath string) *PrivValidator
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()
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 *pbtypes.Proposal) error
func (*PrivValidator) SignVote ¶
func (privVal *PrivValidator) SignVote(chainID string, vote *pbtypes.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 def.INT) 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 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 ResultInfo ¶
type ResultLastHeight ¶
type ResultNetInfo ¶
type ResultNonEmptyHeights ¶
type ResultNumArchivedBlocks ¶
type ResultOrgs ¶
type ResultOrgs struct {
Names []string `json:"names"`
}
type ResultQuery ¶
type ResultQuery struct {
Result Result `json:"result"`
}
type ResultRefuseList ¶
type ResultRefuseList struct {
Result []string `json:"result"`
}
type ResultRequestSpecialOP ¶
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 def.INT `json:"latest_block_height"` LatestBlockTime int64 `json:"latest_block_time"` // nano }
type ResultSubscribe ¶
type ResultSubscribe struct { }
type ResultSurveillance ¶
type ResultUnconfirmedTxs ¶
type ResultUnsafeFlushMempool ¶
type ResultUnsafeFlushMempool struct{}
type ResultUnsafeProfile ¶
type ResultUnsafeProfile struct{}
type ResultUnsafeSetConfig ¶
type ResultUnsafeSetConfig struct{}
type ResultUnsubscribe ¶
type ResultUnsubscribe struct { }
type ResultValidators ¶
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 SpecialOPCmd ¶
type SpecialOPCmd struct { CmdType string `json:"cmdtype"` //type for what kind of specialOP Msg []byte `json:"msg"` Sigs [][]byte `json:"sigs"` Time time.Time `json:"time"` Nonce uint64 `json:"nonce"` PubKey []byte `json:"pubkey"` Signature []byte `json:"signature"` }
func (*SpecialOPCmd) ExtractMsg ¶
func (cmd *SpecialOPCmd) ExtractMsg(o interface{}) (interface{}, error)
func (*SpecialOPCmd) LoadMsg ¶
func (cmd *SpecialOPCmd) LoadMsg(o interface{}) error
type SpecialVoteResult ¶
type SuspectTx ¶
type TMEventData ¶
type TMEventData interface {
events.EventData
AssertIsTMEventData()
}
implements events.EventData
type TxExecutionResult ¶
type TxExecutionResult struct { Height def.INT `json:"height"` BlockHash []byte `json:"blockhash"` BlockTime time.Time `json:"blocktime"` ValidatorHash []byte `json:"validatorhash"` }
func (*TxExecutionResult) FromBytes ¶
func (i *TxExecutionResult) FromBytes(bytes []byte) error
func (*TxExecutionResult) ToBytes ¶
func (i *TxExecutionResult) ToBytes() ([]byte, error)
type Validator ¶
type Validator struct { Address []byte `json:"address"` PubKey crypto.StPubKey `json:"pub_key"` VotingPower def.INT `json:"voting_power"` Accum def.INT `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"` Power uint64 `json:"power,omitempty"` IsCA bool `json:"isCA,omitempty"` }
func (*ValidatorAttr) GetIsCA ¶
func (m *ValidatorAttr) GetIsCA() bool
func (*ValidatorAttr) GetPower ¶
func (m *ValidatorAttr) GetPower() uint64
func (*ValidatorAttr) GetPubKey ¶
func (m *ValidatorAttr) GetPubKey() []byte
func (*ValidatorAttr) Reset ¶
func (m *ValidatorAttr) Reset()
func (*ValidatorAttr) String ¶
func (m *ValidatorAttr) String() string
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 ValSetFromJsonBytes ¶
func ValSetFromJsonBytes(data []byte) *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 def.INT)
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) JSONBytes ¶
func (valSet *ValidatorSet) JSONBytes() ([]byte, error)
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() def.INT
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID pbtypes.BlockID, height def.INT, commit *CommitCache) 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 VoteChannelCmd ¶
type VoteChannelCmd struct { Id []byte `json:"id"` CmdCode string `json:"cmdcode"` //check for vote channel op SubCmd string `json:"subcmd"` //check for request type, include new vote, exec, vote ... Votetype string `json:"votetype"` //check is SpecialOP or other kind of OP type Txmsg Tx `json:"txmsg"` Msg []byte `json:"msg"` //store any kind of specific request type Signs [][]byte `json:"signs"` Sender []byte `json:"node_pubkey"` //sender pubkey }
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
func NewVoteSet ¶
func NewVoteSet(chainID string, height, round def.INT, type_ pbtypes.VoteType, 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) GetByIndex ¶
NOTE: if validator has conflicting votes, returns "canonical" vote
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeCommit ¶
func (voteSet *VoteSet) MakeCommit() *CommitCache
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 ¶
- application.go
- apptool.go
- block_meta.go
- blockcache.go
- blockcache_other.go
- common.go
- define.go
- errors.go
- events.go
- genesis.go
- hooks.go
- hypocrite.go
- keys.go
- mempool.go
- part_set.go
- priv_validator.go
- priv_validator_tool.go
- proposal.go
- query.go
- result.go
- rpc.go
- signable.go
- specialOP.go
- suspect.go
- tx.go
- validator.go
- validator_set.go
- vote.go
- vote_channel.go
- vote_set.go