types

package
v0.0.0-...-277f923 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: GPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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"}
)

Functions

func DecodeBig

func DecodeBig(input string) (*big.Int, error)

DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.

func EncodeBig

func EncodeBig(bigint *big.Int) string

EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.

func HexEncode

func HexEncode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func MustDecodeBig

func MustDecodeBig(input string) *big.Int

MustDecodeBig decodes a hex string with 0x prefix as a quantity. It panics for invalid input.

Types

type BigInt

type BigInt struct {
	IntVal big.Int `msg:"bigint"`
}

func NewBigInt

func NewBigInt(in big.Int) *BigInt

func (*BigInt) DecodeMsg

func (z *BigInt) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (BigInt) EncodeMsg

func (z BigInt) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BigInt) ExtensionType

func (self *BigInt) ExtensionType() int8

Here, we'll pick an arbitrary number between 0 and 127 that isn't already in use

func (BigInt) Get

func (self BigInt) Get() big.Int

func (*BigInt) Len

func (self *BigInt) Len() int

We'll always use 1 + len(big.int.x) bytes to encode the data

func (*BigInt) MarshalBinaryTo

func (self *BigInt) MarshalBinaryTo(b []byte) error

func (BigInt) MarshalMsg

func (z BigInt) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (BigInt) MarshalText

func (self BigInt) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (BigInt) Msgsize

func (z BigInt) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BigInt) Put

func (self *BigInt) Put(in big.Int) *BigInt

func (*BigInt) String

func (self *BigInt) String() string

String returns the hex encoding of b.

func (*BigInt) ToInt

func (self *BigInt) ToInt() *big.Int

ToInt converts b to a big.Int.

func (*BigInt) UnmarshalBinary

func (self *BigInt) UnmarshalBinary(b []byte) error

func (*BigInt) UnmarshalJSON

func (self *BigInt) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*BigInt) UnmarshalMsg

func (z *BigInt) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*BigInt) UnmarshalText

func (self *BigInt) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Byte32

type Byte32 [32]byte

func (*Byte32) DecodeMsg

func (z *Byte32) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Byte32) EncodeMsg

func (z *Byte32) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Byte32) Format

func (self Byte32) Format(s fmt.State, c rune)

func (*Byte32) MarshalMsg

func (z *Byte32) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Byte32) MarshalText

func (self Byte32) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Byte32) Msgsize

func (z *Byte32) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Byte32) String

func (self Byte32) String() string

func (Byte32) UnmarshalJSON

func (self Byte32) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a Byte32 in hex syntax.

func (*Byte32) UnmarshalMsg

func (z *Byte32) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (Byte32) UnmarshalText

func (self Byte32) UnmarshalText(input []byte) error

UnmarshalText parses a Byte32 in hex syntax.

type Byte64

type Byte64 [64]byte

func (*Byte64) DecodeMsg

func (z *Byte64) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Byte64) EncodeMsg

func (z *Byte64) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Byte64) Format

func (self Byte64) Format(s fmt.State, c rune)

func (*Byte64) MarshalMsg

func (z *Byte64) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Byte64) MarshalText

func (self Byte64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Byte64) Msgsize

func (z *Byte64) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Byte64) String

func (self Byte64) String() string

func (Byte64) UnmarshalJSON

func (self Byte64) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a Byte64 in hex syntax.

func (*Byte64) UnmarshalMsg

func (z *Byte64) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (Byte64) UnmarshalText

func (self Byte64) UnmarshalText(input []byte) error

UnmarshalText parses a Byte64 in hex syntax.

type Bytes

type Bytes []byte

func (*Bytes) DecodeMsg

func (z *Bytes) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Bytes) EncodeMsg

func (z Bytes) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Bytes) Format

func (self Bytes) Format(s fmt.State, c rune)

func (Bytes) MarshalMsg

func (z Bytes) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Bytes) MarshalText

func (self Bytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Bytes) Msgsize

func (z Bytes) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Bytes) String

func (self Bytes) String() string

func (Bytes) UnmarshalJSON

func (self Bytes) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a Byte64 in hex syntax.

func (*Bytes) UnmarshalMsg

func (z *Bytes) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (Bytes) UnmarshalText

func (self Bytes) UnmarshalText(input []byte) error

UnmarshalText parses a Byte64 in hex syntax.

Jump to

Keyboard shortcuts

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