db

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownChain = errors.New("unknown chain")
)

Functions

This section is empty.

Types

type ChainsDB

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

ChainsDB is a database that stores logs and heads for multiple chains. it implements the ChainsStorage interface.

func NewChainsDB

func NewChainsDB(logDBs map[types.ChainID]LogStorage, l log.Logger) *ChainsDB

func (*ChainsDB) AddLog

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

func (*ChainsDB) AddLogDB added in v1.9.3

func (db *ChainsDB) AddLogDB(chain types.ChainID, logDB LogStorage)

func (*ChainsDB) Check added in v1.9.1

func (db *ChainsDB) Check(chain types.ChainID, blockNum uint64, logIdx uint32, logHash common.Hash) (common.Hash, error)

Check calls the underlying logDB to determine if the given log entry is safe with respect to the checker's criteria.

func (*ChainsDB) Close

func (db *ChainsDB) Close() error

func (*ChainsDB) FindSealedBlock added in v1.9.3

func (db *ChainsDB) FindSealedBlock(chain types.ChainID, block eth.BlockID) (nextEntry entrydb.EntryIdx, err error)

func (*ChainsDB) IteratorStartingAt added in v1.9.4

func (db *ChainsDB) IteratorStartingAt(chain types.ChainID, sealedNum uint64, logIndex uint32) (logs.Iterator, error)

func (*ChainsDB) LatestBlockNum

func (db *ChainsDB) LatestBlockNum(chain types.ChainID) (num uint64, ok bool)

LatestBlockNum returns the latest fully-sealed block number that has been recorded to the logs db for the given chain. It does not contain safety guarantees. The block number might not be available (empty database, or non-existent chain).

func (*ChainsDB) ResumeFromLastSealedBlock added in v1.9.3

func (db *ChainsDB) ResumeFromLastSealedBlock() error

ResumeFromLastSealedBlock prepares the chains db to resume recording events after a restart. It rewinds the database to the last block that is guaranteed to have been fully recorded to the database, to ensure it can resume recording from the first log of the next block.

func (*ChainsDB) Rewind

func (db *ChainsDB) Rewind(chain types.ChainID, headBlockNum uint64) error

func (*ChainsDB) Safest added in v1.9.4

func (db *ChainsDB) Safest(chainID types.ChainID, blockNum uint64, index uint32) (safest types.SafetyLevel)

Safest returns the strongest safety level that can be guaranteed for the given log entry. it assumes the log entry has already been checked and is valid, this funcion only checks safety levels.

func (*ChainsDB) SealBlock added in v1.9.3

func (db *ChainsDB) SealBlock(
	chain types.ChainID,
	block eth.BlockRef) error

type LogStorage

type LogStorage interface {
	io.Closer

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

	SealBlock(parentHash common.Hash, block eth.BlockID, timestamp uint64) error

	Rewind(newHeadBlockNum uint64) error

	LatestSealedBlockNum() (n uint64, ok bool)

	// 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
	FindSealedBlock(block eth.BlockID) (nextEntry entrydb.EntryIdx, err error)

	IteratorStartingAt(sealedNum uint64, logsSince uint32) (logs.Iterator, error)

	// returns ErrConflict if the log does not match the canonical chain.
	// returns ErrFuture if the log is out of reach.
	// returns nil if the log is known and matches the canonical chain.
	Contains(blockNum uint64, logIdx uint32, logHash common.Hash) (nextIndex entrydb.EntryIdx, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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