types

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: GPL-3.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Precision = 18

	// bytes required to represent the above precision
	// Ceiling[Log2[999 999 999 999 999 999]]
	DecimalPrecisionBits = 60
)

number of decimal places

View Source
const (
	MaxTotalVotingPower      = int64(math.MaxInt64) / 8
	PriorityWindowSizeFactor = 2
)
View Source
const (
	// AddrLen defines a valid address length
	AddrLen = 20
)
View Source
const (
	// DefaultLogIndexUnit default tx hash + log index unit
	DefaultLogIndexUnit = 100000
)

Variables

View Source
var (
	// CoinDecimals is the amount of staking tokens required for 1 unit
	CoinDecimals = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)
)
View Source
var ZeroHeimdallAddress = HeimdallAddress{}

ZeroHeimdallAddress represents zero address

View Source
var ZeroHeimdallHash = HeimdallHash{}

ZeroHeimdallHash represents zero address

View Source
var ZeroPubKey = PubKey{}

ZeroPubKey represents empty pub key

Functions

func DecEq

func DecEq(t *testing.T, exp, got Dec) (*testing.T, bool, string, string, string)

intended to be used with require/assert: require.True(DecEq(...))

func DecsEqual

func DecsEqual(d1s, d2s []Dec) bool

test if two decimal arrays are equal

func HeimdallAddressToAccAddress

func HeimdallAddressToAccAddress(b HeimdallAddress) sdk.AccAddress

HeimdallAddressToAccAddress returns Address with value b.

func IntEq

func IntEq(t *testing.T, exp, got Int) (*testing.T, bool, string, string, string)

intended to be used with require/assert: require.True(IntEq(...))

func KVStorePrefixIteratorPaginated

func KVStorePrefixIteratorPaginated(kvs sdk.KVStore, prefix []byte, page, limit uint) sdk.Iterator

KVStorePrefixIteratorPaginated returns iterator over items in the selected page. 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 MarshallValidator

func MarshallValidator(cdc *codec.Codec, validator Validator) (bz []byte, err error)

amino marshall validator

func SortSpanByID

func SortSpanByID(a []*Span)

SortSpanByID sorts spans by SpanID

func ValidatorListString

func ValidatorListString(vals []*Validator) string

ValidatorListString returns a prettified validator list for logging purposes.

Types

type BaseTx

type BaseTx struct {
	Msg sdk.Msg
}

BaseTx represents base tx tendermint needs

func NewBaseTx

func NewBaseTx(msg sdk.Msg) BaseTx

NewBaseTx drafts BaseTx with messages

func (BaseTx) GetMsgs

func (tx BaseTx) GetMsgs() []sdk.Msg

GetMsgs returns array of messages

func (BaseTx) ValidateBasic

func (tx BaseTx) ValidateBasic() sdk.Error

ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.

type CheckpointBlockHeader

type CheckpointBlockHeader struct {
	Proposer        HeimdallAddress `json:"proposer"`
	StartBlock      uint64          `json:"startBlock"`
	EndBlock        uint64          `json:"endBlock"`
	RootHash        HeimdallHash    `json:"rootHash"`
	AccountRootHash HeimdallHash    `json:"accountRootHash"`
	TimeStamp       uint64          `json:"timestamp"`
}

CheckpointBlockHeader block header struct

func CreateBlock

func CreateBlock(start uint64, end uint64, rootHash HeimdallHash, accountRootHash HeimdallHash, proposer HeimdallAddress, timestamp uint64) CheckpointBlockHeader

CreateBlock generate new block

func SortHeaders

func SortHeaders(headers []CheckpointBlockHeader) []CheckpointBlockHeader

SortHeaders sorts array of headers on the basis for timestamps

func (CheckpointBlockHeader) String

func (m CheckpointBlockHeader) String() string

String returns human redable string

type Coin

type Coin struct {
	Denom string `json:"denom"`

	// To allow the use of unsigned integers (see: #1273) a larger refactor will
	// need to be made. So we use signed integers for now with safety measures in
	// place preventing negative values being used.
	Amount Int `json:"amount"`
}

Coin hold some amount of one currency.

CONTRACT: A coin will never hold a negative amount of any denomination.

TODO: Make field members private for further safety.

func NewCoin

func NewCoin(denom string, amount Int) Coin

NewCoin returns a new coin with a denomination and amount. It will panic if the amount is negative.

func NewInt64Coin

