Help us shape the future of Go! Take the 2026 Go Developer Survey

reorgdetector

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0, MIT Imports: 16 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

func (*Config) Validate added in v0.8.0

func (c *Config) Validate() error

Validate checks if the configuration is valid

type Header struct {
	Num  uint64      `meddler:"num"`
	Hash common.Hash `meddler:"hash,hash"`
}

type HeaderWithSubscriberID added in v0.7.1

type HeaderWithSubscriberID struct {
	SubscriberID string      `meddler:"subscriber_id"`
	Num          uint64      `meddler:"num"`
	Hash         common.Hash `meddler:"hash,hash"`
}

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 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) GetDB added in v0.7.1

func (rd *ReorgDetector) GetDB() *sql.DB

GetDB returns the database connection for testing purposes

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) GetTrackedBlockByBlockNumber added in v0.7.1

func (rd *ReorgDetector) GetTrackedBlockByBlockNumber(id string, blockNumber uint64) (*Header, error)

func to get the tracked blocks for a subscriber by block number and hash, it should be 1 or none, from headercache

func (*ReorgDetector) Start

func (rd *ReorgDetector) Start(ctx context.Context) 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