entrydb

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntrySize = 34
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry [EntrySize]byte

func (Entry) Type added in v1.9.3

func (entry Entry) Type() EntryType

type EntryDB

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

func NewEntryDB

func NewEntryDB(logger log.Logger, path string) (*EntryDB, error)

NewEntryDB creates an EntryDB. A new file will be created if the specified path does not exist, but parent directories will not be created. If the file exists it will be used as the existing data. Returns ErrRecoveryRequired if the existing file is not a valid entry db. A EntryDB is still returned but all operations will return ErrRecoveryRequired until the Recover method is called.

func (*EntryDB) Append

func (e *EntryDB) Append(entries ...Entry) error

Append entries to the database. The entries are combined in memory and passed to a single Write invocation. If the write fails, it will attempt to truncate any partially written data. Subsequent writes to this instance will fail until partially written data is truncated.

func (*EntryDB) Close

func (e *EntryDB) Close() error

func (*EntryDB) LastEntryIdx

func (e *EntryDB) LastEntryIdx() EntryIdx

func (*EntryDB) Read

func (e *EntryDB) Read(idx EntryIdx) (Entry, error)

Read an entry from the database by index. Returns io.EOF iff idx is after the last entry.

func (*EntryDB) Size

func (e *EntryDB) Size() int64

func (*EntryDB) Truncate

func (e *EntryDB) Truncate(idx EntryIdx) error

Truncate the database so that the last retained entry is idx. Any entries after idx are deleted.

type EntryIdx

type EntryIdx int64

type EntryType added in v1.9.3

type EntryType uint8
const (
	TypeSearchCheckpoint EntryType = iota
	TypeCanonicalHash
	TypeInitiatingEvent
	TypeExecutingLink
	TypeExecutingCheck
	TypePadding
)

func (EntryType) String added in v1.9.3

func (d EntryType) String() string

type EntryTypeFlag added in v1.9.3

type EntryTypeFlag uint8
const (
	FlagSearchCheckpoint EntryTypeFlag = 1 << TypeSearchCheckpoint
	FlagCanonicalHash    EntryTypeFlag = 1 << TypeCanonicalHash
	FlagInitiatingEvent  EntryTypeFlag = 1 << TypeInitiatingEvent
	FlagExecutingLink    EntryTypeFlag = 1 << TypeExecutingLink
	FlagExecutingCheck   EntryTypeFlag = 1 << TypeExecutingCheck
	FlagPadding          EntryTypeFlag = 1 << TypePadding
	// for additional padding
	FlagPadding2 EntryTypeFlag = FlagPadding << 1
)

func (*EntryTypeFlag) Add added in v1.9.3

func (ex *EntryTypeFlag) Add(v EntryTypeFlag)

func (EntryTypeFlag) Any added in v1.9.3

func (ex EntryTypeFlag) Any(v EntryTypeFlag) bool

func (*EntryTypeFlag) Remove added in v1.9.3

func (ex *EntryTypeFlag) Remove(v EntryTypeFlag)

Jump to

Keyboard shortcuts

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