rlp

package
v0.0.0-...-8f1dc17 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_NUM_ARRAY_ELEMENT   = int(1024 * 1024)
	MAX_SIZE_OF_BYTE_ARRAYS = int(20 * 1024 * 1024)
)

Variables

View Source
var (
	EOL                 = errors.New("rlp: end of list")
	ErrUnPointer        = errors.New("rlp: interface given to Decode must be a pointer")
	ErrElemTooLarge     = errors.New("rlp: element is larger than containing list")
	ErrValueTooLarge    = errors.New("rlp: value size exceeds available input length")
	ErrVarIntBufferSize = errors.New("rlp: invalid buffer size")
)
View Source
var TypeSize = struct {
	Bool   int
	Byte   int
	UInt8  int
	Int8   int
	UInt16 int
	Int16  int
	UInt32 int
	Int32  int
	UInt   int
	Int    int
	UInt64 int
	Int64  int

	UInt128        int
	Float32        int
	Float64        int
	Checksum160    int
	Checksum256    int
	Checksum512    int
	PublicKey      int
	Signature      int
	Tstamp         int
	BlockTimestamp int
	CurrencyName   int
}{
	Bool:   1,
	Byte:   1,
	UInt8:  1,
	Int8:   1,
	UInt16: 2,
	Int16:  2,
	UInt32: 4,
	Int32:  4,
	UInt:   4,
	Int:    4,
	UInt64: 8,
	Int64:  8,

	UInt128:        16,
	Float32:        4,
	Float64:        8,
	Checksum160:    20,
	Checksum256:    32,
	Checksum512:    64,
	PublicKey:      34,
	Signature:      66,
	Tstamp:         8,
	BlockTimestamp: 4,
	CurrencyName:   7,
}

Functions

func Decode

func Decode(r io.Reader, val interface{}) error

func DecodeBytes

func DecodeBytes(b []byte, val interface{}) error

func Encode

func Encode(w io.Writer, val interface{}) error

func EncodeSize

func EncodeSize(val interface{}) (int, error)

func EncodeToBytes

func EncodeToBytes(val interface{}) ([]byte, error)

Types

type Decoder

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

Decoder implements the EOS unpacking, similar to FC_BUFFER

func NewDecoder

func NewDecoder(data []byte) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) (err error)

func (*Decoder) GetData

func (d *Decoder) GetData() []byte

func (*Decoder) GetPos

func (d *Decoder) GetPos() int

func (*Decoder) ReadBool

func (d *Decoder) ReadBool() (out bool, err error)

func (*Decoder) ReadByte

func (d *Decoder) ReadByte() (out byte, err error)

func (*Decoder) ReadByteArray

func (d *Decoder) ReadByteArray() (out []byte, err error)

func (*Decoder) ReadChecksum160

func (d *Decoder) ReadChecksum160() (out []byte, err error)

func (*Decoder) ReadChecksum256

func (d *Decoder) ReadChecksum256() (out []byte, err error)

func (*Decoder) ReadChecksum512

func (d *Decoder) ReadChecksum512() (out []byte, err error)

func (*Decoder) ReadFloat32

func (d *Decoder) ReadFloat32() (out float32, err error)

func (*Decoder) ReadFloat64

func (d *Decoder) ReadFloat64() (out float64, err error)

func (*Decoder) ReadInt16

func (d *Decoder) ReadInt16() (out int16, err error)

func (*Decoder) ReadInt32

func (d *Decoder) ReadInt32() (out int32, err error)

func (*Decoder) ReadInt64

func (d *Decoder) ReadInt64() (out int64, err error)

func (*Decoder) ReadInt8

func (d *Decoder) ReadInt8() (out int8, err error)

func (*Decoder) ReadName

func (d *Decoder) ReadName() (out uint64, err error)

func (*Decoder) ReadString

func (d *Decoder) ReadString() (out string, err error)

func (*Decoder) ReadUint

func (d *Decoder) ReadUint() (out uint, err error)

func (*Decoder) ReadUint128

func (d *Decoder) ReadUint128(typeName string) (out []byte, err error)

func (*Decoder) ReadUint16

func (d *Decoder) ReadUint16() (out uint16, err error)

func (*Decoder) ReadUint32

func (d *Decoder) ReadUint32() (out uint32, err error)

func (*Decoder) ReadUint64

func (d *Decoder) ReadUint64() (out uint64, err error)

func (*Decoder) ReadUint8

func (d *Decoder) ReadUint8() (out byte, err error)

func (*Decoder) ReadUvarint32

func (d *Decoder) ReadUvarint32() (out uint32, err error)

func (*Decoder) ReadUvarint64

func (d *Decoder) ReadUvarint64() (uint64, error)

func (*Decoder) ReadVarint32

func (d *Decoder) ReadVarint32() (out int32, err error)

func (*Decoder) ReadVarint64

func (d *Decoder) ReadVarint64() (out int64, err error)

type Encoder

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

-------------------------------------------------------------- Encoder implements the EOS packing, similar to FC_BUFFER --------------------------------------------------------------

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) (err error)

func (*Encoder) WriteByte

func (e *Encoder) WriteByte(b byte) (err error)

func (*Encoder) WriteUVarInt

func (e *Encoder) WriteUVarInt(v int) (err error)

func (*Encoder) WriteVarInt

func (e *Encoder) WriteVarInt(v int) (err error)

type Pack

type Pack interface {
	Pack() ([]byte, error)
}

type Unpack

type Unpack interface {
	Unpack([]byte) (int, error)
}

Jump to

Keyboard shortcuts

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