common

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressIDBytes = 20
	AddressBytes   = AddressIDBytes + 1
)
View Source
const (
	TypeAddress = iota + codec.TypeCustom
	TypeInt
)

Variables

View Source
var (
	ErrUnknown         = errors.New("Unknown error")
	ErrIllegalArgument = errors.New("Illegal argument")
	ErrInvalidState    = errors.New("Invalid state")
	ErrUnsupported     = errors.New("Unsupported")
	ErrNotFound        = errors.New("Not found")
)
View Source
var BigIntOne = big.NewInt(1)
View Source
var TypeCodec = &typeCodec{}

Functions

func BigIntSetBytes

func BigIntSetBytes(i *big.Int, bs []byte) *big.Int

func BigIntToBytes

func BigIntToBytes(i *big.Int) []byte

func BytesToInt64

func BytesToInt64(bs []byte) int64

func BytesToUint64

func BytesToUint64(bs []byte) uint64

func DecodeAny

func DecodeAny(o *codec.TypedObj) (interface{}, error)

func EncodeAny

func EncodeAny(obj interface{}) (*codec.TypedObj, error)

func FormatInt

func FormatInt(v int64) string

func FormatUint

func FormatUint(v uint64) string

func Int64ToBytes

func Int64ToBytes(v int64) []byte

func MarshalAny

func MarshalAny(obj interface{}) ([]byte, error)

func MustDecodeAny

func MustDecodeAny(o *codec.TypedObj) interface{}

func MustEncodeAny

func MustEncodeAny(obj interface{}) *codec.TypedObj

func ParseInt

func ParseInt(s string, bits int) (int64, error)

func ParseUint

func ParseUint(s string, bits int) (uint64, error)

func SetLog added in v1.2.0

func SetLog(file string, maxSize int, maxBackups int, localtime bool)

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

func UnmarshalAny

func UnmarshalAny(bs []byte) (interface{}, error)

Types

type Address

type Address [AddressBytes]byte

func NewAccountAddress

func NewAccountAddress(b []byte) *Address

func NewAccountAddressFromPublicKey

func NewAccountAddressFromPublicKey(pubKey *crypto.PublicKey) *Address

func NewAddress

func NewAddress(b []byte) *Address

func NewAddressFromString

func NewAddressFromString(s string) *Address

func NewContractAddress

func NewContractAddress(b []byte) *Address

func (*Address) Bytes

func (a *Address) Bytes() []byte

func (*Address) CodecDecodeSelf

func (a *Address) CodecDecodeSelf(d *codec.Decoder)

func (*Address) CodecEncodeSelf

func (a *Address) CodecEncodeSelf(e *codec.Encoder)

func (*Address) Equal

func (a *Address) Equal(a2 module.Address) bool

func (*Address) ID

func (a *Address) ID() []byte

BytesPart returns part of address without type prefix.

func (*Address) IsContract

func (a *Address) IsContract() bool

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte) error

func (*Address) SetString

func (a *Address) SetString(s string) error

func (*Address) SetTypeAndID

func (a *Address) SetTypeAndID(ic bool, id []byte) error

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type HexBytes

type HexBytes []byte

func (HexBytes) Bytes

func (hs HexBytes) Bytes() []byte

func (HexBytes) MarshalJSON

func (hs HexBytes) MarshalJSON() ([]byte, error)

func (HexBytes) String

func (hs HexBytes) String() string

func (*HexBytes) UnmarshalJSON

func (hs *HexBytes) UnmarshalJSON(b []byte) error

type HexInt

type HexInt struct {
	big.Int
}

func NewHexInt

func NewHexInt(v int64) *HexInt

func NewHexIntFromUint64

func NewHexIntFromUint64(v uint64) *HexInt

func (*HexInt) Bytes

func (i *HexInt) Bytes() []byte

func (*HexInt) Clone

func (i *HexInt) Clone() HexInt

func (*HexInt) CodecDecodeSelf

func (i *HexInt) CodecDecodeSelf(d *codec.Decoder)

func (*HexInt) CodecEncodeSelf

func (i *HexInt) CodecEncodeSelf(e *codec.Encoder)

func (*HexInt) MarshalBinary

func (i *HexInt) MarshalBinary() (data []byte, err error)

func (HexInt) MarshalJSON

func (i HexInt) MarshalJSON() ([]byte, error)

func (*HexInt) SetBytes

func (i *HexInt) SetBytes(bs []byte) *big.Int

func (HexInt) String

func (i HexInt) String() string

func (*HexInt) UnmarshalBinary

func (i *HexInt) UnmarshalBinary(data []byte) error

func (*HexInt) UnmarshalJSON

func (i *HexInt) UnmarshalJSON(b []byte) error

type HexInt16

type HexInt16 struct {
	Value int16
}

func (HexInt16) Bytes

func (i HexInt16) Bytes() []byte

