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

reorgdetector

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0, MIT Imports: 19 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 etherman.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 EthClient

type EthClient interface {
	SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
}

type EthClientMock

type EthClientMock struct {
	mock.Mock
}

EthClientMock is an autogenerated mock type for the EthClient type

func NewEthClientMock

func NewEthClientMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *EthClientMock

NewEthClientMock creates a new instance of EthClientMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*EthClientMock) EXPECT

func (_m *EthClientMock) EXPECT() *EthClientMock_Expecter

func (*EthClientMock) HeaderByHash

func (_m *EthClientMock) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash provides a mock function with given fields: ctx, hash

func (*EthClientMock) HeaderByNumber

func (_m *EthClientMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber provides a mock function with given fields: ctx, number

func (*EthClientMock) SubscribeNewHead

func (_m *EthClientMock) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

SubscribeNewHead provides a mock function with given fields: ctx, ch

type EthClientMock_Expecter

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

func (*EthClientMock_Expecter) HeaderByHash

func (_e *EthClientMock_Expecter) HeaderByHash(ctx interface{}, hash interface{}) *EthClientMock_HeaderByHash_Call

HeaderByHash is a helper method to define mock.On call

  • ctx context.Context
  • hash common.Hash

func (*EthClientMock_Expecter) HeaderByNumber

func (_e *EthClientMock_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *EthClientMock_HeaderByNumber_Call

HeaderByNumber is a helper method to define mock.On call

  • ctx context.Context
  • number *big.Int

func (*EthClientMock_Expecter) SubscribeNewHead

func (_e *EthClientMock_Expecter) SubscribeNewHead(ctx interface{}, ch interface{}) *EthClientMock_SubscribeNewHead_Call

SubscribeNewHead is a helper method to define mock.On call

  • ctx context.Context
  • ch chan<- *types.Header

type EthClientMock_HeaderByHash_Call

type EthClientMock_HeaderByHash_Call struct {
	*mock.Call
}

EthClientMock_HeaderByHash_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByHash'

func (*EthClientMock_HeaderByHash_Call) Return

func (*EthClientMock_HeaderByHash_Call) Run

func (*EthClientMock_HeaderByHash_Call) RunAndReturn

type EthClientMock_HeaderByNumber_Call

type EthClientMock_HeaderByNumber_Call struct {
	*mock.Call
}

EthClientMock_HeaderByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByNumber'

func (*EthClientMock_HeaderByNumber_Call) Return

func (*EthClientMock_HeaderByNumber_Call) Run

func (*EthClientMock_HeaderByNumber_Call) RunAndReturn

type EthClientMock_SubscribeNewHead_Call

type EthClientMock_SubscribeNewHead_Call struct {
	*mock.Call
}

EthClientMock_SubscribeNewHead_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeNewHead'

func (*EthClientMock_SubscribeNewHead_Call) Return

func (*EthClientMock_SubscribeNewHead_Call) Run

func (*EthClientMock_SubscribeNewHead_Call) RunAndReturn

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 EthClient, 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() etherman.BlockNumberFinality

GetFinalizedBlockType returns the finalized block name

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