func NewInt64Coin(denom string, amount int64) Coin

NewInt64Coin returns a new coin with a denomination and amount. It will panic if the amount is negative.

func ParseCoin

func ParseCoin(coinStr string) (coin Coin, err error)

ParseCoin parses a cli input for one coin type, returning errors if invalid. This returns an error on an empty string as well.

func (Coin) Add

func (coin Coin) Add(coinB Coin) Coin

Adds amounts of two coins with same denom. If the coins differ in denom then it panics.

func (Coin) IsEqual

func (coin Coin) IsEqual(other Coin) bool

IsEqual returns true if the two sets of Coins have the same value

func (Coin) IsGTE

func (coin Coin) IsGTE(other Coin) bool

IsGTE returns true if they are the same type and the receiver is an equal or greater value

func (Coin) IsLT

func (coin Coin) IsLT(other Coin) bool

IsLT returns true if they are the same type and the receiver is a smaller value

func (Coin) IsNegative

func (coin Coin) IsNegative() bool

IsNegative returns true if the coin amount is negative and false otherwise.

TODO: Remove once unsigned integers are used.

func (Coin) IsPositive

func (coin Coin) IsPositive() bool

IsPositive returns true if coin amount is positive.

TODO: Remove once unsigned integers are used.

func (Coin) IsValid

func (coin Coin) IsValid() bool

IsValid returns true if the Coin has a non-negative amount and the denom is vaild.

func (Coin) IsZero

func (coin Coin) IsZero() bool

IsZero returns if this represents no money

func (Coin) String

func (coin Coin) String() string

String provides a human-readable representation of a coin

func (Coin) Sub

func (coin Coin) Sub(coinB Coin) Coin

Subtracts amounts of two coins with same denom. If the coins differ in denom then it panics.

type Coins

type Coins []Coin

Coins is a set of Coin, one per currency

func NewCoins

func NewCoins(coins ...Coin) Coins

NewCoins constructs a new coin set.

func ParseCoins

func ParseCoins(coinsStr string) (Coins, error)

ParseCoins will parse out a list of coins separated by commas. If nothing is provided, it returns nil Coins. Returned coins are sorted.

func (Coins) Add

func (coins Coins) Add(coinsB Coins) Coins

Add adds two sets of coins.

e.g. {2A} + {A, 2B} = {3A, 2B} {2A} + {0B} = {2A}

NOTE: Add operates under the invariant that coins are sorted by denominations.

CONTRACT: Add will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true.

func (Coins) AmountOf

func (coins Coins) AmountOf(denom string) Int

Returns the amount of a denom from coins

func (Coins) DenomsSubsetOf

func (coins Coins) DenomsSubsetOf(coinsB Coins) bool

DenomsSubsetOf returns true if receiver's denom set is subset of coinsB's denoms.

func (Coins) Empty

func (coins Coins) Empty() bool

Empty returns true if there are no coins and false otherwise.

func (Coins) IsAllGT

func (coins Coins) IsAllGT(coinsB Coins) bool

IsAllGT returns true if for every denom in coinsB, the denom is present at a greater amount in coins.

func (Coins) IsAllGTE

func (coins Coins) IsAllGTE(coinsB Coins) bool

IsAllGTE returns false if for any denom in coinsB, the denom is present at a smaller amount in coins; else returns true.

func (Coins) IsAllLT

func (coins Coins) IsAllLT(coinsB Coins) bool

IsAllLT returns True iff for every denom in coins, the denom is present at a smaller amount in coinsB.

func (Coins) IsAllLTE

func (coins Coins) IsAllLTE(coinsB Coins) bool

IsAllLTE returns true iff for every denom in coins, the denom is present at a smaller or equal amount in coinsB.

func (Coins) IsAllPositive

func (coins Coins) IsAllPositive() bool

IsAllPositive returns true if there is at least one coin and all currencies have a positive value.

func (Coins) IsAnyGT

func (coins Coins) IsAnyGT(coinsB Coins) bool

IsAnyGT returns true iff for any denom in coins, the denom is present at a greater amount in coinsB.

e.g. {2A, 3B}.IsAnyGT{A} = true {2A, 3B}.IsAnyGT{5C} = false {}.IsAnyGT{5C} = false {2A, 3B}.IsAnyGT{} = false

func (Coins) IsAnyGTE

func (coins Coins) IsAnyGTE(coinsB Coins) bool

