common

package
v0.0.0-...-a41a74f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SuperMajorityFactor - super majority 2/3
	SuperMajorityFactor = 3
	// SimpleMajorityFactor - simple majority 1/2
	SimpleMajorityFactor = 2
)

Variables

View Source
var ServiceLookup = map[string]int32{
	"unknown":                      0,
	"mock":                         1,
	"arkeo-mainnet-fullnode":       2,
	"avax-mainnet-fullnode":        3,
	"avax-mainnet-archivenode":     4,
	"bch-mainnet-fullnode":         5,
	"bch-mainnet-lightnode":        6,
	"bnb-mainnet-fullnode":         7,
	"bsc-mainnet-fullnode":         8,
	"bsc-mainnet-archivenode":      9,
	"btc-mainnet-fullnode":         10,
	"btc-mainnet-lightnode":        11,
	"cardano-mainnet-relaynode":    12,
	"gaia-mainnet-rpc":             13,
	"doge-mainnet-fullnode":        14,
	"doge-mainnet-lightnode":       15,
	"etc-mainnet-archivenode":      16,
	"etc-mainnet-fullnode":         17,
	"etc-mainnet-lightnode":        18,
	"eth-mainnet-archivenode":      19,
	"eth-mainnet-fullnode":         20,
	"eth-mainnet-lightnode":        21,
	"ltc-mainnet-fullnode":         22,
	"ltc-mainnet-lightnode":        23,
	"optimism-mainnet-fullnode":    24,
	"osmosis-mainnet-fullnode":     25,
	"polkadot-mainnet-fullnode":    26,
	"polkadot-mainnet-lightnode":   27,
	"polkadot-mainnet-archivenode": 28,
	"polygon-mainnet-fullnode":     29,
	"polygon-mainnet-archivenode":  30,
	"sol-mainnet-fullnode":         31,
	"thorchain-mainnet-fullnode":   32,
	"bch-mainnet-unchained":        33,
	"btc-mainnet-unchained":        34,
	"bsc-mainnet-unchained":        36,
	"gaia-mainnet-unchained":       38,
	"doge-mainnet-unchained":       39,
	"eth-mainnet-unchained":        40,
	"avax-mainnet-unchained":       41,
	"ltc-mainnet-unchained":        42,
	"osmosis-mainnet-unchained":    43,
	"thorchain-mainnet-unchained":  44,
	"optimism-mainnet-unchained":   45,
	"gaia-mainnet-grpc":            46,
	"btc-mainnet-blockbook":        47,
	"ltc-mainnet-blockbook":        48,
	"bch-mainnet-blockbook":        49,
	"doge-mainnet-blockbook":       50,
}
View Source
var ServiceReverseLookup = map[Service]string{
	0:  "unknown",
	1:  "mock",
	2:  "arkeo-mainnet-fullnode",
	3:  "avax-mainnet-fullnode",
	4:  "avax-mainnet-archivenode",
	5:  "bch-mainnet-fullnode",
	6:  "bch-mainnet-lightnode",
	7:  "bnb-mainnet-fullnode",
	8:  "bsc-mainnet-fullnode",
	9:  "bsc-mainnet-archivenode",
	10: "btc-mainnet-fullnode",
	11: "btc-mainnet-lightnode",
	12: "cardano-mainnet-relaynode",
	13: "gaia-mainnet-rpc",
	14: "doge-mainnet-fullnode",
	15: "doge-mainnet-lightnode",
	16: "etc-mainnet-archivenode",
	17: "etc-mainnet-fullnode",
	18: "etc-mainnet-lightnode",
	19: "eth-mainnet-archivenode",
	20: "eth-mainnet-fullnode",
	21: "eth-mainnet-lightnode",
	22: "ltc-mainnet-fullnode",
	23: "ltc-mainnet-lightnode",
	24: "optimism-mainnet-fullnode",
	25: "osmosis-mainnet-fullnode",
	26: "polkadot-mainnet-fullnode",
	27: "polkadot-mainnet-lightnode",
	28: "polkadot-mainnet-archivenode",
	29: "polygon-mainnet-fullnode",
	30: "polygon-mainnet-archivenode",
	31: "sol-mainnet-fullnode",
	32: "thorchain-mainnet-fullnode",
	33: "bch-mainnet-unchained",
	34: "btc-mainnet-unchained",
	35: "bnb-mainnet-unchained",
	36: "bsc-mainnet-unchained",
	37: "bsc-mainnet-unchained",
	38: "gaia-mainnet-unchained",
	39: "doge-mainnet-unchained",
	40: "eth-mainnet-unchained",
	41: "avax-mainnet-unchained",
	42: "ltc-mainnet-unchained",
	43: "osmosis-mainnet-unchained",
	44: "thorchain-mainnet-unchained",
	45: "optimism-mainnet-unchained",
	46: "gaia-mainnet-grpc",
	47: "btc-mainnet-blockbook",
	48: "ltc-mainnet-blockbook",
	49: "bch-mainnet-blockbook",
	50: "doge-mainnet-blockbook",
}

