logs

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const EntrySize = 34

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB implements an append only database for log data and cross-chain dependencies.

To keep the append-only format, reduce data size, and support reorg detection and registering of executing-messages:

Use a fixed 24 bytes per entry.

Data is an append-only log, that can be binary searched for any necessary event data.

func NewFromEntryStore

func NewFromEntryStore(logger log.Logger, m Metrics, chainID eth.ChainID, store entrydb.EntryStore[EntryType, Entry], trimToLastSealed bool) (*DB, error)

func NewFromFile

func NewFromFile(logger log.Logger, m Metrics, chainID eth.ChainID, path string, trimToLastSealed bool) (*DB, error)

func (*DB) AddLog

func (db *DB) AddLog(logHash common.Hash, parentBlock eth.BlockID, logIdx uint32, execMsg *types.ExecutingMessage) error

func (*DB) Clear added in v1.13.5

func (db *DB) Clear(inv reads.Invalidator) error

Clear clears the DB such that there is no data left. An invalidator is required as argument, to force users to invalidate any current open reads.

func (*DB) Close

func (db *DB) Close() error

func (*DB) Contains

func (db *DB) Contains(query types.ContainsQuery) (types.BlockSeal, error)

Contains returns no error iff the specified logHash is recorded in the specified blockNum and logIdx. If the log is out of reach and the block is complete, an ErrConflict is returned. If the log is out of reach and the block is not complete, an ErrFuture is returned. If the log is determined to conflict with the canonical chain, then ErrConflict is returned. logIdx is the index of the log in the array of all logs in the block. This can be used to check the validity of cross-chain interop events. The block-seal of the blockNum block, that the log was included in, is returned. This seal may be fully zeroed, without error, if the block isn't fully known yet.

func (*DB) FindSealedBlock added in v1.9.3

func (db *DB) FindSealedBlock(number uint64) (seal types.BlockSeal, err error)

FindSealedBlock finds the requested block, to check if it exists, returning the next index after it where things continue from. returns ErrFuture if the block is too new to be able to tell returns ErrDifferent if the known block does not match

func (*DB) FirstSealedBlock added in v1.13.4

func (db *DB) FirstSealedBlock() (seal types.BlockSeal, err error)

FirstSealedBlock returns the first block seal in the DB, if any.

func (*DB) IsEmpty added in v1.13.4

func (db *DB) IsEmpty() bool

func (*DB) IteratorStartingAt added in v1.9.3

func (db *DB) IteratorStartingAt(sealedNum uint64, logsSince uint32) (Iterator, error)

func (*DB) LatestSealedBlock added in v1.11.0

func (db *DB) LatestSealedBlock() (id eth.BlockID, ok bool)

LatestSealedBlock returns the block ID of the block that was last sealed, or ok=false if there is no sealed block (i.e. empty DB)

func (*DB) OpenBlock added in v1.9.5

func (db *DB) OpenBlock(blockNum uint64) (ref eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, retErr error)

OpenBlock returns the Executing Messages for the block at the given number. it returns identification of the block, the parent block, and the executing messages.

func (*DB) Rewind

func (db *DB) Rewind(inv reads.Invalidator, newHead eth.BlockID) error

Rewind the database to remove any blocks after newHead. The block at newHead.Number itself is not removed. If the newHead is before the start of the DB, then this empties the DB.

func (*DB) SealBlock added in v1.9.3

func (db *DB) SealBlock(parentHash common.Hash, block eth.BlockID, timestamp uint64) error

type Entry added in v1.9.5

type Entry [EntrySize]byte

func (Entry) Type added in v1.9.5

func (e Entry) Type() EntryType

type EntryBinary added in v1.9.5

type EntryBinary struct{}

func (EntryBinary) Append added in v1.9.5

func (EntryBinary) Append(dest []byte, e *Entry) []byte

func (EntryBinary) EntrySize added in v1.9.5

func (EntryBinary) EntrySize() int

func (EntryBinary) ReadAt added in v1.9.5

func (EntryBinary) ReadAt(dest *Entry, r io.ReaderAt, at int64) (n int, err error)

type EntryObj added in v1.9.3

type EntryObj interface {
	// contains filtered or unexported methods
}

type EntryType added in v1.9.5

type EntryType uint8
const (
	TypeSearchCheckpoint EntryType = iota
	TypeCanonicalHash
	TypeInitiatingEvent
	TypeExecChainID
	TypeExecPosition
	TypeExecChecksum
	TypePadding
)

func (EntryType) String added in v1.9.5

func (x EntryType) String() string

type EntryTypeFlag added in v1.9.5

type EntryTypeFlag uint16
const (
	FlagSearchCheckpoint EntryTypeFlag = 1 << TypeSearchCheckpoint
	FlagCanonicalHash    EntryTypeFlag = 1 << TypeCanonicalHash
	FlagInitiatingEvent  EntryTypeFlag = 1 << TypeInitiatingEvent
	FlagExecChainID      EntryTypeFlag = 1 << TypeExecChainID
	FlagExecPosition     EntryTypeFlag = 1 << TypeExecPosition
	FlagExecChecksum     EntryTypeFlag = 1 << TypeExecChecksum
	FlagPadding          EntryTypeFlag = 1 << TypePadding
	// for additional padding
	FlagPadding2 EntryTypeFlag = FlagPadding << 1
	FlagPadding3 EntryTypeFlag = FlagPadding2 << 1
)

func (*EntryTypeFlag) Add added in v1.9.5

func (x *EntryTypeFlag) Add(v EntryTypeFlag)

func (EntryTypeFlag) Any added in v1.9.5

func (x EntryTypeFlag) Any(v EntryTypeFlag) bool

func (*EntryTypeFlag) Remove added in v1.9.5

func (x *EntryTypeFlag) Remove(v EntryTypeFlag)

func (EntryTypeFlag) String added in v1.9.5

func (x EntryTypeFlag) String() string

type Iterator added in v1.9.1

type Iterator interface {
	End() error
	NextInitMsg() error
	NextExecMsg() error
	NextBlock() error
	TraverseConditional(traverseConditionalFn) error
	IteratorState
}

type IteratorState added in v1.9.3

type IteratorState interface {
	NextIndex() entrydb.EntryIdx
	SealedBlock() (hash common.Hash, num uint64, ok bool)
	SealedTimestamp() (timestamp uint64, ok bool)
	InitMessage() (hash common.Hash, logIndex uint32, ok bool)
	ExecMessage() *types.ExecutingMessage
}

type Metrics

type Metrics interface {
	RecordDBEntryCount(kind string, count int64)
	RecordDBSearchEntriesRead(count int64)
}

Jump to

Keyboard shortcuts

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