e2store

package
v1.14.6-0...-341647f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Type  uint16
	Value []byte
}

Entry is a variable-length-data record in an e2store.

type Reader

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

A Reader reads entries from an e2store-encoded file. For more information on this format, see https://github.com/status-im/nimbus-eth2/blob/stable/docs/e2store.md

func NewReader

func NewReader(r io.ReaderAt) *Reader

NewReader returns a new Reader that reads from r.

func (*Reader) Find

func (r *Reader) Find(want uint16) (*Entry, error)

Find returns the first entry with the matching type.

func (*Reader) FindAll

func (r *Reader) FindAll(want uint16) ([]*Entry, error)

FindAll returns all entries with the matching type.

func (*Reader) LengthAt

func (r *Reader) LengthAt(off int64) (int64, error)

LengthAt reads the header at off and returns the total length of the entry, including header.

func (*Reader) Read

func (r *Reader) Read() (*Entry, error)

Read reads one Entry from r.

func (*Reader) ReadAt

func (r *Reader) ReadAt(entry *Entry, off int64) (int, error)

ReadAt reads one Entry from r at the specified offset.

func (*Reader) ReadMetadataAt

func (r *Reader) ReadMetadataAt(off int64) (typ uint16, length uint32, err error)

ReadMetadataAt reads the header metadata at the given offset.

func (*Reader) ReaderAt

func (r *Reader) ReaderAt(expectedType uint16, off int64) (io.Reader, int, error)

ReaderAt returns an io.Reader delivering value data for the entry at the specified offset. If the entry type does not match the expected type, an error is returned.

type Writer

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

Writer writes entries using e2store encoding. For more information on this format, see: https://github.com/status-im/nimbus-eth2/blob/stable/docs/e2store.md

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer that writes to w.

func (*Writer) Write

func (w *Writer) Write(typ uint16, b []byte) (int, error)

Write writes a single e2store entry to w. An entry is encoded in a type-length-value format. The first 8 bytes of the record store the type (2 bytes), the length (4 bytes), and some reserved data (2 bytes). The remaining bytes store b.

Jump to

Keyboard shortcuts

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