{"modulePath":"github.com/Evolution404/simcore","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package common\n\nPackage common contains various helper functions.\n\n## Constants\n\n```go\nconst (\n\t// HashLength is the expected length of the hash\n\tHashLength = 32\n\t// AddressLength is the expected length of the address\n\tAddressLength = 20\n)\n```\nLengths of hashes and addresses in bytes.\n\n## Variables\n\n```go\nvar (\n\tBig1   = big.NewInt(1)\n\tBig2   = big.NewInt(2)\n\tBig3   = big.NewInt(3)\n\tBig0   = big.NewInt(0)\n\tBig32  = big.NewInt(32)\n\tBig256 = big.NewInt(256)\n\tBig257 = big.NewInt(257)\n)\n```\nCommon big integers often used\n\n## Functions\n\n```go\nfunc AbsolutePath(datadir string, filename string) string\n```\nAbsolutePath returns datadir + filename, or filename if it is absolute.\n\n```go\nfunc Bytes2Hex(d []byte) string\n```\nBytes2Hex returns the hexadecimal encoding of d.\n\n```go\nfunc CopyBytes(b []byte) (copiedBytes []byte)\n```\nCopyBytes returns an exact copy of the provided bytes.\n\n```go\nfunc FileExist(filePath string) bool\n```\nFileExist checks if a file exists at filePath.\n\n```go\nfunc FromHex(s string) []byte\n```\nFromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with \"0x\".\n\n```go\nfunc Hex2Bytes(str string) []byte\n```\nHex2Bytes returns the bytes represented by the hexadecimal string str.\n\n```go\nfunc Hex2BytesFixed(str string, flen int) []byte\n```\nHex2BytesFixed returns bytes of a specified fixed length flen.\n\n```go\nfunc IsHexAddress(s string) bool\n```\nIsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.\n\n```go\nfunc LeftPadBytes(slice []byte, l int) []byte\n```\nLeftPadBytes zero-pads slice to the left up to length l.\n\n```go\nfunc LoadJSON(file string, val interface{}) error\n```\nLoadJSON reads the given file and unmarshals its content.\n\n```go\nfunc MakeName(name, version string) string\n```\nMakeName creates a node name that follows the ethereum convention for such names. It adds the operation system name and Go runtime version the name.\n\n```go\nfunc PrintDeprecationWarning(str string)\n```\nPrintDeprecationWarning prints the given string in a box using fmt.Println.\n\n```go\nfunc Report(extra ...interface{})\n```\nReport gives off a warning requesting the user to submit an issue to the github tracker.\n\n```go\nfunc RightPadBytes(slice []byte, l int) []byte\n```\nRightPadBytes zero-pads slice to the right up to length l.\n\n```go\nfunc TrimLeftZeroes(s []byte) []byte\n```\nTrimLeftZeroes returns a subslice of s without leading zeroes\n\n```go\nfunc TrimRightZeroes(s []byte) []byte\n```\nTrimRightZeroes returns a subslice of s without trailing zeroes\n\n## Types\n\n```go\ntype Address [AddressLength]byte\n```\nAddress represents the 20 byte address of an Ethereum account.\n\n```go\nfunc BigToAddress(b *big.Int) Address\n```\nBigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc BytesToAddress(b []byte) Address\n```\nBytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc HexToAddress(s string) Address\n```\nHexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.\n\n```go\nfunc (a Address) Bytes() []byte\n```\nBytes gets the string representation of the underlying address.\n\n```go\nfunc (a Address) Format(s fmt.State, c rune)\n```\nFormat implements fmt.Formatter. Address supports the %v, %s, %q, %x, %X and %d format verbs.\n\n```go\nfunc (a Address) Hash() Hash\n```\nHash converts an address to a hash by left-padding it with zeros.\n\n```go\nfunc (a Address) Hex() string\n```\nHex returns an EIP55-compliant hex string representation of the address.\n\n```go\nfunc (a Address) ImplementsGraphQLType(name string) bool\n```\nImplementsGraphQLType returns true if Hash implements the specified GraphQL type.\n\n```go\nfunc (a Address) MarshalText() ([]byte, error)\n```\nMarshalText returns the hex representation of a.\n\n```go\nfunc (a *Address) Scan(src interface{}) error\n```\nScan implements Scanner for database/sql.\n\n```go\nfunc (a *Address) SetBytes(b []byte)\n```\nSetBytes sets the address to the value of b. If b is larger than len(a), b will be cropped from the left.\n\n```go\nfunc (a Address) String() string\n```\nString implements fmt.Stringer.\n\n```go\nfunc (a *Address) UnmarshalGraphQL(input interface{}) error\n```\nUnmarshalGraphQL unmarshals the provided GraphQL query data.\n\n```go\nfunc (a *Address) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON parses a hash in hex syntax.\n\n```go\nfunc (a *Address) UnmarshalText(input []byte) error\n```\nUnmarshalText parses a hash in hex syntax.\n\n```go\nfunc (a Address) Value() (driver.Value, error)\n```\nValue implements valuer for database/sql.\n\n```go\ntype Hash [HashLength]byte\n```\nHash represents the 32 byte Keccak256 hash of arbitrary data.\n\n```go\nfunc BigToHash(b *big.Int) Hash\n```\nBigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc BytesToHash(b []byte) Hash\n```\nBytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc HexToHash(s string) Hash\n```\nHexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc (h Hash) Big() *big.Int\n```\nBig converts a hash to a big integer.\n\n```go\nfunc (h Hash) Bytes() []byte\n```\nBytes gets the byte representation of the underlying hash.\n\n```go\nfunc (h Hash) Format(s fmt.State, c rune)\n```\nFormat implements fmt.Formatter. Hash supports the %v, %s, %q, %x, %X and %d format verbs.\n\n```go\nfunc (h Hash) Generate(rand *rand.Rand, size int) reflect.Value\n```\nGenerate implements testing/quick.Generator.\n\n```go\nfunc (h Hash) Hex() string\n```\nHex converts a hash to a hex string.\n\n```go\nfunc (Hash) ImplementsGraphQLType(name string) bool\n```\nImplementsGraphQLType returns true if Hash implements the specified GraphQL type.\n\n```go\nfunc (h Hash) MarshalText() ([]byte, error)\n```\nMarshalText returns the hex representation of h.\n\n```go\nfunc (h *Hash) Scan(src interface{}) error\n```\nScan implements Scanner for database/sql.\n\n```go\nfunc (h *Hash) SetBytes(b []byte)\n```\nSetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.\n\n```go\nfunc (h Hash) String() string\n```\nString implements the stringer interface and is used also by the logger when doing full logging into a file.\n\n```go\nfunc (h Hash) TerminalString() string\n```\nTerminalString implements log.TerminalStringer, formatting a string for console output during logging.\n\n```go\nfunc (h *Hash) UnmarshalGraphQL(input interface{}) error\n```\nUnmarshalGraphQL unmarshals the provided GraphQL query data.\n\n```go\nfunc (h *Hash) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON parses a hash in hex syntax.\n\n```go\nfunc (h *Hash) UnmarshalText(input []byte) error\n```\nUnmarshalText parses a hash in hex syntax.\n\n```go\nfunc (h Hash) Value() (driver.Value, error)\n```\nValue implements valuer for database/sql.\n\n```go\ntype MixedcaseAddress struct {\n\t// contains filtered or unexported fields\n}\n```\nMixedcaseAddress retains the original string, which may or may not be correctly checksummed\n\n```go\nfunc NewMixedcaseAddress(addr Address) MixedcaseAddress\n```\nNewMixedcaseAddress constructor (mainly for testing)\n\n```go\nfunc NewMixedcaseAddressFromString(hexaddr string) (*MixedcaseAddress, error)\n```\nNewMixedcaseAddressFromString is mainly meant for unit-testing\n\n```go\nfunc (ma *MixedcaseAddress) Address() Address\n```\nAddress returns the address\n\n```go\nfunc (ma *MixedcaseAddress) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the original value\n\n```go\nfunc (ma *MixedcaseAddress) Original() string\n```\nOriginal returns the mixed-case input string\n\n```go\nfunc (ma *MixedcaseAddress) String() string\n```\nString implements fmt.Stringer\n\n```go\nfunc (ma *MixedcaseAddress) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON parses MixedcaseAddress\n\n```go\nfunc (ma *MixedcaseAddress) ValidChecksum() bool\n```\nValidChecksum returns true if the address has valid checksum\n\n```go\ntype PrettyAge time.Time\n```\nPrettyAge is a pretty printed version of a time.Duration value that rounds the values up to a single most significant unit, days/weeks/years included.\n\n```go\nfunc (t PrettyAge) String() string\n```\nString implements the Stringer interface, allowing pretty printing of duration values rounded to the most significant time unit.\n\n```go\ntype PrettyDuration time.Duration\n```\nPrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.\n\n```go\nfunc (d PrettyDuration) String() string\n```\nString implements the Stringer interface, allowing pretty printing of duration values rounded to three decimals.\n\n```go\ntype StorageSize float64\n```\nStorageSize is a wrapper around a float value that supports user friendly formatting.\n\n```go\nfunc (s StorageSize) String() string\n```\nString implements the stringer interface.\n\n```go\nfunc (s StorageSize) TerminalString() string\n```\nTerminalString implements log.TerminalStringer, formatting a string for console output during logging.\n\n```go\ntype UnprefixedAddress Address\n```\nUnprefixedAddress allows marshaling an Address without 0x prefix.\n\n```go\nfunc (a UnprefixedAddress) MarshalText() ([]byte, error)\n```\nMarshalText encodes the address as hex.\n\n```go\nfunc (a *UnprefixedAddress) UnmarshalText(input []byte) error\n```\nUnmarshalText decodes the address from hex. The 0x prefix is optional.\n\n```go\ntype UnprefixedHash Hash\n```\nUnprefixedHash allows marshaling a Hash without 0x prefix.\n\n```go\nfunc (h UnprefixedHash) MarshalText() ([]byte, error)\n```\nMarshalText encodes the hash as hex.\n\n```go\nfunc (h *UnprefixedHash) UnmarshalText(input []byte) error\n```\nUnmarshalText decodes the hash from hex. The 0x prefix is optional.\n\n","path":"github.com/Evolution404/simcore/common","name":"common","synopsis":"Package common contains various helper functions.","isRedistributable":true}
