Documentation
¶
Index ¶
- Constants
- Variables
- func CopyBytes(b []byte) (copiedBytes []byte)
- func Decode(input string) ([]byte, error)
- func EmptyHash(h Hash) bool
- func Encode(b []byte) string
- func EncodeBig(bigint *big.Int) string
- func FileExist(filePath string) bool
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func IsHexAddress(s string) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func LoadJSON(file string, val interface{}) error
- func MustDecode(input string) []byte
- func Report(extra ...interface{})
- func RightPadBytes(slice []byte, l int) []byte
- func UnmarshalFixedText(typname string, input, out []byte) error
- type AbsTime
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hex() string
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- type BlockNonce
- type Bytes
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Set(other Hash)
- func (h *Hash) SetBytes(b []byte)
- func (h *Hash) SetString(s string)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- type PrettyDuration
- type StorageSize
Constants ¶
const ( //HashLength length of hash string HashLength = 32 //AddressLength length of account address AddressLength = 20 )
Variables ¶
var ( //ErrEmptyString string is empty ErrEmptyString = &decError{"empty hex string"} //ErrSyntax string format is not hex ErrSyntax = &decError{"invalid hex string"} //ErrMissingPrefix string for hex without 0x prefix ErrMissingPrefix = &decError{"hex string without 0x prefix"} //ErrOddLength string length is odd not even ErrOddLength = &decError{"hex string of odd length"} //ErrEmptyNumber string only contains 0x prefix ErrEmptyNumber = &decError{"hex string \"0x\""} //ErrLeadingZero hex number with zero beginning ErrLeadingZero = &decError{"hex number with leading zero digits"} //ErrUint64Range hex number is larger than 64 bit len ErrUint64Range = &decError{"hex number > 64 bits"} //ErrUintRange hex number is larger than uint len ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)} //ErrBig256Range hex number is larger than 256 bit len ErrBig256Range = &decError{"hex number > 256 bits"} )
var ( Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big0 = big.NewInt(0) Big32 = big.NewInt(32) Big256 = big.NewInt(0xff) Big257 = big.NewInt(257) )
Common big integers often used
Functions ¶
func CopyBytes ¶
CopyBytes returns a duplication of self byte array Input - copiedBytes: pointer to destination Output - copiedBytes: copy byte array to destination
func EncodeBig ¶
EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded dacChain address or not.
func LeftPadBytes ¶
func MustDecode ¶
MustDecode decodes a hex string with 0x prefix. It panics for invalid input.
func Report ¶
func Report(extra ...interface{})
Report gives off a warning requesting the user to submit an issue to the github tracker.
func RightPadBytes ¶
func UnmarshalFixedText ¶
UnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address
func BigToAddress ¶
func BytesToAddress ¶
BytesToAddress set the address to the value to b
func HexToAddress ¶
HexToAddress set the address to the value of s
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type BlockNonce ¶
type BlockNonce [8]byte
A BlockNonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.
func EncodeNonce ¶
func EncodeNonce(i uint64) BlockNonce
EncodeNonce converts the given integer to a block nonce.
type Bytes ¶
type Bytes []byte
Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (Bytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
SetBytes set the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).
func (*Hash) SetString ¶
Set string `s` to h. If s is larger than len(h) s will be cropped (from left) to fit.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type PrettyDuration ¶
PrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.
type StorageSize ¶
type StorageSize float64
func (StorageSize) Int64 ¶
func (self StorageSize) Int64() int64
func (StorageSize) String ¶
func (self StorageSize) String() string