import "github.com/axiomzen/go-ethereum/common"
Package common contains various helper functions.
big.go bytes.go debug.go format.go path.go size.go test_utils.go types.go
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Lengths of hashes and addresses in bytes.
var ( Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big0 = big.NewInt(0) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) )
Common big integers often used
AbsolutePath returns datadir + filename, or filename if it is absolute.
Bytes2Hex returns the hexadecimal encoding of d.
CopyBytes returns an exact copy of the provided bytes.
FileExist checks if a file exists at filePath.
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
Hex2Bytes returns the bytes represented by the hexadecimal string str.
Hex2BytesFixed returns bytes of a specified fixed length flen.
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
LeftPadBytes zero-pads slice to the left up to length l.
LoadJSON reads the given file and unmarshals its content.
MakeName creates a node name that follows the ethereum convention for such names. It adds the operation system name and Go runtime version the name.
PrintDepricationWarning prinst the given string in a box using fmt.Println.
func Report(extra ...interface{})
Report gives off a warning requesting the user to submit an issue to the github tracker.
RightPadBytes zero-pads slice to the right up to length l.
ToHex returns the hex representation of b, prefixed with '0x'. For empty slices, the return value is "0x0".
Deprecated: use hexutil.Encode instead.
ToHexArray creates a array of hex-string based on []byte
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
Bytes gets the string representation of the underlying address.
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
Hash converts an address to a hash by left-padding it with zeros.
Hex returns an EIP55-compliant hex string representation of the address.
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
MarshalText returns the hex representation of a.
Scan implements Scanner for database/sql.
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
String implements fmt.Stringer.
UnmarshalGraphQL unmarshals the provided GraphQL query data.
UnmarshalJSON parses a hash in hex syntax.
UnmarshalText parses a hash in hex syntax.
Value implements valuer for database/sql.
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
Big converts a hash to a big integer.
Bytes gets the byte representation of the underlying hash.
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
Generate implements testing/quick.Generator.
Hex converts a hash to a hex string.
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
MarshalText returns the hex representation of h.
Scan implements Scanner for database/sql.
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
String implements the stringer interface and is used also by the logger when doing full logging into a file.
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
UnmarshalGraphQL unmarshals the provided GraphQL query data.
UnmarshalJSON parses a hash in hex syntax.
UnmarshalText parses a hash in hex syntax.
Value implements valuer for database/sql.
type MixedcaseAddress struct {
// contains filtered or unexported fields
}
MixedcaseAddress retains the original string, which may or may not be correctly checksummed
func NewMixedcaseAddress(addr Address) MixedcaseAddress
NewMixedcaseAddress constructor (mainly for testing)
func NewMixedcaseAddressFromString(hexaddr string) (*MixedcaseAddress, error)
NewMixedcaseAddressFromString is mainly meant for unit-testing
func (ma *MixedcaseAddress) Address() Address
Address returns the address
func (ma *MixedcaseAddress) MarshalJSON() ([]byte, error)
MarshalJSON marshals the original value
func (ma *MixedcaseAddress) Original() string
Original returns the mixed-case input string
func (ma *MixedcaseAddress) String() string
String implements fmt.Stringer
func (ma *MixedcaseAddress) UnmarshalJSON(input []byte) error
UnmarshalJSON parses MixedcaseAddress
func (ma *MixedcaseAddress) ValidChecksum() bool
ValidChecksum returns true if the address has valid checksum
PrettyAge 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.
String implements the Stringer interface, allowing pretty printing of duration values rounded to the most significant time unit.
PrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.
func (d PrettyDuration) String() string
String implements the Stringer interface, allowing pretty printing of duration values rounded to three decimals.
StorageSize is a wrapper around a float value that supports user friendly formatting.
func (s StorageSize) String() string
String implements the stringer interface.
func (s StorageSize) TerminalString() string
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
UnprefixedAddress allows marshaling an Address without 0x prefix.
func (a UnprefixedAddress) MarshalText() ([]byte, error)
MarshalText encodes the address as hex.
func (a *UnprefixedAddress) UnmarshalText(input []byte) error
UnmarshalText decodes the address from hex. The 0x prefix is optional.
UnprefixedHash allows marshaling a Hash without 0x prefix.
func (h UnprefixedHash) MarshalText() ([]byte, error)
MarshalText encodes the hash as hex.
func (h *UnprefixedHash) UnmarshalText(input []byte) error
UnmarshalText decodes the hash from hex. The 0x prefix is optional.
Path | Synopsis |
---|---|
bitutil | Package bitutil implements fast bitwise operations. |
compiler | Package compiler wraps the Solidity and Vyper compiler executables (solc; vyper). |
fdlimit | |
hexutil | Package hexutil implements hex encoding with 0x prefix. |
math | Package math provides integer math utilities. |
mclock | Package mclock is a wrapper for a monotonic clock source |
prque | Package prque implements a priority queue data structure supporting arbitrary value types and int64 priorities. |
Package common imports 17 packages (graph). Updated 2019-07-06. Refresh now. Tools for package owners.