encoding

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read256

func Read256(r *bytes.Buffer, b []byte) error

Read256 will read 32 bytes from r and return them as a slice of bytes.

func Read512

func Read512(r *bytes.Buffer, b []byte) error

Read512 will read 64 bytes from r and return them as a slice of bytes.

func ReadBLS

func ReadBLS(r *bytes.Buffer, b []byte) error

ReadBLS will read a compressed bls signature (33 bytes) from r and return it as a slice of bytes.

func ReadBLSPKey added in v0.6.0

func ReadBLSPKey(r *bytes.Buffer, b []byte) error

ReadBLSPKey will read a compressed bls public key (96 bytes) from r and return it as a slice of bytes.

func ReadBool

func ReadBool(r *bytes.Buffer, b *bool) error

ReadBool will read a single byte from r, turn it into a bool and return it.

func ReadString

func ReadString(r *bytes.Buffer) (string, error)

ReadString reads the data with ReadVarBytes and returns it as a string by simple type conversion.

func ReadUint16LE added in v0.2.0

func ReadUint16LE(r *bytes.Buffer, v *uint16) error

ReadUint16LE will read two bytes and convert them to a uint16 assuming little-endian byte order. The result is put into v.

func ReadUint32LE added in v0.2.0

func ReadUint32LE(r *bytes.Buffer, v *uint32) error

ReadUint32LE will read four bytes and convert them to a uint32 assuming little-endian byte order. The result is put into v.

func ReadUint64LE added in v0.2.0

func ReadUint64LE(r *bytes.Buffer, v *uint64) error

ReadUint64LE will read eight bytes and convert them to a uint64 assuming little-endian byte order. The result is put into v.

func ReadUint8

func ReadUint8(r *bytes.Buffer, v *uint8) error

ReadUint8 will read a single byte into v.

func ReadVarBytes

func ReadVarBytes(r *bytes.Buffer, b *[]byte) error

ReadVarBytes will read a CompactSize int denoting the length, then proceeds to read that amount of bytes from r into b.

func ReadVarBytesUint32LE added in v0.5.0

func ReadVarBytesUint32LE(r *bytes.Buffer, b *[]byte) error

ReadVarBytesUint32LE will read a CompactSize int denoting the length, then proceeds to read that amount of bytes from r into b.

func ReadVarInt

func ReadVarInt(r *bytes.Buffer) (uint64, error)

ReadVarInt reads the discriminator byte of a CompactSize int, and then deserializes the number accordingly.

func VarIntEncodeSize

func VarIntEncodeSize(v uint64) uint64

VarIntEncodeSize returns the number of bytes needed to serialize a CompactSize int of size v.

func Write256

func Write256(w *bytes.Buffer, b []byte) error

Write256 will check the length of b and then write to w.

func Write512

func Write512(w *bytes.Buffer, b []byte) error

Write512 will check the length of b and then write to w.

func WriteBLS

func WriteBLS(w *bytes.Buffer, b []byte) error

WriteBLS will write a compressed bls signature (33 bytes) to w.

func WriteBLSPKey added in v0.6.0

func WriteBLSPKey(w *bytes.Buffer, b []byte) error

WriteBLSPKey will write a compressed bls public key (96 bytes) to w.

func WriteBool

func WriteBool(w *bytes.Buffer, b bool) error

WriteBool will write a boolean value as a single byte into w.

func WriteString

func WriteString(w *bytes.Buffer, s string) error

WriteString will write string s as a slice of bytes through WriteVarBytes.

func WriteUint16LE added in v0.2.0

func WriteUint16LE(w *bytes.Buffer, v uint16) error

WriteUint16LE will write two bytes in little-endian byte order.

func WriteUint32LE added in v0.2.0

func WriteUint32LE(w *bytes.Buffer, v uint32) error

WriteUint32LE will write four bytes in little-endian byte order.

func WriteUint64LE added in v0.2.0

func WriteUint64LE(w *bytes.Buffer, v uint64) error

WriteUint64LE will write eight bytes in little-endian byte order.

func WriteUint8

func WriteUint8(w *bytes.Buffer, v uint8) error

WriteUint8 will write a single byte.

func WriteVarBytes

func WriteVarBytes(w *bytes.Buffer, b []byte) error

WriteVarBytes will serialize a CompactSize int denoting the length, then proceeds to write b into w.

func WriteVarBytesUint32 added in v0.5.0

func WriteVarBytesUint32(w *bytes.Buffer, b []byte) error

WriteVarBytesUint32 will serialize a CompactSize int denoting the length, then proceeds to write b into w.

func WriteVarInt

func WriteVarInt(w *bytes.Buffer, v uint64) error

WriteVarInt writes a CompactSize integer with a number of bytes depending on it's value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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