indexer

package
v0.3.1-0...-ee1233d Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000")
)

Functions

func InitFromConfig

func InitFromConfig(ctx context.Context, i *Indexer, cfg *Config) (err error)

InitFromConfig inits a new Indexer from a provided Config struct

Types

type Config

type Config struct {
	// address configs
	SrcBridgeAddress        common.Address
	SrcSignalServiceAddress common.Address
	SrcTaikoAddress         common.Address
	DestBridgeAddress       common.Address
	// db configs
	DatabaseUsername        string
	DatabasePassword        string
	DatabaseName            string
	DatabaseHost            string
	DatabaseMaxIdleConns    uint64
	DatabaseMaxOpenConns    uint64
	DatabaseMaxConnLifetime uint64
	// queue configs
	QueueUsername string
	QueuePassword string
	QueueHost     string
	QueuePort     uint64
	// rpc configs
	SrcRPCUrl                           string
	DestRPCUrl                          string
	ETHClientTimeout                    uint64
	BlockBatchSize                      uint64
	NumGoroutines                       uint64
	SubscriptionBackoff                 uint64
	SyncMode                            SyncMode
	WatchMode                           WatchMode
	NumLatestBlocksToIgnoreWhenCrawling uint64
	EventName                           string
	TargetBlockNumber                   *uint64
	BackOffRetryInterval                time.Duration
	BackOffMaxRetries                   uint64
	OpenQueueFunc                       func() (queue.Queue, error)
	OpenDBFunc                          func() (DB, error)
}

Config is a struct which should be created from the cli or environment variables, populated, and used to create a new Indexer.

func NewConfigFromCliContext

func NewConfigFromCliContext(c *cli.Context) (*Config, error)

NewConfigFromCliContext creates a new config instance from command line flags.

type DB

type DB interface {
	DB() (*sql.DB, error)
	GormDB() *gorm.DB
}

DB is a local interface that lets us narrow down a database type for testing.

type Indexer

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

Indexer is the main struct of this package, containing all dependencies necessary for indexing relayer-related chain data. All database repositories, contract implementations, and configurations will be injected here. An indexer should be configured and deployed for all possible combinations of bridging. IE: an indexer for L1-L2, and another for L2-L1. an L1-L2 indexer will have the L1 configurations as its source, and vice versa for the L2-L1 indexer. They will add messages to a queue specifically for a processor of the same configuration.

func (*Indexer) Close

func (i *Indexer) Close(ctx context.Context)

Close waits for the wait groups internally to be stopped ,which will be done when the context is stopped externally by cmd/main.go shutdown.

func (*Indexer) InitFromCli

func (i *Indexer) InitFromCli(ctx context.Context, c *cli.Context) error

InitFromCli inits a new Indexer from command line or environment variables.

func (*Indexer) Name

func (i *Indexer) Name() string

Name implements the SubcommandAction interface

func (*Indexer) Start

func (i *Indexer) Start() error

Start starts the indexer, which should initialize the queue, add to wait groups, and start filtering or subscribing depending on the WatchMode provided. nolint: funlen

type SyncMode

type SyncMode string

SyncMode is a type which determines how the indexer will start indexing.

var (
	// Sync grabs the latest processed block in the DB and starts from there.
	Sync SyncMode = "sync"
	// Resync starts from genesis, ignoring the database.
	Resync SyncMode = "resync"
	Modes           = []SyncMode{Sync, Resync}
)

type WatchMode

type WatchMode string

WatchMode is a type that determines how the indexer will operate.

var (
	// Filter will filter past blocks, but when catches up to latest block,
	// will stop.
	Filter WatchMode = "filter"
	// Subscribe ignores all past blocks, only subscibes to new events from latest block.
	Subscribe WatchMode = "subscribe"
	// FilterAndSubscribe filters up til latest block, then subscribes to new events. This is the
	// default mode.
	FilterAndSubscribe WatchMode = "filter-and-subscribe"
	// CrawlPastBlocks filters through the past N blocks on a loop, when it reaches `latestBlock - N`,
	// it will recursively start the loop again, filtering for missed events, or ones the
	// processor failed to process.
	CrawlPastBlocks WatchMode = "crawl-past-blocks"
	WatchModes                = []WatchMode{Filter, Subscribe, FilterAndSubscribe, CrawlPastBlocks}
)

Jump to

Keyboard shortcuts

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