heads

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: LGPL-3.0, MIT Imports: 16 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBroadcaster

func NewBroadcaster(
	lggr logger.Logger,
) broadcaster

Types

type Broadcaster

type Broadcaster = heads.Broadcaster[*evmtypes.Head, common.Hash]

Type Alias for EVM Head Tracker Components

type Client

type Client = heads.Client[*evmtypes.Head, ethereum.Subscription, *big.Int, common.Hash]

Type Alias for EVM Head Tracker Components

type DbORM

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

func NewORM

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

NewORM creates an ORM scoped to chainID.

func (*DbORM) HeadByHash

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

func (*DbORM) IdempotentInsertHead

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

func (*DbORM) LatestHead

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

func (*DbORM) LatestHeads

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

func (*DbORM) TrimOldHeads

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

type HeadSaver

type HeadSaver interface {
	heads.Saver[*evmtypes.Head, common.Hash]
	// LatestHeadFromDB returns the highest seen head from DB.
	LatestHeadFromDB(ctx context.Context) (*evmtypes.Head, error)
}

HeadSaver maintains chains persisted in DB. All methods are thread-safe.

var NullSaver HeadSaver = &nullSaver{}

func NewSaver

func NewSaver(lggr logger.Logger, orm ORM, config heads.ChainConfig, htConfig heads.TrackerConfig) HeadSaver

type HeadSet

type HeadSet 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) error
	// 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
}

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

func NewHeadSet

func NewHeadSet() HeadSet

type Listener

type Listener = heads.Listener[*evmtypes.Head, common.Hash]

Type Alias for EVM Head Tracker Components

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)
}

func NewNullORM

func NewNullORM() ORM

type Trackable

type Trackable = heads.Trackable[*evmtypes.Head, common.Hash]

Type Alias for EVM Head Tracker Components

type Tracker

type Tracker = heads.Tracker[*evmtypes.Head, common.Hash]

Type Alias for EVM Head Tracker Components

var NullTracker Tracker = &nullTracker{}

func NewTracker

func NewTracker(
	lggr logger.Logger,
	ethClient Client,
	config heads.ChainConfig,
	htConfig heads.TrackerConfig,
	headBroadcaster Broadcaster,
	headSaver HeadSaver,
	mailMon *mailbox.Monitor,
) Tracker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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