util

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Eb = &EventBus{
	Subscribers: map[string]DataChannelSlice{},
}

Functions

func CalcGasCost

func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int

CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)

func ConvertNftResult

func ConvertNftResult(gameNftAddress string, res []response.NftResult) []response.NftResult

func CreateDir

func CreateDir(dirs ...string) (err error)

func EventSignHash

func EventSignHash(eventTopic string) string

func GetABI

func GetABI(abiJSON string) abi.ABI

func GetIntFromRedis

func GetIntFromRedis(key string, client *redis.Client) (int64, bool, error)

func GetStringFromRedis

func GetStringFromRedis(key string, client *redis.Client) (string, bool, error)

func GetTxMethodName

func GetTxMethodName(method string) []byte

func IncrFromRedis

func IncrFromRedis(key string, client *redis.Client) error

func IsValidAddress

func IsValidAddress(iaddress interface{}) bool

IsValidAddress validate hex address

func IsZeroAddress

func IsZeroAddress(iaddress interface{}) bool

IsZeroAddress validate if it's a 0 address

func Lock

func Lock(key string, value interface{}, duration time.Duration, client *redis.Client) (bool, error)

func ParseBalance

func ParseBalance(balance *big.Int) string

func ParseCacheData

func ParseCacheData(cds []model.CacheData) map[string][]model.CacheData

func ParseMetadata

func ParseMetadata(nr []response.NftResult) []model.CacheData

func PathExists

func PathExists(path string) (bool, error)

func QueryBlockHeight

func QueryBlockHeight() (uint64, error)

func RmKeyByPrefix

func RmKeyByPrefix(prefix string, client *redis.Client)

func SetFromRedis

func SetFromRedis(key string, value interface{}, duration time.Duration, client *redis.Client) error

func SigRSV

func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)

SigRSV signatures R S V returned as arrays

func ToDecimal

func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal

ToDecimal wei to decimals

func ToWei

func ToWei(iamount interface{}, decimals int) *big.Int

ToWei decimals to wei

func UnLock

func UnLock(key string, client *redis.Client) error

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

func NewCounter

func NewCounter(r int, cycle time.Duration) Counter

func (*Counter) Ok

func (l *Counter) Ok(weight, rate int) bool

func (*Counter) Reset

func (l *Counter) Reset(t time.Time, rate int)

type DataChannel

type DataChannel chan DataEvent

type DataChannelSlice

type DataChannelSlice []DataChannel

type DataEvent

type DataEvent struct {
	Data  interface{}
	Topic string
}

type EventBus

type EventBus struct {
	Subscribers map[string]DataChannelSlice
	// contains filtered or unexported fields
}

func (*EventBus) Publish

func (eb *EventBus) Publish(topic string, data interface{})

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(topic string, ch DataChannel)

type SpikeTx

type SpikeTx struct {
	Data      []byte
	To        string
	BscClient *ethclient.Client
	Nonce     uint64
	From      common.Address
}

func (*SpikeTx) ConstructionTransaction

func (s *SpikeTx) ConstructionTransaction() (*types.Transaction, error)

Jump to

Keyboard shortcuts

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