headtracker

package
v2.12.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullSaver httypes.HeadSaver = &nullSaver{}
View Source
var NullTracker httypes.HeadTracker = &nullTracker{}

Functions

func NewHeadBroadcaster

func NewHeadBroadcaster(
	lggr logger.Logger,
) headBroadcaster

func NewHeadListener

func NewHeadListener(
	lggr logger.Logger,
	ethClient evmclient.Client,
	config Config, chStop chan struct{},
) headListener

func NewHeadSaver

func NewHeadSaver(lggr logger.Logger, orm ORM, config Config, htConfig HeadTrackerConfig) httypes.HeadSaver

func NewHeadTracker

func NewHeadTracker(
	lggr logger.Logger,
	ethClient evmclient.Client,
	config Config,
	htConfig HeadTrackerConfig,
	headBroadcaster httypes.HeadBroadcaster,
	headSaver httypes.HeadSaver,
	mailMon *mailbox.Monitor,
) httypes.HeadTracker

Types

type Config

type Config interface {
	BlockEmissionIdleWarningThreshold() time.Duration
	FinalityDepth() uint32
	FinalityTagEnabled() bool
}

Config represents a subset of options needed by head tracker

type DbORM added in v2.11.0

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

func NewORM

func NewORM(chainID big.Int, ds sqlutil.DataSource) *DbORM

NewORM creates an ORM scoped to chainID.

func (*DbORM) HeadByHash added in v2.11.0

func (orm *DbORM) HeadByHash(ctx context.Context, hash common.Hash) (head *evmtypes.Head, err error)

func (*DbORM) IdempotentInsertHead added in v2.11.0

func (orm *DbORM) IdempotentInsertHead(ctx context.Context, head *evmtypes.Head) error

func (*DbORM) LatestHead added in v2.11.0

func (orm *DbORM) LatestHead(ctx context.Context) (head *evmtypes.Head, err error)

func (*DbORM) LatestHeads added in v2.11.0

func (orm *DbORM) LatestHeads(ctx context.Context, minBlockNumer int64) (heads []*evmtypes.Head, err error)

func (*DbORM) TrimOldHeads added in v2.11.0

func (orm *DbORM) TrimOldHeads(ctx context.Context, minBlockNumber int64) (err error)

type HeadTrackerConfig added in v2.3.0

type HeadTrackerConfig interface {
	config.HeadTracker
}

type Heads

type Heads interface {
	// LatestHead returns the block header with the highest number that has been seen, or nil.
	LatestHead() *evmtypes.Head
	// HeadByHash returns a head for the specified hash, or nil.
	HeadByHash(hash common.Hash) *evmtypes.Head
	// AddHeads adds newHeads to the collection, eliminates duplicates,
	// sorts by head number, fixes parents and cuts off old heads (historyDepth).
	AddHeads(newHeads ...*evmtypes.Head)
	// Count returns number of heads in the collection.
	Count() int
	// MarkFinalized - finds `finalized` in the LatestHead and marks it and all direct ancestors as finalized.
	// Trims old blocks whose height is smaller than minBlockToKeep
	MarkFinalized(finalized common.Hash, minBlockToKeep int64) bool
}

Heads is a collection of heads. All methods are thread-safe.

func NewHeads

func NewHeads() Heads

type ORM

type ORM interface {
	// IdempotentInsertHead inserts a head only if the hash is new. Will do nothing if hash exists already.
	// No advisory lock required because this is thread safe.
	IdempotentInsertHead(ctx context.Context, head *evmtypes.Head) error
	// TrimOldHeads deletes heads such that only blocks >= minBlockNumber remain
	TrimOldHeads(ctx context.Context, minBlockNumber int64) (err error)
	// LatestHead returns the highest seen head
	LatestHead(ctx context.Context) (head *evmtypes.Head, err error)
	// LatestHeads returns the latest heads with blockNumbers >= minBlockNumber
	LatestHeads(ctx context.Context, minBlockNumber int64) (heads []*evmtypes.Head, err error)
	// HeadByHash fetches the head with the given hash from the db, returns nil if none exists
	HeadByHash(ctx context.Context, hash common.Hash) (head *evmtypes.Head, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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