IsAnyGTE returns true iff coins contains at least one denom that is present at a greater or equal amount in coinsB; it returns false otherwise.

NOTE: IsAnyGTE operates under the invariant that both coin sets are sorted by denominations and there exists no zero coins.

func (Coins) IsAnyNegative

func (coins Coins) IsAnyNegative() bool

IsAnyNegative returns true if there is at least one coin whose amount is negative; returns false otherwise. It returns false if the coin set is empty too.

TODO: Remove once unsigned integers are used.

func (Coins) IsEqual

func (coins Coins) IsEqual(coinsB Coins) bool

IsEqual returns true if the two sets of Coins have the same value

func (Coins) IsValid

func (coins Coins) IsValid() bool

IsValid asserts the Coins are sorted, have positive amount, and Denom does not contain upper case characters.

func (Coins) IsZero

func (coins Coins) IsZero() bool

IsZero returns true if there are no coins or all coins are zero.

func (Coins) Len

func (coins Coins) Len() int

nolint

func (Coins) Less

func (coins Coins) Less(i, j int) bool

func (Coins) MarshalJSON

func (coins Coins) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom JSON marshaller for the Coins type to allow nil Coins to be encoded as an empty array.

func (Coins) SafeSub

func (coins Coins) SafeSub(coinsB Coins) (Coins, bool)

SafeSub performs the same arithmetic as Sub but returns a boolean if any negative coin amount was returned.

func (Coins) Sort

func (coins Coins) Sort() Coins

Sort is a helper function to sort the set of coins inplace

func (Coins) String

func (coins Coins) String() string

func (Coins) Sub

func (coins Coins) Sub(coinsB Coins) Coins

Sub subtracts a set of coins from another.

e.g. {2A, 3B} - {A} = {A, 3B} {2A} - {0B} = {2A} {A, B} - {A} = {B}

CONTRACT: Sub will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true.

func (Coins) Swap

func (coins Coins) Swap(i, j int)

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) ABI

func (c *Contract) ABI() abi.ABI

ABI returns the abi of contract

func (*Contract) Address

func (c *Contract) Address() common.Address

Address returns address of contract

func (*Contract) Instance

func (c *Contract) Instance() bind.ContractBackend

Instance returns the instance of contract

func (*Contract) Location

func (c *Contract) Location() int

Location returns location of contract

func (*Contract) Name

func (c *Contract) Name() string

Name returns name of contract

type Dec

type Dec struct {
	*big.Int `json:"int"`
}

NOTE: never use new(Dec) or else we will panic unmarshalling into the nil embedded big.Int

func MaxDec

func MaxDec(d1, d2 Dec) Dec

maximum decimal between two

func MinDec

func MinDec(d1, d2 Dec) Dec

minimum decimal between two

func MustNewDecFromStr

func MustNewDecFromStr(s string) Dec

Decimal from string, panic on error

func NewDec

func NewDec(i int64) Dec

create a new Dec from integer assuming whole number

func NewDecFromBigInt

func NewDecFromBigInt(i *big.Int) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromBigIntWithPrec

func NewDecFromBigIntWithPrec(i *big.Int, prec int64) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromInt

func NewDecFromInt(i Int) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromIntWithPrec

func NewDecFromIntWithPrec(i Int, prec int64) Dec

create a new Dec from big integer with decimal place at prec CONTRACT: prec <= Precision

func NewDecFromStr

func NewDecFromStr(str string) (d Dec, err sdk.Error)

create a decimal from an input decimal string. valid must come in the form:

(-) whole integers (.) decimal integers

examples of acceptable input include:

-123.456
456.7890
345
-456789

NOTE - An error will return if more decimal places are provided in the string than the constant Precision.

CONTRACT - This function does not mutate the input str.

func NewDecWithPrec

func NewDecWithPrec(i, prec int64) Dec

create a new Dec from integer with decimal place at prec CONTRACT: prec <= Precision

func OneDec

func OneDec() Dec

func ZeroDec

func ZeroDec() Dec

nolint - common values

func (Dec) Abs

func (d Dec) Abs() Dec

func (Dec) Add

func (d Dec) Add(d2 Dec) Dec

addition

func (Dec) Ceil

func (d Dec) Ceil() Dec

Ceil returns the smallest interger value (as a decimal) that is greater than or equal to the given decimal.

func (Dec) Equal

func (d Dec) Equal(d2 Dec) bool

