reorgdetector

package
v0.7.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DBPath is the path to the database
	DBPath string `mapstructure:"DBPath"`

	// CheckReorgsInterval is the interval to check for reorgs in tracked blocks
	CheckReorgsInterval types.Duration `mapstructure:"CheckReorgsInterval"`
	// FinalizedBlockType indicates the status of the blocks that will be queried in order to sync
	// if finalizedBlock == "LatestBlock" then it's disabled and we assume the network has no chances of reorgs
	FinalizedBlock aggkittypes.BlockNumberFinality `` //nolint:lll
	/* 135-byte string literal not displayed */
}

Config is the configuration for the reorg detector

func (*Config) GetCheckReorgsInterval

func (c *Config) GetCheckReorgsInterval() time.Duration

GetCheckReorgsInterval returns the interval to check for reorgs in tracked blocks

type Network added in v0.0.2

type Network string
const (
	L1 Network = "l1"
	L2 Network = "l2"
)

func (Network) String added in v0.0.2

func (n Network) String() string

type NoOpReorgDetector added in v0.7.0

type NoOpReorgDetector struct {
}

NoOpReorgDetector is a no-operation implementation of sync.ReorgDetector that does nothing when called, used when reorg detection is not needed

func NewNoOpReorgDetector added in v0.7.0

func NewNoOpReorgDetector() *NoOpReorgDetector

NewNoOpReorgDetector creates a new no-op reorg detector

func (*NoOpReorgDetector) AddBlockToTrack added in v0.7.0

func (n *NoOpReorgDetector) AddBlockToTrack(
	ctx context.Context,
	id string,
	blockNum uint64,
	blockHash common.Hash,
) error

AddBlockToTrack implements sync.ReorgDetector interface

func (*NoOpReorgDetector) GetFinalizedBlockType added in v0.7.0

func (n *NoOpReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality

GetFinalizedBlockType implements sync.ReorgDetector interface

func (*NoOpReorgDetector) GetLastReorgEvent added in v0.7.0

func (n *NoOpReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)

GetLastReorgEvent returns an empty reorg event since no-op detector never detects reorgs

func (*NoOpReorgDetector) String added in v0.7.0

func (n *NoOpReorgDetector) String() string

String implements sync.ReorgDetector interface

func (*NoOpReorgDetector) Subscribe added in v0.7.0

func (n *NoOpReorgDetector) Subscribe(id string) (*Subscription, error)

Subscribe implements sync.ReorgDetector interface

type ReorgDetector

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

func New

func New(client aggkittypes.BaseEthereumClienter, cfg Config, network Network) (*ReorgDetector, error)

func (*ReorgDetector) AddBlockToTrack

func (rd *ReorgDetector) AddBlockToTrack(ctx context.Context, id string, num uint64, hash common.Hash) error

AddBlockToTrack adds a block to the tracked list for a subscriber

func (*ReorgDetector) GetFinalizedBlockType added in v0.0.2

func (rd *ReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality

GetFinalizedBlockType returns the finalized block name

func (*ReorgDetector) GetLastReorgEvent added in v0.5.0

func (rd *ReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)

GetLastReorgEvent returns the the last ReorgEvent stored in reorg_event table

func (*ReorgDetector) IsDisabled added in v0.0.2

func (rd *ReorgDetector) IsDisabled() bool

func (*ReorgDetector) Start

func (rd *ReorgDetector) Start(ctx context.Context) (err error)

Start starts the reorg detector

func (*ReorgDetector) String added in v0.0.2

func (rd *ReorgDetector) String() string

func (*ReorgDetector) Subscribe

func (rd *ReorgDetector) Subscribe(id string) (*Subscription, error)

Subscribe subscribes to reorg events

type ReorgEvent added in v0.1.0

type ReorgEvent struct {
	DetectedAt   int64       `meddler:"detected_at"`
	FromBlock    uint64      `meddler:"from_block"`
	ToBlock      uint64      `meddler:"to_block"`
	SubscriberID string      `meddler:"subscriber_id"`
	TrackedHash  common.Hash `meddler:"tracked_hash,hash"`
	CurrentHash  common.Hash `meddler:"current_hash,hash"`
	Version      string      `meddler:"version"`
}

type Subscription

type Subscription struct {
	ReorgedBlock   chan uint64
	ReorgProcessed chan bool
}

Subscription is a subscription to reorg events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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