Documentation ¶
Index ¶
- Constants
- Variables
- func Bytes2Hex(d []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func DecodeHex(input string) ([]byte, error)
- func DecodeHexBig(input string) (*big.Int, error)
- func DecodeHexUint64(input string) (uint64, error)
- func EncodeHex(b []byte) string
- func EncodeHexBig(bigint *big.Int) string
- func EncodeHexUint64(i uint64) string
- func FromHex(s string) []byte
- func HasHexPrefix(str string) bool
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func IsHex(str string) bool
- func IsHexAddress(s string) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func MustDecodeHex(input string) []byte
- func MustDecodeHexBig(input string) *big.Int
- func MustDecodeHexUint64(input string) uint64
- func RegisterExtension(typ *int8, f func() msgp.Extension) error
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) string
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (z *Address) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Address) EncodeMsg(en *msgp.Writer) (err error)
- func (*Address) ExtensionType() int8
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) HexLower() string
- func (*Address) Len() int
- func (a *Address) MarshalBinaryTo(b []byte) error
- func (z *Address) MarshalMsg(b []byte) (o []byte, err error)
- func (a Address) MarshalText() ([]byte, error)
- func (z *Address) Msgsize() (s int)
- func (a *Address) SetBytes(b []byte)
- func (a Address) Str() string
- func (a *Address) UnmarshalBinary(b []byte) error
- func (a *Address) UnmarshalJSON(b []byte) error
- func (z *Address) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (a *Address) UnmarshalText(input []byte) error
- type BigInt
- func (z *BigInt) DecodeMsg(dc *msgp.Reader) (err error)
- func (z BigInt) EncodeMsg(en *msgp.Writer) (err error)
- func (bigInt *BigInt) ExtensionType() int8
- func (bigInt BigInt) Get() big.Int
- func (bigInt *BigInt) Len() int
- func (bigInt *BigInt) MarshalBinaryTo(b []byte) error
- func (z BigInt) MarshalMsg(b []byte) (o []byte, err error)
- func (b BigInt) MarshalText() ([]byte, error)
- func (z BigInt) Msgsize() (s int)
- func (bigInt *BigInt) Put(in big.Int) *BigInt
- func (b *BigInt) String() string
- func (b *BigInt) ToInt() *big.Int
- func (bigInt *BigInt) UnmarshalBinary(b []byte) error
- func (b *BigInt) UnmarshalJSON(input []byte) error
- func (z *BigInt) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (b *BigInt) UnmarshalText(input []byte) error
- type Bloom
- func (b Bloom) Big() *big.Int
- func (b Bloom) Bytes() []byte
- func (z *Bloom) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Bloom) EncodeMsg(en *msgp.Writer) (err error)
- func (bloom *Bloom) ExtensionType() int8
- func (bloom *Bloom) Len() int
- func (bloom *Bloom) MarshalBinaryTo(b []byte) error
- func (z *Bloom) MarshalMsg(b []byte) (o []byte, err error)
- func (b Bloom) MarshalText() ([]byte, error)
- func (z *Bloom) Msgsize() (s int)
- func (b *Bloom) SetBytes(d []byte)
- func (bloom *Bloom) UnmarshalBinary(b []byte) error
- func (z *Bloom) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (b *Bloom) UnmarshalText(input []byte) error
- type BytesForJson
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (z *Hash) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Hash) EncodeMsg(en *msgp.Writer) (err error)
- func (h *Hash) Equal(in *Hash) bool
- func (*Hash) ExtensionType() int8
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Hex() string
- func (*Hash) Len() int
- func (h *Hash) MarshalBinaryTo(b []byte) error
- func (z *Hash) MarshalMsg(b []byte) (o []byte, err error)
- func (h Hash) MarshalText() ([]byte, error)
- func (z *Hash) Msgsize() (s int)
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) Str() string
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalBinary(b []byte) error
- func (h *Hash) UnmarshalJSON(b []byte) error
- func (z *Hash) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (h *Hash) UnmarshalText(b []byte) error
- type Hashs
- type IP
- func (z *IP) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *IP) EncodeMsg(en *msgp.Writer) (err error)
- func (*IP) ExtensionType() int8
- func (ip IP) Get() net.IP
- func (ip *IP) Len() int
- func (ip *IP) MarshalBinaryTo(b []byte) error
- func (z *IP) MarshalMsg(b []byte) (o []byte, err error)
- func (z *IP) Msgsize() (s int)
- func (ip *IP) Put(in net.IP) *IP
- func (ip *IP) UnmarshalBinary(b []byte) error
- func (z *IP) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Uint64ForJson
- type UintForJson
Constants ¶
const ( // BloomByteLength represents the number of bytes used in a header log bloom. BloomByteLength = 256 // BloomBitLength represents the number of bits used in a header log bloom. BloomBitLength = 8 * BloomByteLength )
const (
AddressLength = 20
)
const (
HashLength = 32
)
Variables ¶
var ( ErrEmptyString = &decError{"empty hex string"} ErrSyntax = &decError{"invalid hex string"} ErrMissingPrefix = &decError{"hex string without 0x prefix"} ErrOddLength = &decError{"hex string of odd length"} ErrEmptyNumber = &decError{"hex string \"0x\""} ErrLeadingZero = &decError{"hex number with leading zero digits"} ErrUint64Range = &decError{"hex number > 64 bits"} ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)} ErrBig256Range = &decError{"hex number > 256 bits"} )
var ( ErrBytesTooLong = &decError{"bytes too long"} ErrRegisterFull = &decError{"Can't register more type"} ErrRegisterFailure = &decError{"Register is failure"} )
Functions ¶
func DecodeHexBig ¶
DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.
func DecodeHexUint64 ¶
DecodeUint64 decodes a hex string with 0x prefix as a quantity.
func EncodeHexBig ¶
EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.
func EncodeHexUint64 ¶
EncodeUint64 encodes i as a hex string with 0x prefix.
func HasHexPrefix ¶
func Hex2BytesFixed ¶
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Bchain address or not.
func LeftPadBytes ¶
func MustDecodeHex ¶
MustDecode decodes a hex string with 0x prefix. It panics for invalid input.
func MustDecodeHexBig ¶
MustDecodeBig decodes a hex string with 0x prefix as a quantity. It panics for invalid input.
func MustDecodeHexUint64 ¶
MustDecodeUint64 decodes a hex string with 0x prefix as a quantity. It panics for invalid input.
func RightPadBytes ¶
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an bchain account.
func BigToAddress ¶
func BytesToAddress ¶
func HexToAddress ¶
func StringToAddress ¶
func (*Address) ExtensionType ¶
Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use
func (*Address) MarshalBinaryTo ¶
MarshalBinaryTo simply copies the value of the bytes into 'b'
func (*Address) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Address) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Address) SetBytes ¶
Sets the address to the value of b. If b is larger than len(a) it will panic
func (*Address) UnmarshalBinary ¶
UnmarshalBinary copies the value of 'b' into the BYTE8 object. (We might want to add a sanity check here later that len(b) <= HashLength.)
func (*Address) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type BigInt ¶
func (*BigInt) ExtensionType ¶
Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use
func (*BigInt) MarshalBinaryTo ¶
func (BigInt) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (BigInt) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (BigInt) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BigInt) UnmarshalBinary ¶
func (*BigInt) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*BigInt) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*BigInt) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type Bloom ¶
type Bloom [BloomByteLength]byte
Bloom represents a 2048 bit bloom filter.
func BytesToBloom ¶
BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.
func (*Bloom) ExtensionType ¶
Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use
func (*Bloom) MarshalBinaryTo ¶
func (*Bloom) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Bloom) MarshalText ¶
MarshalText encodes b as a hex string with 0x prefix.
func (*Bloom) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Bloom) SetBytes ¶
SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.
func (*Bloom) UnmarshalBinary ¶
func (*Bloom) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Bloom) UnmarshalText ¶
UnmarshalText b as a hex string with 0x prefix.
type BytesForJson ¶
type BytesForJson []byte
Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (BytesForJson) MarshalText ¶
func (b BytesForJson) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (BytesForJson) String ¶
func (b BytesForJson) String() string
String returns the hex encoding of b.
func (*BytesForJson) UnmarshalJSON ¶
func (b *BytesForJson) UnmarshalJSON(input []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*BytesForJson) UnmarshalText ¶
func (b *BytesForJson) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data. It's a hex string/num
func BytesToHash ¶
func StringToHash ¶
func (*Hash) ExtensionType ¶
Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use
func (*Hash) MarshalBinaryTo ¶
MarshalBinaryTo simply copies the value of the bytes into 'b'
func (*Hash) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Hash) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Hash) SetBytes ¶
Sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).
func (Hash) TerminalString ¶
func (*Hash) UnmarshalBinary ¶
UnmarshalBinary copies the value of 'b' into the Hash object. (We might want to add a sanity check here later that len(b) <= HashLength.)
func (*Hash) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
type Hashs ¶
type Hashs struct {
Hashs []*Hash
}
func (*Hashs) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type IP ¶
func (*IP) ExtensionType ¶
Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use
func (*IP) MarshalBinaryTo ¶
MarshalBinaryTo simply copies the value of the bytes into 'b'
func (*IP) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*IP) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*IP) UnmarshalBinary ¶
UnmarshalBinary copies the value of 'b' into the Hash object. (We might want to add a sanity check here later that len(b) <= HashLength.)
type Uint64ForJson ¶
type Uint64ForJson uint64
Uint64 marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".
func (Uint64ForJson) MarshalText ¶
func (b Uint64ForJson) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (Uint64ForJson) String ¶
func (b Uint64ForJson) String() string
String returns the hex encoding of b.
func (*Uint64ForJson) UnmarshalJSON ¶
func (b *Uint64ForJson) UnmarshalJSON(input []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*Uint64ForJson) UnmarshalText ¶
func (b *Uint64ForJson) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type UintForJson ¶
type UintForJson uint
Uint marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".
func (UintForJson) MarshalText ¶
func (b UintForJson) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (UintForJson) String ¶
func (b UintForJson) String() string
String returns the hex encoding of b.
func (*UintForJson) UnmarshalJSON ¶
func (b *UintForJson) UnmarshalJSON(input []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*UintForJson) UnmarshalText ¶
func (b *UintForJson) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.