func (Dec) Format

func (d Dec) Format(s fmt.State, verb rune)

format decimal state

func (Dec) GT

func (d Dec) GT(d2 Dec) bool

func (Dec) GTE

func (d Dec) GTE(d2 Dec) bool

func (Dec) IsInteger

func (d Dec) IsInteger() bool

is integer, e.g. decimals are zero

func (Dec) IsNegative

func (d Dec) IsNegative() bool

func (Dec) IsNil

func (d Dec) IsNil() bool

______________________________________________________________________________________________ nolint

func (Dec) IsPositive

func (d Dec) IsPositive() bool

func (Dec) IsZero

func (d Dec) IsZero() bool

func (Dec) LT

func (d Dec) LT(d2 Dec) bool

func (Dec) LTE

func (d Dec) LTE(d2 Dec) bool

func (Dec) MarshalAmino

func (d Dec) MarshalAmino() (string, error)

wraps d.MarshalText()

func (Dec) MarshalJSON

func (d Dec) MarshalJSON() ([]byte, error)

MarshalJSON marshals the decimal

func (Dec) Mul

func (d Dec) Mul(d2 Dec) Dec

multiplication

func (Dec) MulInt

func (d Dec) MulInt(i Int) Dec

multiplication

func (Dec) MulInt64

func (d Dec) MulInt64(i int64) Dec

MulInt64 - multiplication with int64

func (Dec) MulTruncate

func (d Dec) MulTruncate(d2 Dec) Dec

multiplication truncate

func (Dec) Neg

func (d Dec) Neg() Dec

func (Dec) Quo

func (d Dec) Quo(d2 Dec) Dec

quotient

func (Dec) QuoInt

func (d Dec) QuoInt(i Int) Dec

quotient

func (Dec) QuoInt64

func (d Dec) QuoInt64(i int64) Dec

QuoInt64 - quotient with int64

func (Dec) QuoRoundUp

func (d Dec) QuoRoundUp(d2 Dec) Dec

quotient, round up

func (Dec) QuoTruncate

func (d Dec) QuoTruncate(d2 Dec) Dec

quotient truncate

func (Dec) RoundInt

func (d Dec) RoundInt() Int

RoundInt round the decimal using bankers rounding

func (Dec) RoundInt64

func (d Dec) RoundInt64() int64

RoundInt64 rounds the decimal using bankers rounding

func (Dec) String

func (d Dec) String() string

func (Dec) Sub

func (d Dec) Sub(d2 Dec) Dec

subtraction

func (Dec) TruncateDec

func (d Dec) TruncateDec() Dec

TruncateDec truncates the decimals from the number and returns a Dec

func (Dec) TruncateInt

func (d Dec) TruncateInt() Int

TruncateInt truncates the decimals from the number and returns an Int

func (Dec) TruncateInt64

func (d Dec) TruncateInt64() int64

TruncateInt64 truncates the decimals from the number and returns an int64

func (*Dec) UnmarshalAmino

func (d *Dec) UnmarshalAmino(text string) (err error)

requires a valid JSON string - strings quotes and calls UnmarshalText

func (*Dec) UnmarshalJSON

func (d *Dec) UnmarshalJSON(bz []byte) error

UnmarshalJSON defines custom decoding scheme

type DecCoin

type DecCoin struct {
	Denom  string `json:"denom"`
	Amount Dec    `json:"amount"`
}

Coins which can have additional decimal points

func NewDecCoin

func NewDecCoin(denom string, amount Int) DecCoin

func NewDecCoinFromCoin

func NewDecCoinFromCoin(coin Coin) DecCoin

func NewDecCoinFromDec

func NewDecCoinFromDec(denom string, amount Dec) DecCoin

func NewInt64DecCoin

func NewInt64DecCoin(denom string, amount int64) DecCoin

NewInt64DecCoin returns a new DecCoin with a denomination and amount. It will panic if the amount is negative or denom is invalid.

func ParseDecCoin

func ParseDecCoin(coinStr string) (coin DecCoin, err error)

ParseDecCoin parses a decimal coin from a string, returning an error if invalid. An empty string is considered invalid.

func (DecCoin) Add

func (coin DecCoin) Add(coinB DecCoin) DecCoin

Adds amounts of two coins with same denom

func (DecCoin) IsEqual

func (coin DecCoin) IsEqual(other DecCoin) bool

IsEqual returns true if the two sets of Coins have the same value.

