Documentation ¶
Index ¶
- Constants
- Variables
- func NewEvmHeadBroadcaster(lggr logger.Logger) *evmHeadBroadcaster
- func NewEvmHeadListener(lggr logger.Logger, ethClient evmclient.Client, config Config, ...) *evmHeadListener
- func NewHeadBroadcaster[H commontypes.Head[BLOCK_HASH], BLOCK_HASH commontypes.Hashable](lggr logger.Logger) *headBroadcaster[H, BLOCK_HASH]
- func NewHeadListener[HTH htrktypes.Head[BLOCK_HASH, ID], S commontypes.Subscription, ...](lggr logger.Logger, client CLIENT, config htrktypes.Config, ...) *headListener[HTH, S, ID, BLOCK_HASH]
- func NewHeadSaver(lggr logger.Logger, orm ORM, config Config) httypes.HeadSaver
- func NewHeadTracker(lggr logger.Logger, ethClient evmclient.Client, config Config, ...) httypes.HeadTracker
- func NewWrappedConfig(c Config) *wrappedConfig
- type Config
- type Heads
- type ORM
Constants ¶
View Source
const HeadsBufferSize = 10
HeadsBufferSize - The buffer is used when heads sampling is disabled, to ensure the callback is run for every head
View Source
const TrackableCallbackTimeout = 2 * time.Second
Variables ¶
View Source
var NullSaver httypes.HeadSaver = &nullSaver{}
View Source
var NullTracker httypes.HeadTracker = &nullTracker{}
Functions ¶
func NewEvmHeadBroadcaster ¶
func NewEvmHeadListener ¶
func NewHeadBroadcaster ¶
func NewHeadBroadcaster[ H commontypes.Head[BLOCK_HASH], BLOCK_HASH commontypes.Hashable, ]( lggr logger.Logger, ) *headBroadcaster[H, BLOCK_HASH]
NewHeadBroadcaster creates a new HeadBroadcaster
func NewHeadListener ¶
func NewHeadListener[ HTH htrktypes.Head[BLOCK_HASH, ID], S commontypes.Subscription, ID txmgrtypes.ID, BLOCK_HASH commontypes.Hashable, CLIENT htrktypes.Client[HTH, S, ID, BLOCK_HASH], ]( lggr logger.Logger, client CLIENT, config htrktypes.Config, chStop chan struct{}, ) *headListener[HTH, S, ID, BLOCK_HASH]
func NewHeadTracker ¶
func NewHeadTracker( lggr logger.Logger, ethClient evmclient.Client, config Config, headBroadcaster httypes.HeadBroadcaster, headSaver httypes.HeadSaver, mailMon *utils.MailboxMonitor, ) httypes.HeadTracker
NewHeadTracker instantiates a new HeadTracker using HeadSaver to persist new block numbers.
func NewWrappedConfig ¶ added in v2.2.0
func NewWrappedConfig(c Config) *wrappedConfig
Types ¶
type Config ¶
type Config interface { BlockEmissionIdleWarningThreshold() time.Duration EvmFinalityDepth() uint32 EvmHeadTrackerHistoryDepth() uint32 EvmHeadTrackerMaxBufferSize() uint32 EvmHeadTrackerSamplingInterval() time.Duration }
Config represents a subset of options needed by head tracker
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(historyDepth uint, newHeads ...*evmtypes.Head) // Count returns number of heads in the collection. Count() int }
Heads is a collection of heads. All methods are thread-safe.
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 the top N block numbers remain TrimOldHeads(ctx context.Context, n uint) (err error) // LatestHead returns the highest seen head LatestHead(ctx context.Context) (head *evmtypes.Head, err error) // LatestHeads returns the latest heads up to given limit LatestHeads(ctx context.Context, limit uint) (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) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.