common

package
v0.0.0-...-c187892 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2016 License: MIT, GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Convenience Directories
	GoPath            = os.Getenv("GOPATH")
	ErisLtd           = filepath.Join(GoPath, "src", "github.com", "eris-ltd") // CSK: to deprecate
	ErisGo            = filepath.Join(GoPath, "src", "github.com", "eris-ltd") // CSK: to keep
	ErisGH            = "https://github.com/eris-ltd/"
	ErisRoot          = ResolveErisRoot()
	ErisContainerRoot = "/home/eris/.eris" // XXX: this is used as root in the `eris/base` image

	// Major Directories
	ActionsPath  = filepath.Join(ErisRoot, "actions")
	AppsPath     = filepath.Join(ErisRoot, "apps")   // previously "dapps"
	ChainsPath   = filepath.Join(ErisRoot, "chains") // previously "blockchains"
	KeysPath     = filepath.Join(ErisRoot, "keys")
	RemotesPath  = filepath.Join(ErisRoot, "remotes")
	ScratchPath  = filepath.Join(ErisRoot, "scratch")
	ServicesPath = filepath.Join(ErisRoot, "services")

	// Chains Directories
	HEAD             = filepath.Join(ChainsPath, "HEAD")
	DefaultChainPath = filepath.Join(ChainsPath, "default")
	AccountsTypePath = filepath.Join(ChainsPath, "account-types")
	ChainTypePath    = filepath.Join(ChainsPath, "chain-types")

	// Keys Directories
	KeysDataPath = filepath.Join(KeysPath, "data")
	KeyNamesPath = filepath.Join(KeysPath, "names")

	// Scratch Directories (basically eris' cache) (globally coordinated)
	DataContainersPath   = filepath.Join(ScratchPath, "data")
	LanguagesScratchPath = filepath.Join(ScratchPath, "languages") // previously "~/.eris/languages"
	LllcScratchPath      = filepath.Join(ScratchPath, "lllc")
	SolcScratchPath      = filepath.Join(ScratchPath, "sol")
	SerpScratchPath      = filepath.Join(ScratchPath, "ser")

	// Services Directories
	PersonalServicesPath = filepath.Join(ServicesPath, "global")

	// Deprecated Directories (remove on 0.12 release)
	BlockchainsPath = filepath.Join(ErisRoot, "blockchains")
	DappsPath       = filepath.Join(ErisRoot, "dapps")
	LanguagesPath   = filepath.Join(ErisRoot, "languages")
)
View Source
var (
	Big1     = big.NewInt(1)
	Big2     = big.NewInt(2)
	Big3     = big.NewInt(3)
	Big0     = big.NewInt(0)
	BigTrue  = Big1
	BigFalse = Big0
	Big32    = big.NewInt(32)
	Big256   = big.NewInt(0xff)
	Big257   = big.NewInt(257)
)

Common big integers often used

These should only be used by specific tooling rather than eris-cli level

eris update checks if old dirs exist & migrates them

These should only be used by specific tooling rather than eris-cli level

These should only be used by specific tooling rather than eris-cli level

These should only be used by specific tooling rather than eris-cli level

Functions

func AbsolutePath

func AbsolutePath(Datadir string, filename string) string

func AddHex

func AddHex(s string) string

func Address

func Address(slice []byte) (addr []byte)

func AddressStringToBytes

func AddressStringToBytes(addr string) []byte

func Big

func Big(num string) *big.Int

Big

Shortcut for new(big.Int).SetString(..., 0)

func BigCopy

func BigCopy(src *big.Int) *big.Int

Big copy

Creates a copy of the given big integer

func BigD

func BigD(data []byte) *big.Int

BigD

Shortcut for new(big.Int).SetBytes(...)

func BigMax

func BigMax(x, y *big.Int) *big.Int

Big max

Returns the maximum size big integer

func BigMin

func BigMin(x, y *big.Int) *big.Int

Big min

Returns the minimum size big integer

func BigPow

func BigPow(a, b int) *big.Int

Big pow

Returns the power of two big integers

func BigToBytes

func BigToBytes(num *big.Int, base int) []byte

Big to bytes

Returns the bytes of a big integer with the size specified by **base** Attempts to pad the byte array with zeros.

func BitTest

func BitTest(num *big.Int, i int) bool

func Bytes2Hex

func Bytes2Hex(d []byte) string

func ClearDir

func ClearDir(dir string) error

func Coerce2Hex

func Coerce2Hex(s string) string

s can be string, hex, or int. returns properly formatted 32byte hex value

func CoerceHexAndPad

func CoerceHexAndPad(aa string, padright bool) string

func Copy

func Copy(src, dst string) error

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

Copy bytes

Returns an exact copy of the provided bytes

func Editor

func Editor(file string) error

func Exit

func Exit(err error)

func FieldFromTag

func FieldFromTag(v reflect.Value, field string) (string, error)

func FirstBitSet

func FirstBitSet(v *big.Int) int

func GenerateSingle

func GenerateSingle(cmd *cobra.Command, out *bytes.Buffer, linkHandler func(string) string, specs []string, render_dir string)

func GenerateSpecs

func GenerateSpecs(dir, render_dir, front_matter string) []string

func GenerateTree

func GenerateTree(cmd *cobra.Command, dir string, specs []string, front_matter, base_url string)

func IfExit

func IfExit(err error)

func InitDataDir

func InitDataDir(Datadir string) error

func InitErisDir

func InitErisDir() (err error)

Create the default eris tree

func IsHex

func IsHex(s string) bool

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

func LeftPadString

func LeftPadString(str string, l int) string

func NewInvalidKindErr

func NewInvalidKindErr(kind, k reflect.Kind) error

func NumberToBytes

func NumberToBytes(num interface{}, N int) []byte

keeps N bytes of the conversion

func ReadJson

func ReadJson(config interface{}, config_file string) error

func ResolveErisRoot

func ResolveErisRoot() string

TODO: [csk] give this a default string if folks want it somewhere besides ~/.eris ...?

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

func RightPadString

func RightPadString(str string, l int) string

func S256

func S256(x *big.Int) *big.Int

func SetProperty

func SetProperty(cv reflect.Value, field string, value interface{}) error

Set a field in a struct value Field can be field name or json tag name Values can be strings that can be cast to int or bool

only handles strings, ints, bool

func StripHex

func StripHex(s string) string

func StripOnes

func StripOnes(s string) string

func StripZeros

func StripZeros(s string) string

func U256

func U256(x *big.Int) *big.Int

func UnLeftPadBytes

func UnLeftPadBytes(slice []byte) []byte

func UnRightPadBytes

func UnRightPadBytes(slice []byte) []byte

func Usr

func Usr() string

func WriteFile

func WriteFile(data, path string) error

func WriteJson

func WriteJson(config interface{}, config_file string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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