func (DecCoin) IsGTE

func (coin DecCoin) IsGTE(other DecCoin) bool

IsGTE returns true if they are the same type and the receiver is an equal or greater value.

func (DecCoin) IsLT

func (coin DecCoin) IsLT(other DecCoin) bool

IsLT returns true if they are the same type and the receiver is a smaller value.

func (DecCoin) IsNegative

func (coin DecCoin) IsNegative() bool

IsNegative returns true if the coin amount is negative and false otherwise.

TODO: Remove once unsigned integers are used.

func (DecCoin) IsPositive

func (coin DecCoin) IsPositive() bool

IsPositive returns true if coin amount is positive.

TODO: Remove once unsigned integers are used.

func (DecCoin) IsZero

func (coin DecCoin) IsZero() bool

IsZero returns if the DecCoin amount is zero.

func (DecCoin) String

func (coin DecCoin) String() string

String implements the Stringer interface for DecCoin. It returns a human-readable representation of a decimal coin.

func (DecCoin) Sub

func (coin DecCoin) Sub(coinB DecCoin) DecCoin

Subtracts amounts of two coins with same denom

func (DecCoin) TruncateDecimal

func (coin DecCoin) TruncateDecimal() (Coin, DecCoin)

TruncateDecimal returns a Coin with a truncated decimal and a DecCoin for the change. Note, the change may be zero.

type DecCoins

type DecCoins []DecCoin

coins with decimal

func NewDecCoins

func NewDecCoins(coins Coins) DecCoins

func ParseDecCoins

func ParseDecCoins(coinsStr string) (DecCoins, error)

ParseDecCoins will parse out a list of decimal coins separated by commas. If nothing is provided, it returns nil DecCoins. Returned decimal coins are sorted.

func (DecCoins) Add

func (coins DecCoins) Add(coinsB DecCoins) DecCoins

Add adds two sets of DecCoins.

NOTE: Add operates under the invariant that coins are sorted by denominations.

CONTRACT: Add will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true.

func (DecCoins) AmountOf

func (coins DecCoins) AmountOf(denom string) Dec

returns the amount of a denom from deccoins

func (DecCoins) Empty

func (coins DecCoins) Empty() bool

Empty returns true if there are no coins and false otherwise.

func (DecCoins) Intersect

func (coins DecCoins) Intersect(coinsB DecCoins) DecCoins

Intersect will return a new set of coins which contains the minimum DecCoin for common denoms found in both `coins` and `coinsB`. For denoms not common to both `coins` and `coinsB` the minimum is considered to be 0, thus they are not added to the final set.In other words, trim any denom amount from coin which exceeds that of coinB, such that (coin.Intersect(coinB)).IsLTE(coinB).

func (DecCoins) IsAllPositive

func (coins DecCoins) IsAllPositive() bool

IsAllPositive returns true if there is at least one coin and all currencies have a positive value.

TODO: Remove once unsigned integers are used.

func (DecCoins) IsAnyNegative

func (coins DecCoins) IsAnyNegative() bool

IsAnyNegative returns true if there is at least one coin whose amount is negative; returns false otherwise. It returns false if the DecCoins set is empty too.

TODO: Remove once unsigned integers are used.

func (DecCoins) IsEqual

func (coins DecCoins) IsEqual(coinsB DecCoins) bool

IsEqual returns true if the two sets of DecCoins have the same value.

func (DecCoins) IsValid

func (coins DecCoins) IsValid() bool

IsValid asserts the DecCoins are sorted, have positive amount, and Denom does not contain upper case characters.

func (DecCoins) IsZero

func (coins DecCoins) IsZero() bool

return whether all coins are zero

func (DecCoins) Len

func (coins DecCoins) Len() int

nolint

func (DecCoins) Less

func (coins DecCoins) Less(i, j int) bool

func (DecCoins) MulDec

func (coins DecCoins) MulDec(d Dec) DecCoins

MulDec multiplies all the coins by a decimal.

CONTRACT: No zero coins will be returned.

func (DecCoins) MulDecTruncate

func (coins DecCoins) MulDecTruncate(d Dec) DecCoins

MulDecTruncate multiplies all the decimal coins by a decimal, truncating. It panics if d is zero.

CONTRACT: No zero coins will be returned.

func (DecCoins) QuoDec

func (coins DecCoins) QuoDec(d Dec) DecCoins

