Documentation ¶
Index ¶
- Constants
- Variables
- func HeimdallAddressToAccAddress(b HeimdallAddress) sdk.AccAddress
- func KVStorePrefixIteratorPaginated(kvs sdk.KVStore, prefix []byte, page, limit uint) sdk.Iterator
- func KVStorePrefixRangeIteratorPaginated(kvs sdk.KVStore, page, limit uint, from, to []byte) sdk.Iterator
- func KVStoreReversePrefixIteratorPaginated(kvs sdk.KVStore, prefix []byte, page, limit uint) sdk.Iterator
- func MarshallDividendAccount(cdc *codec.Codec, dividendAccount DividendAccount) (bz []byte, err error)
- func MarshallDividendAccountProof(cdc *codec.Codec, dividendAccountProof DividendAccountProof) (bz []byte, err error)
- func MarshallValSigningInfo(cdc *codec.Codec, valSigningInfo ValidatorSigningInfo) (bz []byte, err error)
- func MarshallValSlashingInfo(cdc *codec.Codec, valSlashingInfo ValidatorSlashingInfo) (bz []byte, err error)
- func MarshallValidator(cdc *codec.Codec, validator Validator) (bz []byte, err error)
- func SortSpanByID(a []*Span)
- func ValidatorListString(vals []*Validator) string
- type BaseTx
- type Checkpoint
- type Contract
- type DividendAccount
- type DividendAccountProof
- type HeimdallAddress
- func (aa HeimdallAddress) Bytes() []byte
- func (aa HeimdallAddress) Empty() bool
- func (aa HeimdallAddress) Equals(aa2 sdk.Address) bool
- func (aa HeimdallAddress) EthAddress() common.Address
- func (aa HeimdallAddress) Format(s fmt.State, verb rune)
- func (aa HeimdallAddress) Marshal() ([]byte, error)
- func (aa HeimdallAddress) MarshalJSON() ([]byte, error)
- func (aa HeimdallAddress) MarshalYAML() (interface{}, error)
- func (aa HeimdallAddress) String() string
- func (aa *HeimdallAddress) Unmarshal(data []byte) error
- func (aa *HeimdallAddress) UnmarshalJSON(data []byte) error
- func (aa *HeimdallAddress) UnmarshalYAML(data []byte) error
- type HeimdallHash
- func (aa HeimdallHash) Bytes() []byte
- func (aa HeimdallHash) Empty() bool
- func (aa HeimdallHash) Equals(aa2 HeimdallHash) bool
- func (aa HeimdallHash) EthHash() common.Hash
- func (aa HeimdallHash) Format(s fmt.State, verb rune)
- func (aa HeimdallHash) Hex() string
- func (aa HeimdallHash) Marshal() ([]byte, error)
- func (aa HeimdallHash) MarshalJSON() ([]byte, error)
- func (aa HeimdallHash) MarshalYAML() (interface{}, error)
- func (aa HeimdallHash) String() string
- func (aa *HeimdallHash) Unmarshal(data []byte) error
- func (aa *HeimdallHash) UnmarshalJSON(data []byte) error
- func (aa *HeimdallHash) UnmarshalYAML(data []byte) error
- type HexBytes
- func (bz HexBytes) Bytes() []byte
- func (bz HexBytes) Empty() bool
- func (bz HexBytes) Equals(bz2 HexBytes) bool
- func (bz HexBytes) Format(s fmt.State, verb rune)
- func (bz HexBytes) Marshal() ([]byte, error)
- func (bz HexBytes) MarshalJSON() ([]byte, error)
- func (bz HexBytes) MarshalYAML() (interface{}, error)
- func (bz HexBytes) String() string
- func (bz *HexBytes) Unmarshal(data []byte) error
- func (bz *HexBytes) UnmarshalJSON(data []byte) error
- func (bz *HexBytes) UnmarshalYAML(data []byte) error
- type MinimalVal
- type PaginatedIterator
- type PostTxHandler
- type PubKey
- func (a PubKey) ABCIPubKey() abci.PubKey
- func (a PubKey) Address() common.Address
- func (a PubKey) Bytes() []byte
- func (a PubKey) CryptoPubKey() crypto.PubKey
- func (a PubKey) Marshal() ([]byte, error)
- func (a PubKey) MarshalJSON() ([]byte, error)
- func (a PubKey) MarshalText() ([]byte, error)
- func (a PubKey) MarshalYAML() (interface{}, error)
- func (a PubKey) String() string
- func (a *PubKey) Unmarshal(data []byte) error
- func (a *PubKey) UnmarshalJSON(data []byte) error
- func (a *PubKey) UnmarshalText(input []byte) error
- func (a *PubKey) UnmarshalYAML(data []byte) error
- type QueryPaginationParams
- type SideHandlers
- type SideRouter
- type SideTxHandler
- type SideTxMsg
- type Span
- type Validator
- func (v *Validator) Bytes() []byte
- func (v *Validator) CompareProposerPriority(other *Validator) *Validator
- func (v *Validator) Copy() *Validator
- func (v *Validator) IsCurrentValidator(ackCount uint64) bool
- func (v *Validator) MinimalVal() MinimalVal
- func (v *Validator) String() string
- func (v *Validator) UpdatedAt() string
- func (v *Validator) ValidateBasic() bool
- type ValidatorID
- type ValidatorSet
- func (vals *ValidatorSet) Copy() *ValidatorSet
- func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
- func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
- func (vals *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
- func (vals *ValidatorSet) GetProposer() (proposer *Validator)
- func (vals *ValidatorSet) HasAddress(address []byte) bool
- func (vals *ValidatorSet) Hash() []byte
- func (vals *ValidatorSet) IncrementProposerPriority(times int)
- func (vals *ValidatorSet) IsNilOrEmpty() bool
- func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (vals *ValidatorSet) RescalePriorities(diffMax int64)
- func (vals *ValidatorSet) Size() int
- func (vals *ValidatorSet) String() string
- func (vals *ValidatorSet) StringIndented(indent string) string
- func (vals *ValidatorSet) TotalVotingPower() int64
- func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
- type ValidatorSigningInfo
- type ValidatorSlashingInfo
- type ValidatorsByAddress
Constants ¶
const ( AttributeKeyTxHash = "txhash" AttributeKeyTxLogIndex = "tx-log-index" AttributeKeySideTxResult = "side-tx-result" )
staking module event types
const ( MaxTotalVotingPower = int64(math.MaxInt64) / 8 PriorityWindowSizeFactor = 2 )
const (
// AddrLen defines a valid address length
AddrLen = 20
)
const (
// DefaultLogIndexUnit default tx hash + log index unit
DefaultLogIndexUnit = 100000
)
Variables ¶
var ( // CoinDecimals is the amount of staking tokens required for 1 unit CoinDecimals = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil) )
var ZeroHeimdallAddress = HeimdallAddress{}
ZeroHeimdallAddress represents zero address
var ZeroHeimdallHash = HeimdallHash{}
ZeroHeimdallHash represents zero address
var ZeroPubKey = PubKey{}
ZeroPubKey represents empty pub key
Functions ¶
func HeimdallAddressToAccAddress ¶
func HeimdallAddressToAccAddress(b HeimdallAddress) sdk.AccAddress
HeimdallAddressToAccAddress returns Address with value b.
func KVStorePrefixIteratorPaginated ¶
KVStorePrefixIteratorPaginated returns iterator over items in the selected page. Items iterated and skipped in ascending order.
func KVStorePrefixRangeIteratorPaginated ¶
func KVStorePrefixRangeIteratorPaginated(kvs sdk.KVStore, page, limit uint, from, to []byte) sdk.Iterator
KVStorePrefixRangeIteratorPaginated returns iterator over items in the selected page and queries within a range. Items iterated and skipped in ascending order.
func KVStoreReversePrefixIteratorPaginated ¶
func KVStoreReversePrefixIteratorPaginated(kvs sdk.KVStore, prefix []byte, page, limit uint) sdk.Iterator
KVStoreReversePrefixIteratorPaginated returns iterator over items in the selected page. Items iterated and skipped in descending order.
func MarshallDividendAccount ¶
func MarshallDividendAccount(cdc *codec.Codec, dividendAccount DividendAccount) (bz []byte, err error)
MarshallDividendAccount - amino Marshall DividendAccount
func MarshallDividendAccountProof ¶
func MarshallDividendAccountProof(cdc *codec.Codec, dividendAccountProof DividendAccountProof) (bz []byte, err error)
MarshallDividendAccountProof - amino Marshall DividendAccountProof
func MarshallValSigningInfo ¶
func MarshallValSigningInfo(cdc *codec.Codec, valSigningInfo ValidatorSigningInfo) (bz []byte, err error)
amino marshall validator
func MarshallValSlashingInfo ¶
func MarshallValSlashingInfo(cdc *codec.Codec, valSlashingInfo ValidatorSlashingInfo) (bz []byte, err error)
amino marshall validator slashing info
func MarshallValidator ¶
amino marshall validator
func ValidatorListString ¶
ValidatorListString returns a prettified validator list for logging purposes.
Types ¶
type BaseTx ¶
BaseTx represents base tx tendermint needs
func (BaseTx) ValidateBasic ¶
ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.
type Checkpoint ¶
type Checkpoint struct { Proposer HeimdallAddress `json:"proposer"` StartBlock uint64 `json:"start_block"` EndBlock uint64 `json:"end_block"` RootHash HeimdallHash `json:"root_hash"` BorChainID string `json:"bor_chain_id"` TimeStamp uint64 `json:"timestamp"` }
Checkpoint block header struct
func CreateBlock ¶
func CreateBlock( start uint64, end uint64, rootHash HeimdallHash, proposer HeimdallAddress, borChainID string, timestamp uint64, ) Checkpoint
CreateBlock generate new block
func SortHeaders ¶
func SortHeaders(headers []Checkpoint) []Checkpoint
SortHeaders sorts array of headers on the basis for timestamps
type Contract ¶
type Contract struct {
// contains filtered or unexported fields
}
Contract is how we represent contracts at heimdall
func NewContract ¶
func NewContract(name string, address common.Address, abi abi.ABI, location int, instance bind.ContractBackend) Contract
NewContract creates new contract instance
func (*Contract) Instance ¶
func (c *Contract) Instance() bind.ContractBackend
Instance returns the instance of contract
type DividendAccount ¶
type DividendAccount struct { User HeimdallAddress `json:"user"` FeeAmount string `json:"feeAmount"` // string representation of big.Int }
DividendAccount contains burned Fee amount
func NewDividendAccount ¶
func NewDividendAccount(user HeimdallAddress, fee string) DividendAccount
func SortDividendAccountByAddress ¶
func SortDividendAccountByAddress(dividendAccounts []DividendAccount) []DividendAccount
SortDividendAccountByAddress - Sorts DividendAccounts By Address
func UnMarshallDividendAccount ¶
func UnMarshallDividendAccount(cdc *codec.Codec, value []byte) (DividendAccount, error)
UnMarshallDividendAccount - amino Unmarshall DividendAccount
func (DividendAccount) CalculateHash ¶
func (da DividendAccount) CalculateHash() ([]byte, error)
CalculateHash hashes the values of a DividendAccount
func (DividendAccount) Equals ¶
func (da DividendAccount) Equals(other merkletree.Content) (bool, error)
Equals tests for equality of two Contents
func (*DividendAccount) String ¶
func (da *DividendAccount) String() string
type DividendAccountProof ¶
type DividendAccountProof struct { User HeimdallAddress `json:"user"` Proof HexBytes `json:"accountProof"` Index uint64 `json:"index"` }
DividendAccountProof contains ID, merkle proof, leaf index in merketree
func NewDividendAccountProof ¶
func NewDividendAccountProof(user HeimdallAddress, proof HexBytes, index uint64) DividendAccountProof
NewDividendAccountProof generate proof for new dividend account
func UnMarshallDividendAccountProof ¶
func UnMarshallDividendAccountProof(cdc *codec.Codec, value []byte) (DividendAccountProof, error)
UnMarshallDividendAccountProof - amino Unmarshall DividendAccountProof
func (*DividendAccountProof) String ¶
func (ap *DividendAccountProof) String() string
type HeimdallAddress ¶
HeimdallAddress represents heimdall address
func AccAddressToHeimdallAddress ¶
func AccAddressToHeimdallAddress(b sdk.AccAddress) HeimdallAddress
AccAddressToHeimdallAddress returns Address with value b.
func BytesToHeimdallAddress ¶
func BytesToHeimdallAddress(b []byte) HeimdallAddress
BytesToHeimdallAddress returns Address with value b.
func HexToHeimdallAddress ¶
func HexToHeimdallAddress(b string) HeimdallAddress
HexToHeimdallAddress returns Address with value b.
func SampleHeimdallAddress ¶
func SampleHeimdallAddress(s string) HeimdallAddress
SampleHeimdallAddress returns sample address
func (HeimdallAddress) Bytes ¶
func (aa HeimdallAddress) Bytes() []byte
Bytes returns the raw address bytes.
func (HeimdallAddress) Empty ¶
func (aa HeimdallAddress) Empty() bool
Empty returns boolean for whether an AccAddress is empty
func (HeimdallAddress) Equals ¶
func (aa HeimdallAddress) Equals(aa2 sdk.Address) bool
Equals returns boolean for whether two AccAddresses are Equal
func (HeimdallAddress) EthAddress ¶
func (aa HeimdallAddress) EthAddress() common.Address
EthAddress get eth address
func (HeimdallAddress) Format ¶
func (aa HeimdallAddress) Format(s fmt.State, verb rune)
Format implements the fmt.Formatter interface. nolint: errcheck
func (HeimdallAddress) Marshal ¶
func (aa HeimdallAddress) Marshal() ([]byte, error)
Marshal returns the raw address bytes. It is needed for protobuf compatibility.
func (HeimdallAddress) MarshalJSON ¶
func (aa HeimdallAddress) MarshalJSON() ([]byte, error)
MarshalJSON marshals to JSON using Bech32.
func (HeimdallAddress) MarshalYAML ¶
func (aa HeimdallAddress) MarshalYAML() (interface{}, error)
MarshalYAML marshals to YAML using Bech32.
func (HeimdallAddress) String ¶
func (aa HeimdallAddress) String() string
String implements the Stringer interface.
func (*HeimdallAddress) Unmarshal ¶
func (aa *HeimdallAddress) Unmarshal(data []byte) error
Unmarshal sets the address to the given data. It is needed for protobuf compatibility.
func (*HeimdallAddress) UnmarshalJSON ¶
func (aa *HeimdallAddress) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (*HeimdallAddress) UnmarshalYAML ¶
func (aa *HeimdallAddress) UnmarshalYAML(data []byte) error
UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.
type HeimdallHash ¶
HeimdallHash represents heimdall address
func BytesToHeimdallHash ¶
func BytesToHeimdallHash(b []byte) HeimdallHash
BytesToHeimdallHash returns Address with value b.
func HexToHeimdallHash ¶
func HexToHeimdallHash(b string) HeimdallHash
HexToHeimdallHash returns Address with value b.
func (HeimdallHash) Bytes ¶
func (aa HeimdallHash) Bytes() []byte
Bytes returns the raw address bytes.
func (HeimdallHash) Empty ¶
func (aa HeimdallHash) Empty() bool
Empty returns boolean for whether an AccAddress is empty
func (HeimdallHash) Equals ¶
func (aa HeimdallHash) Equals(aa2 HeimdallHash) bool
Equals returns boolean for whether two HeimdallHash are Equal
func (HeimdallHash) Format ¶
func (aa HeimdallHash) Format(s fmt.State, verb rune)
Format implements the fmt.Formatter interface. nolint: errcheck
func (HeimdallHash) Marshal ¶
func (aa HeimdallHash) Marshal() ([]byte, error)
Marshal returns the raw address bytes. It is needed for protobuf compatibility.
func (HeimdallHash) MarshalJSON ¶
func (aa HeimdallHash) MarshalJSON() ([]byte, error)
MarshalJSON marshals to JSON using Bech32.
func (HeimdallHash) MarshalYAML ¶
func (aa HeimdallHash) MarshalYAML() (interface{}, error)
MarshalYAML marshals to YAML using Bech32.
func (HeimdallHash) String ¶
func (aa HeimdallHash) String() string
String implements the Stringer interface.
func (*HeimdallHash) Unmarshal ¶
func (aa *HeimdallHash) Unmarshal(data []byte) error
Unmarshal sets the address to the given data. It is needed for protobuf compatibility.
func (*HeimdallHash) UnmarshalJSON ¶
func (aa *HeimdallHash) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (*HeimdallHash) UnmarshalYAML ¶
func (aa *HeimdallHash) UnmarshalYAML(data []byte) error
UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.
type HexBytes ¶
type HexBytes []byte
HexBytes the main purpose of HexBytes is to enable HEX-encoding for json/encoding.
func BytesToHexBytes ¶
BytesToHexBytes returns HexBytes with value b.
func (HexBytes) MarshalJSON ¶
MarshalJSON this is the point of Bytes.
func (HexBytes) MarshalYAML ¶
MarshalYAML marshals to YAML using Bech32.
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON this is the point of Bytes.
func (*HexBytes) UnmarshalYAML ¶
UnmarshalYAML unmarshals from YAML assuming Bech32 encoding.
type MinimalVal ¶
type MinimalVal struct { ID ValidatorID `json:"ID"` VotingPower uint64 `json:"power"` // TODO add 10^-18 here so that we dont overflow easily Signer HeimdallAddress `json:"signer"` }
MinimalVal is the minimal validator representation Used to send validator information to bor validator contract
func SortMinimalValByAddress ¶
func SortMinimalValByAddress(a []MinimalVal) []MinimalVal
SortMinimalValByAddress sorts validators
func ValToMinVal ¶
func ValToMinVal(vals []Validator) (minVals []MinimalVal)
ValToMinVal converts array of validators to minimal validators
type PaginatedIterator ¶
PaginatedIterator is a wrapper around Iterator that iterates over values starting for given page and limit.
func (*PaginatedIterator) Next ¶
func (pi *PaginatedIterator) Next()
Next will panic after limit is reached.
func (*PaginatedIterator) Valid ¶
func (pi *PaginatedIterator) Valid() bool
Valid if below limit and underlying iterator is valid.
type PostTxHandler ¶
type PostTxHandler func(ctx sdk.Context, msg sdk.Msg, sideTxResult abci.SideTxResultType) sdk.Result
PostTxHandler defines the core of the state transition function of an application after side-tx execution
type PubKey ¶
type PubKey [65]byte
PubKey pubkey
func (PubKey) ABCIPubKey ¶
ABCIPubKey returns abci pubkey for cosmos
func (PubKey) CryptoPubKey ¶
CryptoPubKey returns crypto pub key for tendermint
func (PubKey) Marshal ¶
Marshal returns the raw address bytes. It is needed for protobuf compatibility.
func (PubKey) MarshalJSON ¶
MarshalJSON marshals to JSON using Bech32.
func (PubKey) MarshalText ¶
MarshalText returns the hex representation of a.
func (PubKey) MarshalYAML ¶
MarshalYAML marshals to YAML using Bech32.
func (*PubKey) Unmarshal ¶
Unmarshal sets the address to the given data. It is needed for protobuf compatibility.
func (*PubKey) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (*PubKey) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
func (*PubKey) UnmarshalYAML ¶
UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.
type QueryPaginationParams ¶
QueryPaginationParams defines the params for querying accounts.
func NewQueryPaginationParams ¶
func NewQueryPaginationParams(page uint64, limit uint64) QueryPaginationParams
NewQueryPaginationParams creates a new instance of QueryPaginationParams.
type SideHandlers ¶
type SideHandlers struct { SideTxHandler SideTxHandler PostTxHandler PostTxHandler }
SideHandlers handler for side-tx processing
type SideRouter ¶
type SideRouter interface { AddRoute(r string, h *SideHandlers) (rtr SideRouter) HasRoute(r string) bool GetRoute(path string) (h *SideHandlers) Seal() }
SideRouter implements router.
type SideTxHandler ¶
SideTxHandler defines the core of side-tx execution of an application
type Span ¶
type Span struct { ID uint64 `json:"span_id" yaml:"span_id"` StartBlock uint64 `json:"start_block" yaml:"start_block"` EndBlock uint64 `json:"end_block" yaml:"end_block"` ValidatorSet ValidatorSet `json:"validator_set" yaml:"validator_set"` SelectedProducers []Validator `json:"selected_producers" yaml:"selected_producers"` ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"` }
Span stores details for a span on Bor chain span is indexed by start block
type Validator ¶
type Validator struct { ID ValidatorID `json:"ID"` StartEpoch uint64 `json:"startEpoch"` EndEpoch uint64 `json:"endEpoch"` Nonce uint64 `json:"nonce"` VotingPower int64 `json:"power"` // TODO add 10^-18 here so that we dont overflow easily PubKey PubKey `json:"pubKey"` Signer HeimdallAddress `json:"signer"` LastUpdated string `json:"last_updated"` Jailed bool `json:"jailed"` ProposerPriority int64 `json:"accum"` }
Validator heimdall validator
func NewValidator ¶
func NewValidator( id ValidatorID, startEpoch uint64, endEpoch uint64, nonce uint64, power int64, pubKey PubKey, signer HeimdallAddress, ) *Validator
NewValidator func creates a new validator, the HeimdallAddress field is generated using Address i.e. [20]byte
func SortValidatorByAddress ¶
SortValidatorByAddress sorts a slice of validators by address to sort it we compare the values of the Signer(HeimdallAddress i.e. [20]byte)
func UnmarshallValidator ¶
amono unmarshall validator
func (*Validator) Bytes ¶
Bytes computes the unique encoding of a validator with a given voting power. These are the bytes that gets hashed in consensus. It excludes address as its redundant with the pubkey. This also excludes ProposerPriority which changes every round.
func (*Validator) CompareProposerPriority ¶
Returns the one with higher ProposerPriority.
func (*Validator) Copy ¶
Copy creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.
func (*Validator) IsCurrentValidator ¶
IsCurrentValidator checks if validator is in current validator set
func (*Validator) MinimalVal ¶
func (v *Validator) MinimalVal() MinimalVal
MinimalVal returns block number of last validator update
type ValidatorID ¶
type ValidatorID uint64
ValidatorID validator ID and helper functions
func NewValidatorID ¶
func NewValidatorID(id uint64) ValidatorID
NewValidatorID generate new validator ID
func (ValidatorID) String ¶
func (valID ValidatorID) String() string
Uint64 converts validator ID to int
func (ValidatorID) Uint64 ¶
func (valID ValidatorID) Uint64() uint64
Uint64 converts validator ID to int
type ValidatorSet ¶
type ValidatorSet struct { // NOTE: persisted via reflect, must be exported. Validators []*Validator `json:"validators"` Proposer *Validator `json:"proposer"` // 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 - ie. the validators are sorted by their address. On the other hand, the .ProposerPriority of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementProposerPriority(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.
func NewValidatorSet ¶
func NewValidatorSet(valz []*Validator) *ValidatorSet
NewValidatorSet initializes a ValidatorSet by copying over the values from `valz`, a list of Validators. If valz is nil or empty, the new ValidatorSet will have an empty list of Validators. The addresses of validators in `valz` must be unique otherwise the function panics.
func (*ValidatorSet) Copy ¶
func (vals *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet.
func (*ValidatorSet) CopyIncrementProposerPriority ¶
func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
Increment ProposerPriority and update the proposer on a copy, and return it.
func (*ValidatorSet) GetByAddress ¶
func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
GetByAddress returns an index of the validator with address and validator itself if found. Otherwise, -1 and nil are returned.
func (*ValidatorSet) GetByIndex ¶
func (vals *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
GetByIndex returns the validator's address and validator itself by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).
func (*ValidatorSet) GetProposer ¶
func (vals *ValidatorSet) GetProposer() (proposer *Validator)
GetProposer returns the current proposer. If the validator set is empty, nil is returned.
func (*ValidatorSet) HasAddress ¶
func (vals *ValidatorSet) HasAddress(address []byte) bool
HasAddress returns true if address given is in the validator set, false - otherwise.
func (*ValidatorSet) Hash ¶
func (vals *ValidatorSet) Hash() []byte
Hash returns the Merkle root hash build using validators (as leaves) in the set.
func (*ValidatorSet) IncrementProposerPriority ¶
func (vals *ValidatorSet) IncrementProposerPriority(times int)
IncrementProposerPriority increments ProposerPriority of each validator and updates the proposer. Panics if validator set is empty. `times` must be positive.
func (*ValidatorSet) IsNilOrEmpty ¶
func (vals *ValidatorSet) IsNilOrEmpty() bool
Nil or empty validator sets are invalid.
func (*ValidatorSet) Iterate ¶
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
Iterate will run the given function over the set.
func (*ValidatorSet) RescalePriorities ¶
func (vals *ValidatorSet) RescalePriorities(diffMax int64)
func (*ValidatorSet) Size ¶
func (vals *ValidatorSet) Size() int
Size returns the length of the validator set.
func (*ValidatorSet) String ¶
func (vals *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (vals *ValidatorSet) StringIndented(indent string) string
StringIndented return string
func (*ValidatorSet) TotalVotingPower ¶
func (vals *ValidatorSet) TotalVotingPower() int64
TotalVotingPower returns the sum of the voting powers of all validators. It recomputes the total voting power if required.
func (*ValidatorSet) UpdateWithChangeSet ¶
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
UpdateWithChangeSet attempts to update the validator set with 'changes'. It performs the following steps:
- validates the changes making sure there are no duplicates and splits them in updates and deletes
- verifies that applying the changes will not result in errors
- computes the total voting power BEFORE removals to ensure that in the next steps the priorities across old and newly added validators are fair
- computes the priorities of new validators against the final set
- applies the updates against the validator set
- applies the removals against the validator set
- performs scaling and centering of priority values
If an error is detected during verification steps, it is returned and the validator set is not changed.
type ValidatorSigningInfo ¶
type ValidatorSigningInfo struct { ValID ValidatorID `json:"valID"` // height at which validator was first a candidate OR was unjailed StartHeight int64 `json:"startHeight"` // index offset into signed block bit array IndexOffset int64 `json:"indexOffset"` // timestamp validator cannot be unjailed until // JailedUntil time.Time `json:"jailedUntil"` // whether or not a validator has been tombstoned (killed out of validator set) // Tombstoned bool `protobuf:"varint,5,opt,name=tombstoned,proto3" json:"tombstoned,omitempty"` // missed blocks counter (to avoid scanning the array every time) MissedBlocksCounter int64 `json:"missed_blocks_counter,omitempty"` }
ValidatorSigningInfo defines the signing info for a validator
func NewValidatorSigningInfo ¶
func NewValidatorSigningInfo( valID ValidatorID, startHeight, indexOffset int64, missedBlocksCounter int64, ) ValidatorSigningInfo
NewValidatorSigningInfo creates a new ValidatorSigningInfo instance
func UnmarshallValSigningInfo ¶
func UnmarshallValSigningInfo(cdc *codec.Codec, value []byte) (ValidatorSigningInfo, error)
amono unmarshall validator
func (ValidatorSigningInfo) String ¶
func (i ValidatorSigningInfo) String() string
String implements the stringer interface for ValidatorSigningInfo
type ValidatorSlashingInfo ¶
type ValidatorSlashingInfo struct { ID ValidatorID `json:"ID"` SlashedAmount uint64 `json:"SlashedAmount"` IsJailed bool `json:"IsJailed"` }
ValidatorSlashingInfo - contains ID, slashingAmount, isJailed
func NewValidatorSlashingInfo ¶
func NewValidatorSlashingInfo(id ValidatorID, slashedAmount uint64, isJailed bool) ValidatorSlashingInfo
func SortValidatorSlashingInfoByID ¶
func SortValidatorSlashingInfoByID(slashingInfos []*ValidatorSlashingInfo) []*ValidatorSlashingInfo
SortValidatorSlashingInfoByID - Sorts ValidatorSlashingInfo By ID
func UnmarshallValSlashingInfo ¶
func UnmarshallValSlashingInfo(cdc *codec.Codec, value []byte) (ValidatorSlashingInfo, error)
amono unmarshall validator slashing info
func (ValidatorSlashingInfo) String ¶
func (v ValidatorSlashingInfo) String() string
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
ValidatorsByAddress sorts validators by address.
func (ValidatorsByAddress) Len ¶
func (valz ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (valz ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (valz ValidatorsByAddress) Swap(i, j int)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package rest provides HTTP types and primitives for REST requests validation and responses handling.
|
Package rest provides HTTP types and primitives for REST requests validation and responses handling. |