rlp

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ParseAnnouncementsErrorPrefix = "parse announcement payload"
View Source
const ParseHashErrorPrefix = "parse hash payload"

Variables

View Source
var (
	ErrBase   = fmt.Errorf("rlp")
	ErrParse  = fmt.Errorf("%w parse", ErrBase)
	ErrDecode = fmt.Errorf("%w decode", ErrBase)
)

Functions

func AnnouncementsLen

func AnnouncementsLen(types []byte, sizes []uint32, hashes []byte) int

func BeInt

func BeInt(payload []byte, pos, length int) (int, error)

BeInt parses Big Endian representation of an integer from given payload at given position

func EncodeAnnouncements

func EncodeAnnouncements(types []byte, sizes []uint32, hashes []byte, encodeBuf []byte) int

EIP-5793: eth/68 - Add tx type to tx announcement

func EncodeByteArrayAsRlp

func EncodeByteArrayAsRlp(raw []byte, w io.Writer, prefixBuf []byte) (int, error)

func EncodeHash

func EncodeHash(h, to []byte) int

EncodeHash assumes that `to` buffer is already 32bytes long

func EncodeHashes

func EncodeHashes(hashes []byte, encodeBuf []byte) int

func EncodeListPrefix

func EncodeListPrefix(dataLen int, to []byte) int

func EncodeString

func EncodeString(s []byte, to []byte) int

func EncodeU32

func EncodeU32(i uint32, to []byte) int

func EncodeU64

func EncodeU64(i uint64, to []byte) int

func GenerateStructLen

func GenerateStructLen(buffer []byte, l int) int

func HashesLen

func HashesLen(hashes []byte) int

func IsRLPError

func IsRLPError(err error) bool

func List

func List(payload []byte, pos int) (dataPos, dataLen int, err error)

func ListPrefixLen

func ListPrefixLen(dataLen int) int

func ParseAnnouncements

func ParseAnnouncements(payload []byte, pos int) ([]byte, []uint32, []byte, int, error)

func ParseHash

func ParseHash(payload []byte, pos int, hashbuf []byte) (int, error)

func Prefix

func Prefix(payload []byte, pos int) (dataPos int, dataLen int, isList bool, err error)

Prefix parses RLP Prefix from given payload at given position. It returns the offset and length of the RLP element as well as the indication of whether it is a list of string

func String

func String(payload []byte, pos int) (dataPos, dataLen int, err error)

func StringLen

func StringLen(s []byte) int

func StringOfLen

func StringOfLen(payload []byte, pos, expectedLen int) (dataPos int, err error)

func U256

func U256(payload []byte, pos int, x *uint256.Int) (int, error)

U256 parses uint256 number from given payload at given position

func U256Len

func U256Len(z *uint256.Int) int

func U32

func U32(payload []byte, pos int) (int, uint32, error)

U32 parses uint64 number from given payload at given position

func U32Len

func U32Len(i uint32) int

func U64

func U64(payload []byte, pos int) (int, uint64, error)

U64 parses uint64 number from given payload at given position

func U64Len

func U64Len(i uint64) int

Types

type RlpEncodedBytes

type RlpEncodedBytes []byte

func (RlpEncodedBytes) DoubleRLPLen

func (b RlpEncodedBytes) DoubleRLPLen() int

func (RlpEncodedBytes) RawBytes

func (b RlpEncodedBytes) RawBytes() []byte

func (RlpEncodedBytes) ToDoubleRLP

func (b RlpEncodedBytes) ToDoubleRLP(w io.Writer, prefixBuf []byte) error

type RlpSerializable

type RlpSerializable interface {
	ToDoubleRLP(io.Writer, []byte) error
	DoubleRLPLen() int
	RawBytes() []byte
}

RlpSerializable is a value that can be double-RLP coded.

type RlpSerializableBytes

type RlpSerializableBytes []byte

func (RlpSerializableBytes) DoubleRLPLen

func (b RlpSerializableBytes) DoubleRLPLen() int

func (RlpSerializableBytes) RawBytes

func (b RlpSerializableBytes) RawBytes() []byte

func (RlpSerializableBytes) ToDoubleRLP

func (b RlpSerializableBytes) ToDoubleRLP(w io.Writer, prefixBuf []byte) error

Jump to

Keyboard shortcuts

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