QuoDec divides all the decimal coins by a decimal. It panics if d is zero.

CONTRACT: No zero coins will be returned.

func (DecCoins) QuoDecTruncate

func (coins DecCoins) QuoDecTruncate(d Dec) DecCoins

QuoDecTruncate divides all the decimal coins by a decimal, truncating. It panics if d is zero.

CONTRACT: No zero coins will be returned.

func (DecCoins) SafeSub

func (coins DecCoins) SafeSub(coinsB DecCoins) (DecCoins, bool)

SafeSub performs the same arithmetic as Sub but returns a boolean if any negative coin amount was returned.

func (DecCoins) Sort

func (coins DecCoins) Sort() DecCoins

Sort is a helper function to sort the set of decimal coins in-place.

func (DecCoins) String

func (coins DecCoins) String() string

String implements the Stringer interface for DecCoins. It returns a human-readable representation of decimal coins.

func (DecCoins) Sub

func (coins DecCoins) Sub(coinsB DecCoins) DecCoins

Sub subtracts a set of DecCoins from another (adds the inverse).

func (DecCoins) Swap

func (coins DecCoins) Swap(i, j int)

func (DecCoins) TruncateDecimal

func (coins DecCoins) TruncateDecimal() (truncatedCoins Coins, changeCoins DecCoins)

TruncateDecimal returns the coins with truncated decimals and returns the change. Note, it will not return any zero-amount coins in either the truncated or change coins.

type DividendAccount

type DividendAccount struct {
	ID            DividendAccountID `json:"ID"`
	FeeAmount     string            `json:"feeAmount"`     // string representation of big.Int
	SlashedAmount string            `json:"slashedAmount"` // string representation of big.Int
}

DividendAccount contains Fee, Slashed amount

func NewDividendAccount

func NewDividendAccount(id DividendAccountID, fee string, slashedAmount string) DividendAccount

func SortDividendAccountByID

func SortDividendAccountByID(dividendAccounts []DividendAccount) []DividendAccount

SortDividendAccountByID - Sorts DividendAccounts By ID

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 DividendAccountID

type DividendAccountID uint64

DividendAccountID dividend account ID and helper functions

func NewDividendAccountID

func NewDividendAccountID(id uint64) DividendAccountID

NewDividendAccountID generate new dividendAccount ID

func (DividendAccountID) Bytes

func (dividendAccountID DividendAccountID) Bytes() []byte

Bytes get bytes of dividendAccountID

func (DividendAccountID) Int

func (dividendAccountID DividendAccountID) Int() int

Int converts dividendAccount ID to int

func (DividendAccountID) Uint64

func (dividendAccountID DividendAccountID) Uint64() uint64

Uint64 converts dividendAccount ID to int

type HeimdallAddress

type HeimdallAddress common.Address

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

type HeimdallHash common.Hash

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 sdk.Address) bool

Equals returns boolean for whether two AccAddresses are Equal

func (HeimdallHash) EthHash

func (aa HeimdallHash) EthHash() common.Hash

EthHash get eth hash

func (HeimdallHash) Format

func (aa HeimdallHash) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface. nolint: errcheck

func (HeimdallHash) Hex

func (aa HeimdallHash) Hex() string

Hex returns hex string

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 HeimdallModuleBasic

type HeimdallModuleBasic interface {
	module.AppModuleBasic

	// verify genesis
	VerifyGenesis(map[string]json.RawMessage) error
}

HeimdallModuleBasic is the standard form for basic non-dependant elements of an application module.

type HexBytes

type HexBytes []byte

HexBytes the main purpose of HexBytes is to enable HEX-encoding for json/encoding.

func BytesToHexBytes

func BytesToHexBytes(b []byte) HexBytes

BytesToHexBytes returns HexBytes with value b.

func HexToHexBytes

func HexToHexBytes(b string) HexBytes

HexToHexBytes returns hex bytes

func (HexBytes) Bytes

func (bz HexBytes) Bytes() []byte

Bytes return bytes

func (HexBytes) Empty

func (bz HexBytes) Empty() bool

Empty returns boolean for whether an AccAddress is empty

func (HexBytes) Equals

func (bz HexBytes) Equals(bz2 HexBytes) bool

Equals returns boolean for whether two AccAddresses are Equal

func (HexBytes) Format

func (bz HexBytes) Format(s fmt.State, verb rune)

Format format bytes

func (HexBytes) Marshal