func (*HexInt16) CodecDecodeSelf

func (i *HexInt16) CodecDecodeSelf(d *codec.Decoder)

func (*HexInt16) CodecEncodeSelf

func (i *HexInt16) CodecEncodeSelf(e *codec.Encoder)

func (HexInt16) MarshalJSON

func (i HexInt16) MarshalJSON() ([]byte, error)

func (HexInt16) String

func (i HexInt16) String() string

func (*HexInt16) UnmarshalJSON

func (i *HexInt16) UnmarshalJSON(b []byte) error

type HexInt32

type HexInt32 struct {
	Value int32
}

func (*HexInt32) CodecDecodeSelf

func (i *HexInt32) CodecDecodeSelf(d *codec.Decoder)

func (*HexInt32) CodecEncodeSelf

func (i *HexInt32) CodecEncodeSelf(e *codec.Encoder)

func (HexInt32) MarshalJSON

func (i HexInt32) MarshalJSON() ([]byte, error)

func (HexInt32) String

func (i HexInt32) String() string

func (*HexInt32) UnmarshalJSON

func (i *HexInt32) UnmarshalJSON(b []byte) error

type HexInt64

type HexInt64 struct {
	Value int64
}

func (*HexInt64) CodecDecodeSelf

func (i *HexInt64) CodecDecodeSelf(e *codec.Decoder)

func (*HexInt64) CodecEncodeSelf

func (i *HexInt64) CodecEncodeSelf(e *codec.Encoder)

func (HexInt64) MarshalJSON

func (i HexInt64) MarshalJSON() ([]byte, error)

func (HexInt64) String

func (i HexInt64) String() string

func (*HexInt64) UnmarshalJSON

func (i *HexInt64) UnmarshalJSON(b []byte) error

type HexUint16

type HexUint16 struct {
	Value uint16
}

func (HexUint16) Bytes

func (i HexUint16) Bytes() []byte

func (*HexUint16) CodecDecodeSelf

func (i *HexUint16) CodecDecodeSelf(d *codec.Decoder)

func (*HexUint16) CodecEncodeSelf

func (i *HexUint16) CodecEncodeSelf(e *codec.Encoder)

func (HexUint16) MarshalJSON

func (i HexUint16) MarshalJSON() ([]byte, error)

func (HexUint16) String

func (i HexUint16) String() string

func (*HexUint16) UnmarshalJSON

func (i *HexUint16) UnmarshalJSON(b []byte) error

type HexUint32

type HexUint32 struct {
	Value uint32
}

func (*HexUint32) CodecDecodeSelf

func (i *HexUint32) CodecDecodeSelf(e *codec.Decoder)

func (*HexUint32) CodecEncodeSelf

func (i *HexUint32) CodecEncodeSelf(e *codec.Encoder)

func (HexUint32) MarshalJSON

func (i HexUint32) MarshalJSON() ([]byte, error)

func (HexUint32) String

func (i HexUint32) String() string

func (*HexUint32) UnmarshalJSON

func (i *HexUint32) UnmarshalJSON(b []byte) error

type HexUint64

type HexUint64 struct {
	Value uint64
}

func (HexUint64) Bytes

func (i HexUint64) Bytes() []byte

func (*HexUint64) CodecDecodeSelf

func (i *HexUint64) CodecDecodeSelf(e *codec.Decoder)

func (*HexUint64) CodecEncodeSelf

func (i *HexUint64) CodecEncodeSelf(e *codec.Encoder)

func (HexUint64) MarshalJSON

func (i HexUint64) MarshalJSON() ([]byte, error)

func (HexUint64) String

func (i HexUint64) String() string

func (*HexUint64) UnmarshalJSON

func (i *HexUint64) UnmarshalJSON(b []byte) error

type Log added in v1.2.0

type Log struct {
	// contains filtered or unexported fields
}

func (*Log) Write added in v1.2.0

func (l *Log) Write(p []byte) (n int, err error)

type RawHexBytes

type RawHexBytes []byte

func (RawHexBytes) Bytes

func (rh RawHexBytes) Bytes() []byte

func (RawHexBytes) MarshalJSON

func (rh RawHexBytes) MarshalJSON() ([]byte, error)

func (RawHexBytes) String

func (rh RawHexBytes) String() string

func (*RawHexBytes) UnmarshalJSON

func (rh *RawHexBytes) UnmarshalJSON(b []byte) error

type Signature

type Signature struct {
	*crypto.Signature
}

func (*Signature) MarshalBinary

func (sig *Signature) MarshalBinary() ([]byte, error)

func (Signature) MarshalJSON

func (sig Signature) MarshalJSON() ([]byte, error)

func (*Signature) UnmarshalBinary

func (sig *Signature) UnmarshalBinary(s []byte) error

func (*Signature) UnmarshalJSON

func (sig *Signature) UnmarshalJSON(s []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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