Documentation ¶
Index ¶
- Constants
- Variables
- func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
- func EventStringBlockPart() string
- func EventStringBond() string
- func EventStringCompleteProposal() string
- func EventStringDupeout() string
- func EventStringFinalCommitted() string
- func EventStringFork() string
- func EventStringLock() string
- func EventStringMessage() string
- func EventStringNewBlock() string
- func EventStringNewBlockHeader() string
- func EventStringNewRound() string
- func EventStringNewRoundStep() string
- func EventStringPolka() string
- func EventStringProposal() string
- func EventStringProposalBlockParts() string
- func EventStringRebond() string
- func EventStringRelock() string
- func EventStringRequest() string
- func EventStringSignAggr() string
- func EventStringTimeoutPropose() string
- func EventStringTimeoutWait() string
- func EventStringTx(tx Tx) string
- func EventStringUnbond() string
- func EventStringUnlock() string
- func EventStringVote() string
- func EventStringVote2Proposer() string
- func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
- func FireEventFinalCommitted(fireable events.Fireable, rs EventDataFinalCommitted)
- func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
- func FireEventMessage(fireable events.Fireable, rs EventDataMessage)
- 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 FireEventRequest(fireable events.Fireable, rs EventDataRequest)
- func FireEventSignAggr(fireable events.Fireable, sign EventDataSignAggr)
- 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 FireEventVote2Proposer(fireable events.Fireable, vote EventDataVote2Proposer)
- func HashSignBytes(chainID string, o Signable) []byte
- func IsVoteTypeValid(type_ byte) bool
- func Loose23MajorThreshold(totalVotingPower *big.Int, round int) *big.Int
- func MakeBlock(height uint64, chainID string, commit *Commit, block *types.Block, ...) (*TdmBlock, *PartSet)
- func SignBytes(chainID string, o Signable) []byte
- type BlockID
- type BlockIDApi
- type CandidateApi
- type CanonicalJSONBlockID
- type CanonicalJSONOnceProposal
- type CanonicalJSONOnceSignAggr
- type CanonicalJSONOnceValidatorMsg
- type CanonicalJSONOnceVote
- type CanonicalJSONPartSetHeader
- type CanonicalJSONProposal
- type CanonicalJSONSignAggr
- type CanonicalJSONValidatorMsg
- type CanonicalJSONVote
- type Commit
- type CommitApi
- type ConsensusAggr
- type DefaultSigner
- type EpochApi
- type EpochApiForConsole
- type EpochValidator
- type EpochValidatorForConsole
- type EpochValidatorVoteApi
- type EpochValidatorVoteApiForConsole
- type EpochVotesApi
- type EpochVotesApiForConsole
- type ErrVoteConflictingVotes
- type EventCache
- type EventDataFinalCommitted
- type EventDataMessage
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataRequest
- type EventDataRoundState
- type EventDataSignAggr
- type EventDataTx
- type EventDataVote
- type EventDataVote2Proposer
- type EventSwitch
- type Eventable
- type Fireable
- type ForbiddenApi
- type GenesisDoc
- type GenesisDocWrite
- type GenesisValidator
- type GenesisValidatorWrite
- type IntermediateBlockResult
- type OneEpochDoc
- type OneEpochDocWrite
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error)
- func (ps *PartSet) BitArray() *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 PartSetHeaderApi
- type PartSetReader
- type PrivV
- type PrivValidator
- func (pv *PrivValidator) GetAddress() []byte
- func (pv *PrivValidator) GetPubKey() crypto.PubKey
- func (pv *PrivValidator) Save()
- func (pv *PrivValidator) SetFile(filePath string)
- func (pv *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
- func (pv *PrivValidator) SignVote(chainID string, vote *Vote) error
- func (pv *PrivValidator) String() string
- type PrivValidatorsByAddress
- type Proposal
- type RefundValidatorAmount
- type RewardSchemeDoc
- type SignAggr
- func (sa *SignAggr) HasAll(valSet *ValidatorSet) bool
- func (sa *SignAggr) HasTwoThirdsMajority(valSet *ValidatorSet) bool
- func (sa *SignAggr) IsCommit() bool
- func (sa *SignAggr) MakeCommit() *Commit
- func (sa *SignAggr) SetBitArray(newBitArray *BitArray)
- func (sa *SignAggr) SetMaj23(blockID BlockID)
- func (sa *SignAggr) SignAggr() crypto.BLSSignature
- func (sa *SignAggr) SignAggrVerify(msg []byte, valSet *ValidatorSet) bool
- func (sa *SignAggr) SignRound() int
- func (sa *SignAggr) Size() int
- func (va *SignAggr) String() string
- func (va *SignAggr) StringIndented(indent string) string
- func (va *SignAggr) StringShort() string
- func (sa *SignAggr) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (sa *SignAggr) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)
- type Signable
- type Signer
- type SwitchEpochOp
- type TMEventData
- type TdmBlock
- func (b *TdmBlock) FillSeenCommitHash()
- func (b *TdmBlock) FromBytes(reader io.Reader) (*TdmBlock, error)
- func (b *TdmBlock) Hash() []byte
- func (b *TdmBlock) HashesTo(hash []byte) bool
- func (b *TdmBlock) MakePartSet(partSize int) *PartSet
- func (b *TdmBlock) String() string
- func (b *TdmBlock) StringIndented(indent string) string
- func (b *TdmBlock) StringShort() string
- func (b *TdmBlock) ToBytes() []byte
- func (b *TdmBlock) ValidateBasic(tdmExtra *TendermintExtra) error
- type TendermintExtra
- type TendermintExtraApi
- type Tx
- type TxProof
- type Txs
- type Validator
- type ValidatorSet
- func (valSet *ValidatorSet) Add(val *Validator) (added bool)
- func (valSet *ValidatorSet) AggrPubKey(bitMap *cmn.BitArray) crypto.PubKey
- func (valSet *ValidatorSet) Copy() *ValidatorSet
- func (valSet *ValidatorSet) Equals(other *ValidatorSet) bool
- func (valSet *ValidatorSet) GetAggrPubKeyAndAddress(bitMap *cmn.BitArray) (*ConsensusAggr, error)
- 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) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
- func (valSet *ValidatorSet) Size() int
- func (valSet *ValidatorSet) String() string
- func (valSet *ValidatorSet) StringIndented(indent string) string
- func (valSet *ValidatorSet) TalliedVotingPower(bitMap *cmn.BitArray) (*big.Int, *big.Int, *big.Int, error)
- func (valSet *ValidatorSet) TotalVotingPower() *big.Int
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyCommit(chainID string, height uint64, commit *Commit) error
- func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error
- type ValidatorStatus
- type ValidatorsByAddress
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *BitArray
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address []byte) *Vote
- func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote
- func (voteSet *VoteSet) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() uint64
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) Round() int
- func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID)
- func (voteSet *VoteSet) Size() int
- func (voteSet *VoteSet) String() string
- func (voteSet *VoteSet) StringIndented(indent string) string
- func (voteSet *VoteSet) StringShort() string
- func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- func (voteSet *VoteSet) Votes() []*Vote
- type VoteSetReader
Constants ¶
const ( EventDataTypeNewBlock = byte(0x01) EventDataTypeFork = byte(0x02) EventDataTypeTx = byte(0x03) EventDataTypeNewBlockHeader = byte(0x04) EventDataTypeRoundState = byte(0x11) EventDataTypeVote = byte(0x12) EventDataTypeSignAggr = byte(0x13) EventDataTypeVote2Proposer = byte(0x14) EventDataTypeRequest = byte(0x21) EventDataTypeMessage = byte(0x22) EventDataTypeFinalCommitted = byte(0x23) )
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
const HalfLooseRound = 15
const LooseRound = 30
const MaxBlockSize = 22020096 // 21MB TODO make it configurable
const MaxSignAggrSize = 22020096 // 21MB TODO make it configurable
------------------------ signature aggregation -------------------
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 ( 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 CONSENSUS_IPBFT string = "ipbft"
var CONSENSUS_POS string = "pos"
var CONSENSUS_POW string = "pow"
var GenDocKey = []byte("GenDocKey")
var MainnetGenesisJSON string = `` /* 847-byte string literal not displayed */
var TestnetGenesisJSON string = `` /* 849-byte string literal not displayed */
var ValidatorCodec = validatorCodec{}
Functions ¶
func AddListenerForEvent ¶
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))
func EventStringBlockPart ¶
func EventStringBlockPart() string
func EventStringCompleteProposal ¶
func EventStringCompleteProposal() string
func EventStringDupeout ¶
func EventStringDupeout() string
func EventStringFinalCommitted ¶
func EventStringFinalCommitted() string
func EventStringFork ¶
func EventStringFork() string
func EventStringLock ¶
func EventStringLock() string
func EventStringMessage ¶
func EventStringMessage() 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 EventStringProposal ¶
func EventStringProposal() string
func EventStringProposalBlockParts ¶
func EventStringProposalBlockParts() string
func EventStringRebond ¶
func EventStringRebond() string
func EventStringRelock ¶
func EventStringRelock() string
func EventStringRequest ¶
func EventStringRequest() string
func EventStringSignAggr ¶
func EventStringSignAggr() 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 EventStringVote2Proposer ¶
func EventStringVote2Proposer() string
func FireEventCompleteProposal ¶
func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)
func FireEventFinalCommitted ¶
func FireEventFinalCommitted(fireable events.Fireable, rs EventDataFinalCommitted)
func FireEventLock ¶
func FireEventLock(fireable events.Fireable, rs EventDataRoundState)
func FireEventMessage ¶
func FireEventMessage(fireable events.Fireable, rs EventDataMessage)
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 FireEventRequest ¶
func FireEventRequest(fireable events.Fireable, rs EventDataRequest)
func FireEventSignAggr ¶
func FireEventSignAggr(fireable events.Fireable, sign EventDataSignAggr)
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 FireEventVote2Proposer ¶
func FireEventVote2Proposer(fireable events.Fireable, vote EventDataVote2Proposer)
func HashSignBytes ¶
HashSignBytes is a convenience method for getting the hash of the bytes of a signable
func IsVoteTypeValid ¶
func Loose23MajorThreshold ¶
max { [(2*LooseRound - round)*totalVotingPower + 3*LooseRound]/(3*LooseRound), totalVotingPower/2 + 1 }
Types ¶
type BlockID ¶
type BlockID struct { Hash []byte `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
type BlockIDApi ¶
type BlockIDApi struct { Hash string `json:"hash"` PartsHeader PartSetHeaderApi `json:"parts"` }
type CandidateApi ¶
type CandidateApi struct {
CandidateList []string `json:"candidateList"`
}
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 CanonicalJSONOnceSignAggr ¶
type CanonicalJSONOnceSignAggr struct { ChainID string `json:"chain_id"` SignAggr CanonicalJSONSignAggr `json:"sign_aggr"` }
type CanonicalJSONOnceValidatorMsg ¶
type CanonicalJSONOnceValidatorMsg struct { ChainID string `json:"chain_id"` ValidatorMsg CanonicalJSONValidatorMsg `json:"validator_msg"` }
----------------------------- author@liaoyd
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 uint64 `json:"height"` POLBlockID CanonicalJSONBlockID `json:"pol_block_id"` POLRound int `json:"pol_round"` Round int `json:"round"` Hash []byte `json:"hash"` }
func CanonicalProposal ¶
func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal
type CanonicalJSONSignAggr ¶
type CanonicalJSONSignAggr struct { Height uint64 `json:"height"` Round int `json:"round"` Type byte `json:"type"` NumValidators int `json:"NumValidators"` BlockID CanonicalJSONBlockID `json:"block_id"` Maj23 CanonicalJSONBlockID `json:"maj23"` Sum int64 `json:"sum"` }
func CanonicalSignAggr ¶
func CanonicalSignAggr(signAggr *SignAggr) CanonicalJSONSignAggr
type CanonicalJSONVote ¶
type CanonicalJSONVote struct { BlockID CanonicalJSONBlockID `json:"block_id"` Height uint64 `json:"height"` Round uint64 `json:"round"` Type byte `json:"type"` }
func CanonicalVote ¶
func CanonicalVote(vote *Vote) CanonicalJSONVote
type Commit ¶
type Commit struct { // NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order. // Any peer with a block can gossip precommits by index with a peer without recalculating the // active ValidatorSet. BlockID BlockID `json:"blockID"` Height uint64 `json:"height"` Round int `json:"round"` // BLS signature aggregation to be added here SignAggr crypto.BLSSignature `json:"SignAggr"` BitArray *BitArray // contains filtered or unexported fields }
NOTE: Commit is empty for height 1, but never nil.
func (*Commit) NumCommits ¶
func (*Commit) StringIndented ¶
func (*Commit) ValidateBasic ¶
type CommitApi ¶
type CommitApi struct { BlockID BlockIDApi `json:"blockID"` Height hexutil.Uint64 `json:"height"` Round int `json:"round"` // BLS signature aggregation to be added here SignAggr crypto.BLSSignature `json:"signAggr"` BitArray *BitArray `json:"bitArray"` }
type ConsensusAggr ¶
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 EpochApi ¶
type EpochApi struct { Number hexutil.Uint64 `json:"number"` RewardPerBlock *hexutil.Big `json:"rewardPerBlock"` StartBlock hexutil.Uint64 `json:"startBlock"` EndBlock hexutil.Uint64 `json:"endBlock"` StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endEime"` Validators []*EpochValidator `json:"validators"` }
type EpochApiForConsole ¶
type EpochApiForConsole struct { Number hexutil.Uint64 `json:"number"` RewardPerBlock *hexutil.Big `json:"rewardPerBlock"` StartBlock hexutil.Uint64 `json:"startBlock"` EndBlock hexutil.Uint64 `json:"endBlock"` StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endTime"` Validators []*EpochValidatorForConsole `json:"validators"` }
For console
type EpochValidator ¶
type EpochValidatorForConsole ¶
type EpochValidatorForConsole struct { Address string `json:"address"` PubKey string `json:"publicKey"` Amount *hexutil.Big `json:"votingPower"` RemainingEpoch hexutil.Uint64 `json:"remainEpoch"` }
For console
type EpochValidatorVoteApi ¶
type EpochVotesApi ¶
type EpochVotesApiForConsole ¶
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 EventDataFinalCommitted ¶
type EventDataFinalCommitted struct {
BlockNumber uint64
}
FinalCommittedEvent is posted when a proposal is committed
func (EventDataFinalCommitted) AssertIsTMEventData ¶
func (_ EventDataFinalCommitted) AssertIsTMEventData()
type EventDataMessage ¶
type EventDataMessage struct {
Payload []byte `json:"payload"`
}
EventDataMessage is posted for Istanbul engine communication
func (EventDataMessage) AssertIsTMEventData ¶
func (_ EventDataMessage) AssertIsTMEventData()
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *TdmBlock `json:"block"`
}
func (EventDataNewBlock) AssertIsTMEventData ¶
func (_ EventDataNewBlock) AssertIsTMEventData()
type EventDataNewBlockHeader ¶
type EventDataNewBlockHeader struct {
Height int `json:"height"`
}
light weight event for benchmarking
func (EventDataNewBlockHeader) AssertIsTMEventData ¶
func (_ EventDataNewBlockHeader) AssertIsTMEventData()
type EventDataRequest ¶
EventDataRequest is posted to propose a proposal
func (EventDataRequest) AssertIsTMEventData ¶
func (_ EventDataRequest) AssertIsTMEventData()
type EventDataRoundState ¶
type EventDataRoundState struct { Height uint64 `json:"height"` Round int `json:"round"` Step string `json:"step"` // private, not exposed to websockets RoundState interface{} `json:"-"` }
NOTE: This goes into the replay WAL
func (EventDataRoundState) AssertIsTMEventData ¶
func (_ EventDataRoundState) AssertIsTMEventData()
type EventDataSignAggr ¶
type EventDataSignAggr struct {
SignAggr *SignAggr
}
func (EventDataSignAggr) AssertIsTMEventData ¶
func (_ EventDataSignAggr) AssertIsTMEventData()
type EventDataTx ¶
type EventDataTx struct { Height int `json:"height"` Tx Tx `json:"tx"` Data []byte `json:"data"` Log string `json:"log"` 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 EventDataVote2Proposer ¶
func (EventDataVote2Proposer) AssertIsTMEventData ¶
func (_ EventDataVote2Proposer) AssertIsTMEventData()
type EventSwitch ¶
type EventSwitch interface { events.EventSwitch }
func NewEventSwitch ¶
func NewEventSwitch() EventSwitch
type Eventable ¶
type Eventable interface {
SetEventSwitch(EventSwitch)
}
type ForbiddenApi ¶
type ForbiddenApi struct {
ForbiddenList []string `json:"forbiddenList"`
}
type GenesisDoc ¶
type GenesisDoc struct { ChainID string `json:"chain_id"` Consensus string `json:"consensus"` //should be 'pos' or 'pow' GenesisTime time.Time `json:"genesis_time"` RewardScheme RewardSchemeDoc `json:"reward_scheme"` CurrentEpoch OneEpochDoc `json:"current_epoch"` }
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (genDoc *GenesisDoc, err error)
读取 genesisdocjson,并做转换
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
Utility method for saving GenensisDoc as JSON file.
func (genDoc *GenesisDoc) SaveAs(file string) error { genDocBytes, err := json.MarshalIndent(genDoc, "", "\t") if err != nil { fmt.Println(err) } return WriteFile(file, genDocBytes, 0644) }
写入文件使用
type GenesisDocWrite ¶
type GenesisDocWrite struct { ChainID string `json:"chain_id"` Consensus string `json:"consensus"` //should be 'pos' or 'pow' GenesisTime time.Time `json:"genesis_time"` RewardScheme RewardSchemeDoc `json:"reward_scheme"` CurrentEpoch OneEpochDocWrite `json:"current_epoch"` }
写入文件使用
type GenesisValidator ¶
type GenesisValidator struct { EthAccount common.Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` Amount *big.Int `json:"amount"` Name string `json:"name"` RemainingEpoch uint64 `json:"epoch"` }
func (GenesisValidator) MarshalJSON ¶
func (gv GenesisValidator) MarshalJSON() ([]byte, error)
func (*GenesisValidator) UnmarshalJSON ¶
func (gv *GenesisValidator) UnmarshalJSON(input []byte) error
type GenesisValidatorWrite ¶
type GenesisValidatorWrite struct { EthAccount string `json:"address"` PubKey crypto.PubKey `json:"pub_key"` Amount *big.Int `json:"amount"` Name string `json:"name"` RemainingEpoch uint64 `json:"epoch"` }
写入文件使用
func (GenesisValidatorWrite) MarshalJSON ¶
func (gv GenesisValidatorWrite) MarshalJSON() ([]byte, error)
写入文件中间转换
func (*GenesisValidatorWrite) UnmarshalJSON ¶
func (gv *GenesisValidatorWrite) UnmarshalJSON(input []byte) error
写入文件中间转换
type IntermediateBlockResult ¶
type IntermediateBlockResult struct { Block *types.Block // followed by block execute result State *state.StateDB Receipts types.Receipts Ops *types.PendingOps }
IntermediateBlockResult represents intermediate block execute result.
type OneEpochDoc ¶
type OneEpochDoc struct { Number uint64 `json:"number"` RewardPerBlock *big.Int `json:"reward_per_block"` StartBlock uint64 `json:"start_block"` EndBlock uint64 `json:"end_block"` Status int `json:"status"` Validators []GenesisValidator `json:"validators"` }
func (OneEpochDoc) MarshalJSON ¶
func (ep OneEpochDoc) MarshalJSON() ([]byte, error)
func (*OneEpochDoc) UnmarshalJSON ¶
func (ep *OneEpochDoc) UnmarshalJSON(input []byte) error
type OneEpochDocWrite ¶
type OneEpochDocWrite struct { Number uint64 `json:"number"` RewardPerBlock *big.Int `json:"reward_per_block"` StartBlock uint64 `json:"start_block"` EndBlock uint64 `json:"end_block"` Status int `json:"status"` Validators []GenesisValidatorWrite `json:"validators"` }
写入文件使用
func (OneEpochDocWrite) MarshalJSON ¶
func (ep OneEpochDocWrite) MarshalJSON() ([]byte, error)
写入文件中间转换
func (*OneEpochDocWrite) UnmarshalJSON ¶
func (ep *OneEpochDocWrite) UnmarshalJSON(input []byte) error
写入文件中间转换
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 PartSetHeaderApi ¶
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type PrivV ¶
type PrivV struct { Address string `json:"address"` PubKey crypto.PubKey `json:"consensus_pub_key"` PrivKey crypto.PrivKey `json:"consensus_priv_key"` Signer `json:"-"` // contains filtered or unexported fields }
修改 privalidator 的地址类型为string
type PrivValidator ¶
type PrivValidator struct { // NeatChain Account Address Address common.Address `json:"address"` // NeatChain Consensus Public Key, in BLS format PubKey crypto.PubKey `json:"consensus_pub_key"` // NeatChain Consensus Private Key, in BLS format // PrivKey should be empty if a Signer other than the default is being used. PrivKey crypto.PrivKey `json:"consensus_priv_key"` Signer `json:"-"` // contains filtered or unexported fields }
func GenPrivValidatorKey ¶
func GenPrivValidatorKey(address common.Address) *PrivValidator
func LoadPrivValidator ¶
func LoadPrivValidator(filePath string) *PrivValidator
修改加载文件的方法,兼容string 的地址类型
func (*PrivValidator) GetAddress ¶
func (pv *PrivValidator) GetAddress() []byte
func (*PrivValidator) GetPubKey ¶
func (pv *PrivValidator) GetPubKey() crypto.PubKey
func (*PrivValidator) Save ¶
func (pv *PrivValidator) Save()
func (*PrivValidator) SetFile ¶
func (pv *PrivValidator) SetFile(filePath string)
func (*PrivValidator) SignProposal ¶
func (pv *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
func (*PrivValidator) SignVote ¶
func (pv *PrivValidator) SignVote(chainID string, vote *Vote) error
func (*PrivValidator) String ¶
func (pv *PrivValidator) String() string
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []*PrivValidator
func (PrivValidatorsByAddress) Len ¶
func (pvs PrivValidatorsByAddress) Len() int
func (PrivValidatorsByAddress) Less ¶
func (pvs PrivValidatorsByAddress) Less(i, j int) bool
func (PrivValidatorsByAddress) Swap ¶
func (pvs PrivValidatorsByAddress) Swap(i, j int)
type Proposal ¶
type Proposal struct { NodeID string `json:"node_id"` Height uint64 `json:"height"` Round int `json:"round"` Hash []byte `json:"hash"` BlockPartsHeader PartSetHeader `json:"block_parts_header"` POLRound int `json:"pol_round"` // -1 if null. POLBlockID BlockID `json:"pol_block_id"` // zero if null. ProposerNetAddr string `json:"proposer_net_addr"` ProposerPeerKey string `json:"proposer_peer_key"` Signature crypto.Signature `json:"signature"` }
func NewProposal ¶
func NewProposal(height uint64, round int, hash []byte, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID, peerKey string) *Proposal
polRound: -1 if no polRound.
func (*Proposal) BlockHeaderHash ¶
type RefundValidatorAmount ¶
type RewardSchemeDoc ¶
type RewardSchemeDoc struct { TotalReward *big.Int `json:"total_reward"` RewardFirstYear *big.Int `json:"reward_first_year"` EpochNumberPerYear uint64 `json:"epoch_no_per_year"` TotalYear uint64 `json:"total_year"` }
func (RewardSchemeDoc) MarshalJSON ¶
func (rs RewardSchemeDoc) MarshalJSON() ([]byte, error)
func (*RewardSchemeDoc) UnmarshalJSON ¶
func (rs *RewardSchemeDoc) UnmarshalJSON(input []byte) error
type SignAggr ¶
type SignAggr struct { ChainID string Height uint64 `json:"height"` Round int `json:"round"` Type byte `json:"type"` NumValidators int `json:"numValidators"` BlockID BlockID `json:"blockid"` Maj23 BlockID `json:"maj23"` BitArray *BitArray `json:"bitarray"` Sum int64 `json:"sum"` // BLS signature aggregation to be added here SignatureAggr crypto.BLSSignature `json:"SignatureAggr"` SignBytes []byte `json:"sign_bytes"` }
func MakeSignAggr ¶
func (*SignAggr) HasAll ¶
func (sa *SignAggr) HasAll(valSet *ValidatorSet) bool
func (*SignAggr) HasTwoThirdsMajority ¶
func (sa *SignAggr) HasTwoThirdsMajority(valSet *ValidatorSet) bool
func (*SignAggr) MakeCommit ¶
func (*SignAggr) SetBitArray ¶
func (sa *SignAggr) SetBitArray(newBitArray *BitArray)
func (*SignAggr) SignAggrVerify ¶
func (sa *SignAggr) SignAggrVerify(msg []byte, valSet *ValidatorSet) bool
func (*SignAggr) StringIndented ¶
func (*SignAggr) StringShort ¶
func (*SignAggr) TwoThirdsMajority ¶
Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).
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 SwitchEpochOp ¶
type SwitchEpochOp struct { ChainId string NewValidators *ValidatorSet }
SwitchEpoch op
func (*SwitchEpochOp) String ¶
func (op *SwitchEpochOp) String() string
type TMEventData ¶
type TMEventData interface {
events.EventData
AssertIsTMEventData()
}
implements events.EventData
type TdmBlock ¶
type TdmBlock struct { Block *types.Block `json:"block"` TdmExtra *TendermintExtra `json:"tdmexdata"` TX3ProofData []*types.TX3ProofData `json:"tx3proofdata"` IntermediateResult *IntermediateBlockResult `json:"-"` }
func (*TdmBlock) FillSeenCommitHash ¶
func (b *TdmBlock) FillSeenCommitHash()
func (*TdmBlock) Hash ¶
Computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*TdmBlock) HashesTo ¶
Convenience. A nil block never hashes to anything. Nothing hashes to a nil hash.
func (*TdmBlock) MakePartSet ¶
func (*TdmBlock) StringIndented ¶
func (*TdmBlock) StringShort ¶
func (*TdmBlock) ValidateBasic ¶
func (b *TdmBlock) ValidateBasic(tdmExtra *TendermintExtra) error
Basic validation that doesn't involve state data.
type TendermintExtra ¶
type TendermintExtra struct { ChainID string `json:"chain_id"` Height uint64 `json:"height"` Time time.Time `json:"time"` NeedToSave bool `json:"need_to_save"` NeedToBroadcast bool `json:"need_to_broadcast"` EpochNumber uint64 `json:"epoch_number"` SeenCommitHash []byte `json:"last_commit_hash"` // commit from validators from the last block ValidatorsHash []byte `json:"validators_hash"` // validators for the current block SeenCommit *Commit `json:"seen_commit"` EpochBytes []byte `json:"epoch_bytes"` }
func DecodeExtraData ¶
func DecodeExtraData(extra string) (tdmExtra *TendermintExtra, err error)
func ExtractTendermintExtra ¶
func ExtractTendermintExtra(h *ethTypes.Header) (*TendermintExtra, error)
ExtractTendermintExtra extracts all values of the TendermintExtra from the header. It returns an error if the length of the given extra-data is less than 32 bytes or the extra-data can not be decoded.
func (*TendermintExtra) Copy ¶
func (te *TendermintExtra) Copy() *TendermintExtra
be careful, here not deep copy because just reference to SeenCommit
func (*TendermintExtra) Hash ¶
func (te *TendermintExtra) Hash() []byte
NOTE: hash is nil if required fields are missing.
func (*TendermintExtra) String ¶
func (te *TendermintExtra) String() string
type TendermintExtraApi ¶
type TendermintExtraApi struct { ChainID string `json:"chainId"` Height hexutil.Uint64 `json:"height"` Time time.Time `json:"time"` NeedToSave bool `json:"needToSave"` NeedToBroadcast bool `json:"needToBroadcast"` EpochNumber hexutil.Uint64 `json:"epochNumber"` SeenCommitHash string `json:"lastCommitHash"` // commit from validators from the last block ValidatorsHash string `json:"validatorsHash"` // validators for the current block SeenCommit *CommitApi `json:"seenCommit"` EpochBytes []byte `json:"epochBytes"` }
type Txs ¶
type Txs []Tx
func (Txs) IndexByHash ¶
Index returns the index of this transaction hash in the list, or -1 if not found
type Validator ¶
type Validator struct { Address []byte `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower *big.Int `json:"voting_power"` RemainingEpoch uint64 `json:"remain_epoch"` }
Volatile state for each Validator TODO: make non-volatile identity
func NewValidator ¶
type ValidatorSet ¶
type ValidatorSet struct { // NOTE: persisted via reflect, must be exported. Validators []*Validator `json:"validators"` // contains filtered or unexported fields }
ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety. TODO: consider validator Accum overflow 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) AggrPubKey ¶
func (valSet *ValidatorSet) AggrPubKey(bitMap *cmn.BitArray) crypto.PubKey
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
func (*ValidatorSet) Equals ¶
func (valSet *ValidatorSet) Equals(other *ValidatorSet) bool
func (*ValidatorSet) GetAggrPubKeyAndAddress ¶
func (valSet *ValidatorSet) GetAggrPubKeyAndAddress(bitMap *cmn.BitArray) (*ConsensusAggr, error)
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
HasAddress returns true if address given is in the validator set, false - otherwise.
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
func (*ValidatorSet) Iterate ¶
func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() int
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
func (*ValidatorSet) TalliedVotingPower ¶
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() *big.Int
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
func (*ValidatorSet) VerifyCommit ¶
func (valSet *ValidatorSet) VerifyCommit(chainID string, height uint64, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes
func (*ValidatorSet) VerifyCommitAny ¶
func (valSet *ValidatorSet) VerifyCommitAny(chainID string, blockID BlockID, height int, commit *Commit) error
Verify that +2/3 of this set had signed the given signBytes. Unlike VerifyCommit(), this function can verify commits with differeent sets.
type ValidatorStatus ¶
type ValidatorStatus struct {
IsForbidden bool `json:"isForbidden"`
}
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 uint64 `json:"validator_index"` Height uint64 `json:"height"` Round uint64 `json:"round"` Type byte `json:"type"` BlockID BlockID `json:"block_id"` // zero if vote is nil. Signature crypto.Signature `json:"signature"` SignBytes []byte `json:"sign_bytes"` }
Represents a prevote, precommit, or commit vote from validators for consensus.
func (*Vote) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the istanbul fields from a RLP stream.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
func NewVoteSet ¶
func NewVoteSet(chainID string, height uint64, round int, 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) HasTwoThirdsMajority ¶
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).