func (bz HexBytes) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (HexBytes) MarshalJSON

func (bz HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON this is the point of Bytes.

func (HexBytes) MarshalYAML

func (bz HexBytes) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (HexBytes) String

func (bz HexBytes) String() string

func (*HexBytes) Unmarshal

func (bz *HexBytes) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*HexBytes) UnmarshalJSON

func (bz *HexBytes) UnmarshalJSON(data []byte) error

UnmarshalJSON this is the point of Bytes.

func (*HexBytes) UnmarshalYAML

func (bz *HexBytes) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals from YAML assuming Bech32 encoding.

type Int

type Int struct {
	I *big.Int
}

Int wraps integer with 256 bit range bound Checks overflow, underflow and division by zero Exists in range from -(2^maxBitLen-1) to 2^maxBitLen-1

func MaxInt

func MaxInt(i, i2 Int) Int

MaxInt returns the maximum between two integers.

func MinInt

func MinInt(i1, i2 Int) Int

return the minimum of the ints

func NewInt

func NewInt(n int64) Int

NewInt constructs Int from int64

func NewIntFromBigInt

func NewIntFromBigInt(i *big.Int) Int

NewIntFromBigInt constructs Int from big.Int

func NewIntFromString

func NewIntFromString(s string) (res Int, ok bool)

NewIntFromString constructs Int from string

func NewIntWithDecimal

func NewIntWithDecimal(n int64, dec int) Int

NewIntWithDecimal constructs Int with decimal Result value is n*10^dec

func OneInt

func OneInt() Int

OneInt returns Int value with one

func ZeroInt

func ZeroInt() Int

ZeroInt returns Int value with zero

func (Int) Add

func (i Int) Add(i2 Int) (res Int)

Add adds Int from another

func (Int) AddRaw

func (i Int) AddRaw(i2 int64) Int

AddRaw adds int64 to Int

func (Int) BigInt

func (i Int) BigInt() *big.Int

BigInt converts Int to big.Int

func (Int) Equal

func (i Int) Equal(i2 Int) bool

Equal compares two Ints

func (Int) GT

func (i Int) GT(i2 Int) bool

GT returns true if first Int is greater than second

func (Int) GTE

func (i Int) GTE(i2 Int) bool

GTE returns true if receiver Int is greater than or equal to the parameter Int.

func (Int) Int64

func (i Int) Int64() int64

Int64 converts Int to int64 Panics if the value is out of range

func (Int) IsInt64

func (i Int) IsInt64() bool

IsInt64 returns true if Int64() not panics

func (Int) IsNegative

func (i Int) IsNegative() bool

IsNegative returns true if Int is negative

func (Int) IsPositive

func (i Int) IsPositive() bool

IsPositive returns true if Int is positive

func (Int) IsZero

func (i Int) IsZero() bool

IsZero returns true if Int is zero

func (Int) LT

func (i Int) LT(i2 Int) bool

LT returns true if first Int is lesser than second

func (Int) LTE

func (i Int) LTE(i2 Int) bool

LTE returns true if first Int is less than or equal to second

func (Int) MarshalAmino

func (i Int) MarshalAmino() (string, error)

MarshalAmino defines custom encoding scheme

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

MarshalJSON defines custom encoding scheme

func (Int) Mod

func (i Int) Mod(i2 Int) Int

Mod returns remainder after dividing with Int

func (Int) ModRaw

func (i Int) ModRaw(i2 int64) Int

ModRaw returns remainder after dividing with int64

func (Int) Mul

func (i Int) Mul(i2 Int) (res Int)

Mul multiples two Ints

func (Int) MulRaw

func (i Int) MulRaw(i2 int64) Int

MulRaw multipies Int and int64

func (Int) Neg

func (i Int) Neg() (res Int)

Neg negates Int

func (Int) Quo

func (i Int) Quo(i2 Int) (res Int)

Quo divides Int with Int

func (Int) QuoRaw

func (i Int) QuoRaw(i2 int64) Int

QuoRaw divides Int with int64

func (Int) Sign

func (i Int) Sign() int

Sign returns sign of Int

func (Int) String

func (i Int) String() string

Human readable string

func (Int) Sub

func (i Int) Sub(i2 Int) (res Int)

Sub subtracts Int from another

func (Int) SubRaw

func (i Int) SubRaw(i2 int64) Int

SubRaw subtracts int64 from Int

func (Int) ToDec