Functions

func ConvertAndEncode

func ConvertAndEncode(hrp string, data []byte) (string, error)

ConvertAndEncode converts from a base64 encoded byte string to hex or base32 encoded byte string and then to bech32

func GetCurrentVersion

func GetCurrentVersion() int64

GetCurrentVersion - intended for unit tests, fetches the current version of arkeo via `version` file #nosec G304 this is a method only used for test purpose

func GetSafeShare

func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int

GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total

func GetUncappedShare

func GetUncappedShare(part, total, allocation cosmos.Int) (share cosmos.Int)

GetUncappedShare this method will panic if any of the input parameter can't be convert to cosmos.Dec which shouldn't happen

func MustParseURL

func MustParseURL(uri string) *url.URL

func NewSingleHostReverseProxy

func NewSingleHostReverseProxy(target *url.URL) *httputil.ReverseProxy

func RandStringBytesMask

func RandStringBytesMask(n int) string

RandStringBytesMask generate random string used for test purpose

func Tokens

func Tokens(i int64) int64

Types

type PubKey

type PubKey []byte
var EmptyPubKey PubKey

func NewPubKey

func NewPubKey(key string) (PubKey, error)

NewPubKey create a new instance of PubKey key is bech32 encoded string

func NewPubKeyFromCrypto

func NewPubKeyFromCrypto(pk cryptotypes.PubKey) (PubKey, error)

func (PubKey) Equals

func (pubKey PubKey) Equals(pubKey1 PubKey) bool

Equals check whether two are the same

func (PubKey) GetMyAddress

func (pubKey PubKey) GetMyAddress() (cosmos.AccAddress, error)

func (PubKey) IsEmpty

func (pubKey PubKey) IsEmpty() bool

IsEmpty to check whether it is empty

func (PubKey) MarshalJSON

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

MarshalJSON to Marshals to JSON using Bech32

func (PubKey) String

func (pubKey PubKey) String() string

String stringer implementation

func (*PubKey) UnmarshalJSON

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

UnmarshalJSON to Unmarshal from JSON assuming Bech32 encoding

type PubKeys

type PubKeys []PubKey

func (PubKeys) Contains

func (pks PubKeys) Contains(pk PubKey) bool

func (PubKeys) Equals

func (pks PubKeys) Equals(newPks PubKeys) bool

Equals check whether two pub keys are identical

func (PubKeys) String

func (pks PubKeys) String() string

String implement stringer interface

func (PubKeys) Strings

func (pks PubKeys) Strings() []string

func (PubKeys) Valid

func (pks PubKeys) Valid() error

type Service

type Service int32
const (
	EmptyService Service = iota
	MockService  Service = 1
	BTCService   Service = 10
	ETHService   Service = 20
)

func NewService

func NewService(serviceId string) (Service, error)

NewService create a new service

func (Service) Equals

func (c Service) Equals(c2 Service) bool

Equals compare two services to see whether they represent the same service

func (Service) IsEmpty

func (c Service) IsEmpty() bool

IsEmpty is to determinate whether the service is empty

func (Service) String

func (c Service) String() string

type Services

type Services []Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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