Documentation ¶
Index ¶
- Constants
- Variables
- func EventStringAccCall(addr []byte) string
- func EventStringAccInput(addr []byte) string
- func EventStringAccOutput(addr []byte) string
- func EventStringBond() string
- func EventStringCompleteProposal() string
- func EventStringDupeout() string
- func EventStringFork() string
- func EventStringLock() string
- func EventStringLogEvent(addr []byte) string
- func EventStringNameReg(name string) string
- func EventStringNewBlock() string
- func EventStringNewRound() string
- func EventStringPermissions(name string) string
- func EventStringPolka() string
- func EventStringRebond() string
- func EventStringRelock() string
- func EventStringTimeoutPropose() string
- func EventStringTimeoutWait() string
- func EventStringUnbond() string
- func EventStringUnlock() string
- func EventStringVote() string
- func NameBaseCost(name, data string) int64
- func NameCostPerBlock(baseCost int64) int64
- func NewContractAddress(caller []byte, nonce int) []byte
- func RandValidator(randBonded bool, minBonded int64) (*ValidatorInfo, *Validator, *PrivValidator)
- func TxID(chainID string, tx Tx) []byte
- func ValidatorInfoDecoder(r io.Reader, n *int64, err *error) interface{}
- func ValidatorInfoEncoder(o interface{}, w io.Writer, n *int64, err *error)
- type AccountGetter
- type Block
- func (b *Block) FillHeader()
- func (b *Block) Hash() []byte
- func (b *Block) HashesTo(hash []byte) bool
- func (b *Block) MakePartSet() *PartSet
- func (b *Block) String() string
- func (b *Block) StringIndented(indent string) string
- func (b *Block) StringShort() string
- func (b *Block) ValidateBasic(chainID string, lastBlockHeight int, lastBlockHash []byte, ...) error
- type BlockMeta
- type BondTx
- func (tx *BondTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error
- func (tx *BondTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error
- func (tx *BondTx) AddOutput(addr []byte, amt int64) error
- func (tx *BondTx) SignBond(chainID string, privAccount *acm.PrivAccount) error
- func (tx *BondTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error
- func (tx *BondTx) String() string
- func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error)
- type CallData
- type CallTx
- type Data
- type DupeoutTx
- type ErrTxInvalidSequence
- type ErrTxInvalidString
- type ErrVoteConflictingSignature
- type EventData
- type EventDataCall
- type EventDataLog
- type EventDataNewBlock
- type EventDataRoundState
- type EventDataTx
- type EventDataVote
- type Header
- type NameRegEntry
- type NameTx
- type NodeInfo
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part) (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 PermissionsTx
- type PrivValidator
- func (privVal *PrivValidator) Save()
- func (privVal *PrivValidator) SetFile(filePath string)
- func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
- func (privVal *PrivValidator) SignRebondTx(chainID string, rebondTx *RebondTx) error
- func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
- func (privVal *PrivValidator) SignVoteUnsafe(chainID string, vote *Vote)
- func (privVal *PrivValidator) String() string
- type PrivValidatorsByAddress
- type Proposal
- type RebondTx
- type SendTx
- func (tx *SendTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error
- func (tx *SendTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error
- func (tx *SendTx) AddOutput(addr []byte, amt int64) error
- func (tx *SendTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error
- func (tx *SendTx) String() string
- func (tx *SendTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error)
- type Tx
- type TxInput
- type TxOutput
- type UnbondTx
- type Validation
- func (v *Validation) BitArray() *BitArray
- func (v *Validation) FirstPrecommit() *Vote
- func (v *Validation) GetByIndex(index int) *Vote
- func (v *Validation) Hash() []byte
- func (v *Validation) Height() int
- func (v *Validation) IsCommit() bool
- func (v *Validation) Round() int
- func (v *Validation) Size() int
- func (v *Validation) StringIndented(indent string) string
- func (v *Validation) Type() byte
- func (v *Validation) ValidateBasic() error
- type Validator
- type ValidatorInfo
- 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 int)
- func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (valSet *ValidatorSet) Proposer() (proposer *Validator)
- func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
- func (valSet *ValidatorSet) Size() int
- func (valSet *ValidatorSet) String() string
- func (valSet *ValidatorSet) StringIndented(indent string) string
- func (valSet *ValidatorSet) TotalVotingPower() int64
- func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
- func (valSet *ValidatorSet) VerifyValidation(chainID string, hash []byte, parts PartSetHeader, height int, v *Validation) error
- type ValidatorsByAddress
- type Versions
- type Vote
- type VoteSet
- func (voteSet *VoteSet) AddByAddress(address []byte, vote *Vote) (added bool, index int, err error)
- func (voteSet *VoteSet) AddByIndex(valIndex int, vote *Vote) (added bool, address []byte, err error)
- func (voteSet *VoteSet) BitArray() *BitArray
- func (voteSet *VoteSet) GetByAddress(address []byte) *Vote
- func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() int
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeValidation() *Validation
- func (voteSet *VoteSet) Round() int
- 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() (hash []byte, parts PartSetHeader, ok bool)
- func (voteSet *VoteSet) Type() byte
- type VoteSetReader
Constants ¶
const ( EventDataTypeNewBlock = byte(0x01) EventDataTypeFork = byte(0x02) EventDataTypeTx = byte(0x03) EventDataTypeCall = byte(0x04) EventDataTypeLog = byte(0x05) EventDataTypeRoundState = byte(0x11) EventDataTypeVote = byte(0x12) )
const ( // Account transactions TxTypeSend = byte(0x01) TxTypeCall = byte(0x02) TxTypeName = byte(0x03) // Validation transactions TxTypeBond = byte(0x11) TxTypeUnbond = byte(0x12) TxTypeRebond = byte(0x13) TxTypeDupeout = byte(0x14) // Admin transactions TxTypePermissions = byte(0x20) )
Types of Tx implementations
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes
Variables ¶
var ( PeerStateKey = "ConsensusReactor.peerState" PeerMempoolChKey = "MempoolReactor.peerMempoolCh" )
var ( MinNameRegistrationPeriod int = 5 // cost for storing a name for a block is // CostPerBlock*CostPerByte*(len(data) + 32) NameByteCostMultiplier int64 = 1 NameBlockCostMultiplier int64 = 1 MaxNameLength = 64 MaxDataLength = 1 << 16 )
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 ( ErrTxInvalidAddress = errors.New("Error invalid address") ErrTxDuplicateAddress = errors.New("Error duplicate address") ErrTxInvalidAmount = errors.New("Error invalid amount") ErrTxInsufficientFunds = errors.New("Error insufficient funds") ErrTxInsufficientGasPrice = errors.New("Error insufficient gas price") ErrTxUnknownPubKey = errors.New("Error unknown pubkey") ErrTxInvalidPubKey = errors.New("Error invalid pubkey") ErrTxInvalidSignature = errors.New("Error invalid signature") ErrTxPermissionDenied = errors.New("Error permission denied") )
var ( ErrVoteUnexpectedStep = errors.New("Unexpected step") ErrVoteInvalidAccount = errors.New("Invalid round vote account") ErrVoteInvalidSignature = errors.New("Invalid round vote signature") ErrVoteInvalidBlockHash = errors.New("Invalid block hash") )
var ValidatorCodec = validatorCodec{}
var ValidatorInfoCodec = wire.Codec{ Encode: ValidatorInfoEncoder, Decode: ValidatorInfoDecoder, }
Functions ¶
func EventStringAccCall ¶
func EventStringAccInput ¶
func EventStringAccOutput ¶
func EventStringBond ¶
func EventStringBond() string
func EventStringCompleteProposal ¶
func EventStringCompleteProposal() string
func EventStringDupeout ¶
func EventStringDupeout() string
func EventStringFork ¶
func EventStringFork() string
func EventStringLock ¶
func EventStringLock() string
func EventStringLogEvent ¶
func EventStringNameReg ¶
func EventStringNewBlock ¶
func EventStringNewBlock() string
func EventStringNewRound ¶
func EventStringNewRound() string
func EventStringPermissions ¶
func EventStringPolka ¶
func EventStringPolka() string
func EventStringRebond ¶
func EventStringRebond() string
func EventStringRelock ¶
func EventStringRelock() string
func EventStringTimeoutPropose ¶
func EventStringTimeoutPropose() string
func EventStringTimeoutWait ¶
func EventStringTimeoutWait() string
func EventStringUnbond ¶
func EventStringUnbond() string
func EventStringUnlock ¶
func EventStringUnlock() string
func EventStringVote ¶
func EventStringVote() string
func NameBaseCost ¶
base cost is "effective" number of bytes
func NameCostPerBlock ¶
func NewContractAddress ¶
func RandValidator ¶
func RandValidator(randBonded bool, minBonded int64) (*ValidatorInfo, *Validator, *PrivValidator)
func ValidatorInfoDecoder ¶
Types ¶
type AccountGetter ¶
type Block ¶
type Block struct { *Header `json:"header"` *Data `json:"data"` LastValidation *Validation `json:"last_validation"` }
func (*Block) FillHeader ¶
func (b *Block) FillHeader()
func (*Block) Hash ¶
Computes and returns the block hash. If the block is incomplete (e.g. missing Header.StateHash) then the hash is nil, to prevent the usage of that hash.
func (*Block) HashesTo ¶
Convenience. A nil block never hashes to anything. Nothing hashes to a nil hash.
func (*Block) MakePartSet ¶
func (*Block) StringIndented ¶
func (*Block) StringShort ¶
func (*Block) ValidateBasic ¶
func (b *Block) ValidateBasic(chainID string, lastBlockHeight int, lastBlockHash []byte, lastBlockParts PartSetHeader, lastBlockTime time.Time) error
Basic validation that doesn't involve state data.
type BlockMeta ¶
type BlockMeta struct { Hash []byte `json:"hash"` // The block hash Header *Header `json:"header"` // The block's Header PartsHeader PartSetHeader `json:"parts_header"` // The PartSetHeader, for transfer }
func NewBlockMeta ¶
type BondTx ¶
type BondTx struct { PubKey acm.PubKeyEd25519 `json:"pub_key"` Signature acm.SignatureEd25519 `json:"signature"` Inputs []*TxInput `json:"inputs"` UnbondTo []*TxOutput `json:"unbond_to"` }
func (*BondTx) AddInputWithNonce ¶
func (*BondTx) SignBond ¶
func (tx *BondTx) SignBond(chainID string, privAccount *acm.PrivAccount) error
type CallTx ¶
type CallTx struct { Input *TxInput `json:"input"` Address []byte `json:"address"` GasLimit int64 `json:"gas_limit"` Fee int64 `json:"fee"` Data []byte `json:"data"` }
func NewCallTxWithNonce ¶
type Data ¶
type Data struct { Txs []Tx `json:"txs"` // contains filtered or unexported fields }
func (*Data) StringIndented ¶
type DupeoutTx ¶
type ErrTxInvalidSequence ¶
func (ErrTxInvalidSequence) Error ¶
func (e ErrTxInvalidSequence) Error() string
type ErrTxInvalidString ¶
type ErrTxInvalidString struct {
Msg string
}
func (ErrTxInvalidString) Error ¶
func (e ErrTxInvalidString) Error() string
type ErrVoteConflictingSignature ¶
func (*ErrVoteConflictingSignature) Error ¶
func (err *ErrVoteConflictingSignature) Error() string
type EventDataCall ¶
type EventDataCall struct { CallData *CallData `json:"call_data"` Origin []byte `json:"origin"` TxID []byte `json:"tx_id"` Return []byte `json:"return"` Exception string `json:"exception"` }
EventDataCall fires when we call a contract, and when a contract calls another contract
func (EventDataCall) AssertIsEventData ¶
func (_ EventDataCall) AssertIsEventData()
type EventDataLog ¶
type EventDataLog struct { Address Word256 `json:"address"` Topics []Word256 `json:"topics"` Data []byte `json:"data"` Height int64 `json:"height"` }
EventDataLog fires when a contract executes the LOG opcode
func (EventDataLog) AssertIsEventData ¶
func (_ EventDataLog) AssertIsEventData()
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *Block `json:"block"`
}
func (EventDataNewBlock) AssertIsEventData ¶
func (_ EventDataNewBlock) AssertIsEventData()
type EventDataRoundState ¶
type EventDataRoundState struct { CurrentTime time.Time `json:"current_time"` Height int `json:"height"` Round int `json:"round"` Step string `json:"step"` StartTime time.Time `json:"start_time"` CommitTime time.Time `json:"commit_time"` Proposal *Proposal `json:"proposal"` ProposalBlock *Block `json:"proposal_block"` LockedRound int `json:"locked_round"` LockedBlock *Block `json:"locked_block"` POLRound int `json:"pol_round"` }
We fire the most recent round state that led to the event (ie. NewRound will have the previous rounds state)
func (EventDataRoundState) AssertIsEventData ¶
func (_ EventDataRoundState) AssertIsEventData()
type EventDataTx ¶
type EventDataTx struct { Tx Tx `json:"tx"` Return []byte `json:"return"` Exception string `json:"exception"` }
All txs fire EventDataTx, but only CallTx might have Return or Exception
func (EventDataTx) AssertIsEventData ¶
func (_ EventDataTx) AssertIsEventData()
type EventDataVote ¶
func (EventDataVote) AssertIsEventData ¶
func (_ EventDataVote) AssertIsEventData()
type Header ¶
type Header struct { ChainID string `json:"chain_id"` Height int `json:"height"` Time time.Time `json:"time"` Fees int64 `json:"fees"` NumTxs int `json:"num_txs"` LastBlockHash []byte `json:"last_block_hash"` LastBlockParts PartSetHeader `json:"last_block_parts"` LastValidationHash []byte `json:"last_validation_hash"` DataHash []byte `json:"data_hash"` StateHash []byte `json:"state_hash"` }
func (*Header) StringIndented ¶
type NameRegEntry ¶
type NameRegEntry struct { Name string `json:"name"` // registered name for the entry Owner []byte `json:"owner"` // address that created the entry Data string `json:"data"` // data to store under this name Expires int `json:"expires"` // block at which this entry expires }
func (*NameRegEntry) Copy ¶
func (entry *NameRegEntry) Copy() *NameRegEntry
type NameTx ¶
type NameTx struct { Input *TxInput `json:"input"` Name string `json:"name"` Data string `json:"data"` Fee int64 `json:"fee"` }
func NewNameTxWithNonce ¶
func (*NameTx) ValidateStrings ¶
type NodeInfo ¶
type NodeInfo struct { PubKey acm.PubKeyEd25519 `json:"pub_key"` Moniker string `json:"moniker"` ChainID string `json:"chain_id"` Host string `json:"host"` P2PPort uint16 `json:"p2p_port"` RPCPort uint16 `json:"rpc_port"` Version Versions `json:"versions"` }
func (*NodeInfo) CompatibleWith ¶
CONTRACT: two nodes with the same Tendermint major and minor version and with the same ChainID are compatible
type Part ¶
type Part struct { Proof merkle.SimpleProof `json:"proof"` Bytes []byte `json:"bytes"` // 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 *int64, err *error)
type PermissionsTx ¶
func NewPermissionsTx ¶
func NewPermissionsTx(st AccountGetter, from acm.PubKey, args ptypes.PermArgs) (*PermissionsTx, error)
func (*PermissionsTx) Sign ¶
func (tx *PermissionsTx) Sign(chainID string, privAccount *acm.PrivAccount)
func (*PermissionsTx) String ¶
func (tx *PermissionsTx) String() string
func (*PermissionsTx) WriteSignBytes ¶
type PrivValidator ¶
type PrivValidator struct { Address []byte `json:"address"` PubKey acm.PubKeyEd25519 `json:"pub_key"` PrivKey acm.PrivKeyEd25519 `json:"priv_key"` LastHeight int `json:"last_height"` LastRound int `json:"last_round"` LastStep int8 `json:"last_step"` // contains filtered or unexported fields }
func GenPrivValidator ¶
func GenPrivValidator() *PrivValidator
Generates a new validator with private key.
func LoadOrGenPrivValidator ¶
func LoadOrGenPrivValidator(filePath string) *PrivValidator
func LoadPrivValidator ¶
func LoadPrivValidator(filePath string) *PrivValidator
func (*PrivValidator) Save ¶
func (privVal *PrivValidator) Save()
func (*PrivValidator) SetFile ¶
func (privVal *PrivValidator) SetFile(filePath string)
func (*PrivValidator) SignProposal ¶
func (privVal *PrivValidator) SignProposal(chainID string, proposal *Proposal) error
func (*PrivValidator) SignRebondTx ¶
func (privVal *PrivValidator) SignRebondTx(chainID string, rebondTx *RebondTx) error
func (*PrivValidator) SignVote ¶
func (privVal *PrivValidator) SignVote(chainID string, vote *Vote) error
func (*PrivValidator) SignVoteUnsafe ¶
func (privVal *PrivValidator) SignVoteUnsafe(chainID string, vote *Vote)
func (*PrivValidator) String ¶
func (privVal *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 { Height int `json:"height"` Round int `json:"round"` BlockPartsHeader PartSetHeader `json:"block_parts_header"` POLRound int `json:"pol_round"` // -1 if null. Signature acm.SignatureEd25519 `json:"signature"` }
func NewProposal ¶
func NewProposal(height int, round int, blockPartsHeader PartSetHeader, polRound int) *Proposal
type RebondTx ¶
type RebondTx struct { Address []byte `json:"address"` Height int `json:"height"` Signature acm.SignatureEd25519 `json:"signature"` }
func NewRebondTx ¶
type SendTx ¶
func (*SendTx) AddInputWithNonce ¶
type TxInput ¶
type TxInput struct { Address []byte `json:"address"` // Hash of the PubKey Amount int64 `json:"amount"` // Must not exceed account balance Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput Signature acm.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx PubKey acm.PubKey `json:"pub_key"` // Must not be nil, may be nil }
func (*TxInput) ValidateBasic ¶
type TxOutput ¶
type TxOutput struct { Address []byte `json:"address"` // Hash of the PubKey Amount int64 `json:"amount"` // The sum of all outputs must not exceed the inputs. }
func (*TxOutput) ValidateBasic ¶
type UnbondTx ¶
type UnbondTx struct { Address []byte `json:"address"` Height int `json:"height"` Signature acm.SignatureEd25519 `json:"signature"` }
func NewUnbondTx ¶
type Validation ¶
type Validation 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. Precommits []*Vote `json:"precommits"` // contains filtered or unexported fields }
NOTE: Validation is empty for height 1, but never nil.
func (*Validation) BitArray ¶
func (v *Validation) BitArray() *BitArray
func (*Validation) FirstPrecommit ¶
func (v *Validation) FirstPrecommit() *Vote
func (*Validation) GetByIndex ¶
func (v *Validation) GetByIndex(index int) *Vote
func (*Validation) Hash ¶
func (v *Validation) Hash() []byte
func (*Validation) Height ¶
func (v *Validation) Height() int
func (*Validation) IsCommit ¶
func (v *Validation) IsCommit() bool
func (*Validation) Round ¶
func (v *Validation) Round() int
func (*Validation) Size ¶
func (v *Validation) Size() int
func (*Validation) StringIndented ¶
func (v *Validation) StringIndented(indent string) string
func (*Validation) Type ¶
func (v *Validation) Type() byte
func (*Validation) ValidateBasic ¶
func (v *Validation) ValidateBasic() error
type Validator ¶
type Validator struct { Address []byte `json:"address"` PubKey acm.PubKeyEd25519 `json:"pub_key"` BondHeight int `json:"bond_height"` UnbondHeight int `json:"unbond_height"` LastCommitHeight int `json:"last_commit_height"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` }
Volatile state for each Validator Also persisted with the state, but fields change every height|round so they don't go in merkle.Tree
func (*Validator) CompareAccum ¶
Returns the one with higher Accum.
type ValidatorInfo ¶
type ValidatorInfo struct { Address []byte `json:"address"` PubKey acm.PubKeyEd25519 `json:"pub_key"` UnbondTo []*TxOutput `json:"unbond_to"` FirstBondHeight int `json:"first_bond_height"` FirstBondAmount int64 `json:"first_bond_amount"` DestroyedHeight int `json:"destroyed_height"` // If destroyed DestroyedAmount int64 `json:"destroyed_amount"` // If destroyed ReleasedHeight int `json:"released_height"` // If released }
Persistent (mostly) static data for each Validator
func (*ValidatorInfo) Copy ¶
func (valInfo *ValidatorInfo) Copy() *ValidatorInfo
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: replace validators []*Validator with github.com/jaekwon/go-ibbs?
func NewValidatorSet ¶
func NewValidatorSet(vals []*Validator) *ValidatorSet
func (*ValidatorSet) Add ¶
func (valSet *ValidatorSet) Add(val *Validator) (added bool)
func (*ValidatorSet) Copy ¶
func (valSet *ValidatorSet) Copy() *ValidatorSet
func (*ValidatorSet) GetByAddress ¶
func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
func (*ValidatorSet) GetByIndex ¶
func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
func (*ValidatorSet) HasAddress ¶
func (valSet *ValidatorSet) HasAddress(address []byte) bool
func (*ValidatorSet) Hash ¶
func (valSet *ValidatorSet) Hash() []byte
func (*ValidatorSet) IncrementAccum ¶
func (valSet *ValidatorSet) IncrementAccum(times 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) Proposer ¶
func (valSet *ValidatorSet) Proposer() (proposer *Validator)
func (*ValidatorSet) Remove ¶
func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
func (*ValidatorSet) Size ¶
func (valSet *ValidatorSet) Size() int
func (*ValidatorSet) String ¶
func (valSet *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (valSet *ValidatorSet) StringIndented(indent string) string
func (*ValidatorSet) TotalVotingPower ¶
func (valSet *ValidatorSet) TotalVotingPower() int64
func (*ValidatorSet) Update ¶
func (valSet *ValidatorSet) Update(val *Validator) (updated bool)
func (*ValidatorSet) VerifyValidation ¶
func (valSet *ValidatorSet) VerifyValidation(chainID string, hash []byte, parts PartSetHeader, height int, v *Validation) error
Verify that +2/3 of the set had signed the given signBytes
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
func (ValidatorsByAddress) Len ¶
func (vs ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (vs ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (vs ValidatorsByAddress) Swap(i, j int)
type Vote ¶
type Vote struct { Height int `json:"height"` Round int `json:"round"` Type byte `json:"type"` BlockHash []byte `json:"block_hash"` // empty if vote is nil. BlockPartsHeader PartSetHeader `json:"block_parts_header"` // zero if vote is nil. Signature acm.SignatureEd25519 `json:"signature"` }
Represents a prevote, precommit, or commit vote from validators for consensus.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet helps collect signatures from validators at each height+round for a predefined vote type. Note that there three kinds of votes: prevotes, precommits, and commits. A commit of prior rounds can be added added in lieu of votes/precommits. NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func NewVoteSet ¶
func NewVoteSet(height int, round int, type_ byte, valSet *ValidatorSet) *VoteSet
Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddByAddress ¶
Returns added=true, index if vote was added Otherwise returns err=ErrVote[UnexpectedStep|InvalidAccount|InvalidSignature|InvalidBlockHash|ConflictingSignature] Duplicate votes return added=false, err=nil. NOTE: vote should not be mutated after adding.
func (*VoteSet) AddByIndex ¶
func (voteSet *VoteSet) AddByIndex(valIndex int, vote *Vote) (added bool, address []byte, err error)
Returns added=true, index if vote was added Otherwise returns err=ErrVote[UnexpectedStep|InvalidAccount|InvalidSignature|InvalidBlockHash|ConflictingSignature] Duplicate votes return added=false, err=nil. NOTE: vote should not be mutated after adding.
func (*VoteSet) GetByAddress ¶
func (*VoteSet) GetByIndex ¶
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeValidation ¶
func (voteSet *VoteSet) MakeValidation() *Validation
func (*VoteSet) StringIndented ¶
func (*VoteSet) StringShort ¶
func (*VoteSet) TwoThirdsMajority ¶
func (voteSet *VoteSet) TwoThirdsMajority() (hash []byte, parts PartSetHeader, ok bool)
Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, false).