common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package common includes utility and constants such as unit (wei, ether)

Index

Constants

View Source
const (
	// DbConfigTblName is a config table name
	DbConfigTblName = "Config"
	// DbConfigPropName is a property colum name
	DbConfigPropName = "Property"
	// DbConfigValName is a value colum name
	DbConfigValName = "Value"
)

Variables

View Source
var UnitFloatMap = map[string]*big.Float{
	"noether":    big.NewFloat(0),
	"wei":        big.NewFloat(1),
	"kwei":       big.NewFloat(1000),
	"Kwei":       big.NewFloat(1000),
	"babbage":    big.NewFloat(1000),
	"femtoether": big.NewFloat(1000),
	"mwei":       big.NewFloat(1000000),
	"Mwei":       big.NewFloat(1000000),
	"lovelace":   big.NewFloat(1000000),
	"picoether":  big.NewFloat(1000000),
	"gwei":       big.NewFloat(1000000000),
	"Gwei":       big.NewFloat(1000000000),
	"shannon":    big.NewFloat(1000000000),
	"nanoether":  big.NewFloat(1000000000),
	"nano":       big.NewFloat(1000000000),
	"szabo":      big.NewFloat(1000000000000),
	"microether": big.NewFloat(1000000000000),
	"micro":      big.NewFloat(1000000000000),
	"finney":     big.NewFloat(1000000000000000),
	"milliether": big.NewFloat(1000000000000000),
	"milli":      big.NewFloat(1000000000000000),
	"ether":      big.NewFloat(1000000000000000000),
	"kether":     big.NewFloat(1000000000000000000000),
	"grand":      big.NewFloat(1000000000000000000000),
	"mether":     big.NewFloat(1000000000000000000000000),
	"gether":     big.NewFloat(1000000000000000000000000000),
	"tether":     big.NewFloat(1000000000000000000000000000000),
}

UnitFloatMap is a map from unit string to value as big float

View Source
var UnitIntMap = map[string]*big.Int{
	"noether":    big.NewInt(0),
	"wei":        big.NewInt(1),
	"kwei":       big.NewInt(1000),
	"Kwei":       big.NewInt(1000),
	"babbage":    big.NewInt(1000),
	"femtoether": big.NewInt(1000),
	"mwei":       big.NewInt(1000000),
	"Mwei":       big.NewInt(1000000),
	"lovelace":   big.NewInt(1000000),
	"picoether":  big.NewInt(1000000),
	"gwei":       big.NewInt(1000000000),
	"Gwei":       big.NewInt(1000000000),
	"shannon":    big.NewInt(1000000000),
	"nanoether":  big.NewInt(1000000000),
	"nano":       big.NewInt(1000000000),
	"szabo":      big.NewInt(1000000000000),
	"microether": big.NewInt(1000000000000),
	"micro":      big.NewInt(1000000000000),
	"finney":     big.NewInt(1000000000000000),
	"milliether": big.NewInt(1000000000000000),
	"milli":      big.NewInt(1000000000000000),
	"ether":      big.NewInt(1000000000000000000),
	"kether":     big.NewInt(-1),
	"grand":      big.NewInt(-1),
	"mether":     big.NewInt(-1),
	"gether":     big.NewInt(-1),
	"tether":     big.NewInt(-1),
}

UnitIntMap is a map from unit string to value as big int

View Source
var UnitStrMap = map[string]string{
	"noether":    "0",
	"wei":        "1",
	"kwei":       "1000",
	"Kwei":       "1000",
	"babbage":    "1000",
	"femtoether": "1000",
	"mwei":       "1000000",
	"Mwei":       "1000000",
	"lovelace":   "1000000",
	"picoether":  "1000000",
	"gwei":       "1000000000",
	"Gwei":       "1000000000",
	"shannon":    "1000000000",
	"nanoether":  "1000000000",
	"nano":       "1000000000",
	"szabo":      "1000000000000",
	"microether": "1000000000000",
	"micro":      "1000000000000",
	"finney":     "1000000000000000",
	"milliether": "1000000000000000",
	"milli":      "1000000000000000",
	"ether":      "1000000000000000000",
	"kether":     "1000000000000000000000",
	"grand":      "1000000000000000000000",
	"mether":     "1000000000000000000000000",
	"gether":     "1000000000000000000000000000",
	"tether":     "1000000000000000000000000000000",
}

UnitStrMap is a map from unit string to value string

Functions

func FindOffsetNBase

func FindOffsetNBase(input string) (offset, base int)

FindOffsetNBase finds offset and base to parse string to int

func RandomUint64

func RandomUint64() uint64

RandomUint64 generates random uint64

Types

type DbConfigResult

type DbConfigResult struct {
	// Property indicates DB column named "Property"
	Property string `json:"property"`
	// Value
	Value string `json:"value"`
}

DbConfigResult represents a row from DB query result

Jump to

Keyboard shortcuts

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