fromda

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const EntrySize = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainMetrics

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

type DB

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

DB implements an append only database for log data and cross-chain dependencies. Each entry is fixed size, and denotes an increment in L1 (derived-from) and/or L2 (derived) block. Data is an append-only log, that can be binary searched for any necessary derivation-link data.

func NewFromEntryStore

func NewFromEntryStore(logger log.Logger, m Metrics, store EntryStore) (*DB, error)

func NewFromFile

func NewFromFile(logger log.Logger, m Metrics, path string) (*DB, error)

func (*DB) AddDerived

func (db *DB) AddDerived(derivedFrom eth.BlockRef, derived eth.BlockRef) error

func (*DB) Close

func (db *DB) Close() error

func (*DB) DerivedFrom

func (db *DB) DerivedFrom(derived eth.BlockID) (derivedFrom types.BlockSeal, err error)

DerivedFrom determines where a L2 block was first derived from. (a L2 block may repeat if the following L1 blocks are empty and don't produce additional L2 blocks)

func (*DB) First

func (db *DB) First() (derivedFrom types.BlockSeal, derived types.BlockSeal, err error)

First returns the first known values, alike to Latest.

func (*DB) FirstAfter

func (db *DB) FirstAfter(derivedFrom, derived eth.BlockID) (nextDerivedFrom, nextDerived types.BlockSeal, err error)

FirstAfter determines the next entry after the given pair of derivedFrom, derived. Either one or both of the two entries will be an increment by 1

func (*DB) LastDerivedAt

func (db *DB) LastDerivedAt(derivedFrom eth.BlockID) (derived types.BlockSeal, err error)

LastDerivedAt returns the last L2 block derived from the given L1 block.

func (*DB) Latest

func (db *DB) Latest() (derivedFrom types.BlockSeal, derived types.BlockSeal, err error)

Latest returns the last known values: derivedFrom: the L1 block that the L2 block is safe for (not necessarily the first, multiple L2 blocks may be derived from the same L1 block). derived: the L2 block that was derived (not necessarily the first, the L1 block may have been empty and repeated the last safe L2 block).

func (*DB) NextDerived

func (db *DB) NextDerived(derived eth.BlockID) (derivedFrom types.BlockSeal, nextDerived types.BlockSeal, err error)

NextDerived finds the next L2 block after derived, and what it was derived from

func (*DB) NextDerivedFrom

func (db *DB) NextDerivedFrom(derivedFrom eth.BlockID) (nextDerivedFrom types.BlockSeal, err error)

NextDerivedFrom finds the next L1 block after derivedFrom

func (*DB) PreviousDerived

func (db *DB) PreviousDerived(derived eth.BlockID) (prevDerived types.BlockSeal, err error)

func (*DB) PreviousDerivedFrom

func (db *DB) PreviousDerivedFrom(derivedFrom eth.BlockID) (prevDerivedFrom types.BlockSeal, err error)

func (*DB) Rewind

func (db *DB) Rewind(derivedFrom uint64) error

Rewind to the last entry that was derived from a L1 block with the given block number.

type Entry

type Entry [EntrySize]byte

func (Entry) Type

func (e Entry) Type() EntryType

type EntryBinary

type EntryBinary struct{}

func (EntryBinary) Append

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

func (EntryBinary) EntrySize

func (EntryBinary) EntrySize() int

func (EntryBinary) ReadAt

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

type EntryStore

type EntryStore interface {
	Size() int64
	LastEntryIdx() entrydb.EntryIdx
	Read(idx entrydb.EntryIdx) (Entry, error)
	Append(entries ...Entry) error
	Truncate(idx entrydb.EntryIdx) error
	Close() error
}

type EntryType

type EntryType uint8
const (
	DerivedFromV0 EntryType = 0
)

func (EntryType) String

func (s EntryType) String() string

type LinkEntry

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

func (LinkEntry) String

func (d LinkEntry) String() string

type Metrics

type Metrics interface {
	RecordDBDerivedEntryCount(count int64)
}

func AdaptMetrics

func AdaptMetrics(chainMetrics ChainMetrics, kind string) Metrics

Jump to

Keyboard shortcuts

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