utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K = 1 << 10
	M = 1 << 20
	G = 1 << 30
	T = 1 << 40
)
View Source
const (
	MaxVersion           = "2"
	Version              = MaxVersion + ".1.0"
	TokenAddr            = "0x3455e0b8259144a4C127faCc7d064A0F2424C8a8"
	LicenseContractAddr  = "0xCbbE47ce51382e2F7cD4E5771587F9Cb5c91Ad33"
	DefaultCmdPort       = 16665
	WebSocketServicePort = 16666
	ExtraServicePort     = 16667
	ChainServicePort     = 16668
	DefaultP2pPort       = 16669
	TestInfuraHttp       = "https://kovan.infura.io/v3/a3a5c09826a246d0bfbef8084b81df1f"
	TestInfuraWss        = "wss://kovan.infura.io/ws/v3/a3a5c09826a246d0bfbef8084b81df1f"
)

Variables

View Source
var (
	InfuraUrl   = ""
	InfuraSubWS = ""
)

Functions

func AbsolutePath

func AbsolutePath(datadir string, filename string) string

func BaseUsrDir

func BaseUsrDir(dir string) string

func DoHttpJSONDataPost added in v1.2.2

func DoHttpJSONDataPost(jsonData []byte, url string) ([]byte, error)

func FileExists

func FileExists(path string) bool

func GetExternalIP

func GetExternalIP() (string, error)

func Home added in v1.2.2

func Home() (string, error)

func InitConfig

func InitConfig(c *Config)

InitConfig for server init

func InitInfura added in v1.2.2

func InitInfura(http, wss string)

InitInfura for client init

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

func Keccak256

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

func LogInst

func LogInst() *zerolog.Logger

func MaxInt64 added in v1.2.2

func MaxInt64(a, b int64) int64

func MinInt64 added in v1.2.2

func MinInt64(a, b int64) int64

func OpenAndReadAll added in v1.2.2

func OpenAndReadAll(filename string) (data []byte, err error)

func Save2File added in v1.2.2

func Save2File(data []byte, filename string) error

func ToISO8601

func ToISO8601(t time.Time) string

func WriteToFile

func WriteToFile(file string, content []byte) error

Types

type ByteSize

type ByteSize int64

func (ByteSize) String

func (bs ByteSize) String() string

type Config

type Config struct {
	LogLevel   zerolog.Level `json:"log_level"`
	InfuraHttp string        `json:"infura_http"`
	InfuraWss  string        `json:"infura_wss"`
}

func DefaultConfig added in v1.2.2

func DefaultConfig(isMain bool) *Config

func (Config) String

func (c Config) String() string

type IP

type IP struct {
	Query string
}

type KeccakState

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

type NinjaDB added in v1.2.2

type NinjaDB struct {
	*leveldb.DB
}

func NewNinjaDB added in v1.2.2

func NewNinjaDB(dir string) (*NinjaDB, error)

func (*NinjaDB) GetJson added in v1.2.2

func (d *NinjaDB) GetJson(key []byte, val interface{}) error

func (*NinjaDB) MustGetJson added in v1.2.2

func (d *NinjaDB) MustGetJson(key []byte, val interface{})

func (*NinjaDB) MustPutJson added in v1.2.2

func (d *NinjaDB) MustPutJson(key []byte, val interface{})

func (*NinjaDB) PutJson added in v1.2.2

func (d *NinjaDB) PutJson(key []byte, val interface{}) error

type Salt

type Salt [aes.BlockSize]byte

func NewSalt

func NewSalt() (s Salt, err error)

type StorageSize

type StorageSize float64

func (StorageSize) String

func (s StorageSize) String() string

func (StorageSize) TerminalString

func (s StorageSize) TerminalString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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