Documentation
¶
Index ¶
- Constants
- type ChainMetrics
- type DB
- func (db *DB) AddDerived(derivedFrom eth.BlockRef, derived eth.BlockRef) error
- func (db *DB) Close() error
- func (db *DB) ContainsDerived(derived eth.BlockID) error
- func (db *DB) DerivedToFirstSource(derived eth.BlockID) (types.BlockSeal, error)
- func (db *DB) First() (pair types.DerivedBlockSealPair, err error)
- func (db *DB) Invalidated() (pair types.DerivedBlockSealPair, err error)
- func (db *DB) Last() (pair types.DerivedBlockSealPair, err error)
- func (db *DB) Next(pair types.DerivedIDPair) (types.DerivedBlockSealPair, error)
- func (db *DB) NextDerived(derived eth.BlockID) (pair types.DerivedBlockSealPair, err error)
- func (db *DB) NextSource(source eth.BlockID) (types.BlockSeal, error)
- func (db *DB) PreviousDerived(derived eth.BlockID) (prevDerived types.BlockSeal, err error)
- func (db *DB) PreviousSource(source eth.BlockID) (types.BlockSeal, error)
- func (db *DB) ReplaceInvalidatedBlock(replacementDerived eth.BlockRef, invalidated common.Hash) (types.DerivedBlockSealPair, error)
- func (db *DB) Rewind(target types.DerivedBlockSealPair, including bool) error
- func (db *DB) RewindAndInvalidate(invalidated types.DerivedBlockRefPair) error
- func (db *DB) RewindToFirstDerived(v eth.BlockID) error
- func (db *DB) RewindToScope(scope eth.BlockID) error
- func (db *DB) SourceToLastDerived(source eth.BlockID) (derived types.BlockSeal, err error)
- type Entry
- type EntryBinary
- type EntryStore
- type EntryType
- type LinkEntry
- type Metrics
Constants ¶
const EntrySize = 100
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainMetrics ¶
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 (*DB) AddDerived ¶
func (*DB) ContainsDerived ¶ added in v1.11.0
ContainsDerived checks if the given block is canonical for the given chain. This returns an ErrFuture if the block is not known yet. An ErrConflict if there is a different block. Or an ErrAwaitReplacementBlock if it was invalidated.
func (*DB) DerivedToFirstSource ¶ added in v1.11.0
DerivedToFirstSource 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() (pair types.DerivedBlockSealPair, err error)
First returns the first known values, alike to Latest.
func (*DB) Invalidated ¶ added in v1.11.0
func (db *DB) Invalidated() (pair types.DerivedBlockSealPair, err error)
func (*DB) Last ¶ added in v1.11.0
func (db *DB) Last() (pair types.DerivedBlockSealPair, 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). If the last entry is invalidated, this returns a types.ErrAwaitReplacementBlock error.
func (*DB) Next ¶ added in v1.11.0
func (db *DB) Next(pair types.DerivedIDPair) (types.DerivedBlockSealPair, error)
Next returns the next Derived Block Pair after the given pair. This may return types.ErrAwaitReplacementBlock if the entry was invalidated and needs replacement.
func (*DB) NextDerived ¶
NextDerived finds the next L2 block after derived, and what it was derived from. This may return types.ErrAwaitReplacementBlock if the entry was invalidated and needs replacement.
func (*DB) NextSource ¶ added in v1.11.0
NextSource finds the next source after the given source
func (*DB) PreviousDerived ¶
func (*DB) PreviousSource ¶ added in v1.11.0
func (*DB) ReplaceInvalidatedBlock ¶ added in v1.11.0
func (db *DB) ReplaceInvalidatedBlock(replacementDerived eth.BlockRef, invalidated common.Hash) (types.DerivedBlockSealPair, error)
ReplaceInvalidatedBlock replaces the current Invalidated block with the given replacement. The to-be invalidated hash must be provided for consistency checks.
func (*DB) Rewind ¶
func (db *DB) Rewind(target types.DerivedBlockSealPair, including bool) error
Rewind rolls back the database to the target, including the target if the including flag is set. it locks the DB and calls rewindLocked.
func (*DB) RewindAndInvalidate ¶ added in v1.11.0
func (db *DB) RewindAndInvalidate(invalidated types.DerivedBlockRefPair) error
RewindAndInvalidate rolls back the database to just before the invalidated block, and then marks the block as invalidated, so that no new data can be added to the DB until a Rewind or ReplaceInvalidatedBlock.
func (*DB) RewindToFirstDerived ¶ added in v1.11.0
RewindToFirstDerived rewinds to the first time when v was derived (inclusive, v is retained in DB).
func (*DB) RewindToScope ¶ added in v1.11.0
RewindToScope rewinds the DB to the last entry with a derivedFrom value matching the given scope (inclusive, scope is retained in DB). Note that this drop L1 blocks that resulted in a previously invalidated local-safe block. This returns ErrFuture if the block is newer than the last known block. This returns ErrConflict if a different block at the given height is known. TODO: rename this "RewindToSource" to match the idea of Source
func (*DB) SourceToLastDerived ¶ added in v1.11.0
LastDerivedAt returns the last L2 block derived from the given L1 block. This may return types.ErrAwaitReplacementBlock if the entry was invalidated and needs replacement.
type EntryBinary ¶
type EntryBinary struct{}
func (EntryBinary) EntrySize ¶
func (EntryBinary) EntrySize() int
type EntryStore ¶
type LinkEntry ¶
type LinkEntry struct {
// contains filtered or unexported fields
}
LinkEntry is a DerivedFromV0 or a InvalidatedFromV0 kind
type Metrics ¶
type Metrics interface {
RecordDBDerivedEntryCount(count int64)
}
func AdaptMetrics ¶
func AdaptMetrics(chainMetrics ChainMetrics, kind string) Metrics