Documentation
¶
Index ¶
- Variables
- type ChainsDB
- func (db *ChainsDB) AddLog(chain types.ChainID, logHash common.Hash, parentBlock eth.BlockID, ...) error
- func (db *ChainsDB) AddLogDB(chain types.ChainID, logDB LogStorage)
- func (db *ChainsDB) Check(chain types.ChainID, blockNum uint64, logIdx uint32, logHash common.Hash) (common.Hash, error)
- func (db *ChainsDB) Close() error
- func (db *ChainsDB) FindSealedBlock(chain types.ChainID, block eth.BlockID) (nextEntry entrydb.EntryIdx, err error)
- func (db *ChainsDB) IteratorStartingAt(chain types.ChainID, sealedNum uint64, logIndex uint32) (logs.Iterator, error)
- func (db *ChainsDB) LatestBlockNum(chain types.ChainID) (num uint64, ok bool)
- func (db *ChainsDB) ResumeFromLastSealedBlock() error
- func (db *ChainsDB) Rewind(chain types.ChainID, headBlockNum uint64) error
- func (db *ChainsDB) Safest(chainID types.ChainID, blockNum uint64, index uint32) (safest types.SafetyLevel)
- func (db *ChainsDB) SealBlock(chain types.ChainID, block eth.BlockRef) error
- type LogStorage
Constants ¶
This section is empty.
Variables ¶
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 (*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) FindSealedBlock ¶ added in v1.9.3
func (*ChainsDB) IteratorStartingAt ¶ added in v1.9.4
func (*ChainsDB) LatestBlockNum ¶
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
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) 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.
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)
}