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, ...) (*NCBlock, *PartSet)
- func SignBytes(chainID string, o Signable) []byte
- type BannedApi
- 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 GenesisDoc
- type GenesisDocWrite
- type GenesisValidator
- type GenesisValidatorWrite
- type IntermediateBlockResult
- type NCBlock
- func (b *NCBlock) FillSeenCommitHash()
- func (b *NCBlock) FromBytes(reader io.Reader) (*NCBlock, error)
- func (b *NCBlock) Hash() []byte
- func (b *NCBlock) HashesTo(hash []byte) bool
- func (b *NCBlock) MakePartSet(partSize int) *PartSet
- func (b *NCBlock) String() string
- func (b *NCBlock) StringIndented(indent string) string
- func (b *NCBlock) StringShort() string
- func (b *NCBlock) ToBytes() []byte
- func (b *NCBlock) ValidateBasic(ncExtra *TendermintExtra) error
- 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 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
const MaxSignAggrSize = 22020096
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_POS string = "pos"
var CONSENSUS_POW string = "pow"
var CONSENSUS_Tendermint string = "tendermint"
var GenDocKey = []byte("GenDocKey")
var MainnetGenesisJSON string = `` /* 1066-byte string literal not displayed */
var TestnetGenesisJSON string = `` /* 885-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 EventStringBond ¶
func EventStringBond() 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 ¶
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"` }
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 { BlockID BlockID `json:"blockID"` Height uint64 `json:"height"` Round int `json:"round"` SignAggr crypto.BLSSignature `json:"SignAggr"` BitArray *BitArray // contains filtered or unexported fields }
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"` SignAggr crypto.BLSSignature `json:"signAggr"` BitArray *BitArray `json:"bitArray"` }
type ConsensusAggr ¶
type DefaultSigner ¶
type DefaultSigner struct {
// contains filtered or unexported fields
}
func NewDefaultSigner ¶
func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner
func (*DefaultSigner) Sign ¶
func (ds *DefaultSigner) Sign(msg []byte) crypto.Signature
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"` }
type EpochValidator ¶
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
}
func (EventDataFinalCommitted) AssertIsTMEventData ¶
func (_ EventDataFinalCommitted) AssertIsTMEventData()
type EventDataMessage ¶
type EventDataMessage struct {
Payload []byte `json:"payload"`
}
func (EventDataMessage) AssertIsTMEventData ¶
func (_ EventDataMessage) AssertIsTMEventData()
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *NCBlock `json:"block"`
}
func (EventDataNewBlock) AssertIsTMEventData ¶
func (_ EventDataNewBlock) AssertIsTMEventData()
type EventDataNewBlockHeader ¶
type EventDataNewBlockHeader struct {
Height int `json:"height"`
}
func (EventDataNewBlockHeader) AssertIsTMEventData ¶
func (_ EventDataNewBlockHeader) AssertIsTMEventData()
type EventDataRequest ¶
func (EventDataRequest) AssertIsTMEventData ¶
func (_ EventDataRequest) AssertIsTMEventData()
type EventDataRoundState ¶
type EventDataRoundState struct { Height uint64 `json:"height"` Round int `json:"round"` Step string `json:"step"` RoundState interface{} `json:"-"` }
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"` }
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 GenesisDoc ¶
type GenesisDoc struct { ChainID string `json:"chain_id"` Consensus string `json:"consensus"` 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)
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
type GenesisDocWrite ¶
type GenesisDocWrite struct { ChainID string `json:"chain_id"` Consensus string `json:"consensus"` 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 NCBlock ¶
type NCBlock struct { Block *types.Block `json:"block"` NTCExtra *TendermintExtra `json:"ntcexdata"` TX3ProofData []*types.TX3ProofData `json:"tx3proofdata"` IntermediateResult *IntermediateBlockResult `json:"-"` }
func (*NCBlock) FillSeenCommitHash ¶
func (b *NCBlock) FillSeenCommitHash()
func (*NCBlock) MakePartSet ¶
func (*NCBlock) StringIndented ¶
func (*NCBlock) StringShort ¶
func (*NCBlock) ValidateBasic ¶
func (b *NCBlock) ValidateBasic(ncExtra *TendermintExtra) error
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 ¶
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
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 PrivValidator ¶
type PrivValidator struct { Address common.Address `json:"address"` PubKey crypto.PubKey `json:"consensus_pub_key"` 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
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"` POLBlockID BlockID `json:"pol_block_id"` ProposerNetAddr string `json:"proposer_net_addr"` ProposerPeerKey string `json:"proposer_peer_key"` Signature crypto.Signature `json:"signature"` }
func NewProposal ¶
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"` 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 ¶
type SwitchEpochOp ¶
type SwitchEpochOp struct { ChainId string NewValidators *ValidatorSet }
func (*SwitchEpochOp) String ¶
func (op *SwitchEpochOp) String() string
type TMEventData ¶
type TMEventData interface {
events.EventData
AssertIsTMEventData()
}
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"` ValidatorsHash []byte `json:"validators_hash"` SeenCommit *Commit `json:"seen_commit"` EpochBytes []byte `json:"epoch_bytes"` }
func DecodeExtraData ¶
func DecodeExtraData(extra string) (ncExtra *TendermintExtra, err error)
func ExtractTendermintExtra ¶
func ExtractTendermintExtra(h *ligoTypes.Header) (*TendermintExtra, error)
func (*TendermintExtra) Copy ¶
func (te *TendermintExtra) Copy() *TendermintExtra
func (*TendermintExtra) Hash ¶
func (te *TendermintExtra) Hash() []byte
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"` ValidatorsHash string `json:"validatorsHash"` SeenCommit *CommitApi `json:"seenCommit"` EpochBytes []byte `json:"epochBytes"` }
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"` }
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 {
IsBanned bool `json:"isBanned"`
}
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).