func (i Int) ToDec() Dec

ToDec converts Int to Dec

func (*Int) UnmarshalAmino

func (i *Int) UnmarshalAmino(text string) error

UnmarshalAmino defines custom decoding scheme

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(bz []byte) error

UnmarshalJSON defines custom decoding scheme

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

type PaginatedIterator struct {
	sdk.Iterator
	// contains filtered or unexported fields
}

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 PubKey

type PubKey [65]byte

PubKey pubkey

func NewPubKey

func NewPubKey(data []byte) PubKey

NewPubKey from byte array

func (PubKey) ABCIPubKey

func (a PubKey) ABCIPubKey() abci.PubKey

ABCIPubKey returns abci pubkey for cosmos

func (PubKey) Address

func (a PubKey) Address() common.Address

Address returns address

func (PubKey) Bytes

func (a PubKey) Bytes() []byte

Bytes returns bytes for pubkey

func (PubKey) CryptoPubKey

func (a PubKey) CryptoPubKey() crypto.PubKey

CryptoPubKey returns crypto pub key for tendermint

func (PubKey) Marshal

func (a PubKey) Marshal() ([]byte, error)

Marshal returns the raw address bytes. It is needed for protobuf compatibility.

func (PubKey) MarshalJSON

func (a PubKey) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using Bech32.

func (PubKey) MarshalText

func (a PubKey) MarshalText() ([]byte, error)

MarshalText returns the hex representation of a.

func (PubKey) MarshalYAML

func (a PubKey) MarshalYAML() (interface{}, error)

MarshalYAML marshals to YAML using Bech32.

func (PubKey) String

func (a PubKey) String() string

String returns string representatin of key

func (*PubKey) Unmarshal

func (a *PubKey) Unmarshal(data []byte) error

Unmarshal sets the address to the given data. It is needed for protobuf compatibility.

func (*PubKey) UnmarshalJSON

func (a *PubKey) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

func (*PubKey) UnmarshalText

func (a *PubKey) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

func (*PubKey) UnmarshalYAML

func (a *PubKey) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals from JSON assuming Bech32 encoding.

type QueryPaginationParams

type QueryPaginationParams struct {
	Page  uint64
	Limit uint64
}

QueryPaginationParams defines the params for querying accounts.

func NewQueryPaginationParams

func NewQueryPaginationParams(page uint64, limit uint64) QueryPaginationParams

NewQueryPaginationParams creates a new instance of QueryPaginationParams.

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

func NewSpan

func NewSpan(id uint64, startBlock uint64, endBlock uint64, validatorSet ValidatorSet, selectedProducers []Validator, chainID string) Span

NewSpan creates new span

func (*Span) String

func (s *Span) String() string

String returns the string representatin of span

type Validator

type Validator struct {
	ID          ValidatorID     `json:"ID"`
	StartEpoch  uint64          `json:"startEpoch"`
	EndEpoch    uint64          `json:"endEpoch"`
	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"`

	ProposerPriority int64 `json:"accum"`
}

Validator heimdall validator

func NewValidator

func NewValidator(id ValidatorID, startEpoch uint64, endEpoch uint64, power int64, pubKey PubKey, signer HeimdallAddress) *Validator

func SortValidatorByAddress

func SortValidatorByAddress(a []Validator) []Validator

SortValidatorByAddress sorts a slice of validators by address

func UnmarshallValidator

func UnmarshallValidator(cdc *codec.Codec, value []byte) (Validator, error)

amono unmarshall validator

func (*Validator) Bytes

func (v *Validator) Bytes() []byte

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

func (v *Validator) CompareProposerPriority(other *Validator) *Validator

Returns the one with higher ProposerPriority.

func (*Validator) Copy

func (v *Validator) Copy() *Validator

Copy creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.

func (*Validator) IsCurrentValidator

func (v *Validator) IsCurrentValidator(ackCount uint64) bool

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

func (*Validator) String

func (v *Validator) String() string

func (*Validator) UpdatedAt

func (v *Validator) UpdatedAt() string

UpdatedAt returns block number of last validator update

func (*Validator) ValidateBasic

func (v *Validator) ValidateBasic() bool

Validates validator

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) Bytes

func (valID ValidatorID) Bytes() []byte

Bytes get bytes of validatorID

func (ValidatorID) Int

func (valID ValidatorID) Int() int

Int converts validator ID to int

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 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)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL