indexer

package module
v0.0.0-...-412688d Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSentryDSNNotSet signals that not Data Source Name was provided
	// with which to configure Sentry logging.
	ErrSentryDSNNotSet = errors.New("sentry-dsn must be set if use-sentry " +
		"is true")
)

Functions

func Main

func Main(gitVersion string) func(ctx *cli.Context) error

Main is the entrypoint into the indexer service. This method returns a closure that executes the service and blocks until the service exits. The use of a closure allows the parameters bound to the top-level main package, e.g. GitVersion, to be captured and used once the function is executed.

func ParseL1Address

func ParseL1Address(address string) (common.Address, error)

ParseL1Address parses a L1 ETH addres from a hex string. This method will fail if the address is not a valid hexidecimal address.

func ParseL2Address

func ParseL2Address(address string) (l2common.Address, error)

ParseL2Address parses a L2 ETH addres from a hex string. This method will fail if the address is not a valid hexidecimal address.

func SentryStreamHandler

func SentryStreamHandler(wr io.Writer, fmtr log.Format) log.Handler

SentryStreamHandler creates a log.Handler that behaves similarly to log.StreamHandler, however it writes any log with severity greater than or equal to log.LvlError to Sentry. In that case, the passed log.Record is encoded using JSON rather than the default terminal output, so that it can be captured for debugging in the Sentry dashboard.

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig ensures additional constraints on the parsed configuration to ensure that it is well-formed.

Types

type Config

type Config struct {

	// BuildEnv identifies the environment this binary is intended for, i.e.
	// production, development, etc.
	BuildEnv string

	// EthNetworkName identifies the intended Ethereum network.
	EthNetworkName string

	// ChainID identifies the chain being indexed.
	ChainID int64

	// L1EthRpc is the HTTP provider URL for L1.
	L1EthRpc string

	// L2EthRpc is the HTTP provider URL for L1.
	L2EthRpc string

	// L1AddressManagerAddress is the address of the address manager for L1.
	L1AddressManagerAddress string

	// L2GenesisBlockHash is the l2 genesis block hash.
	L2GenesisBlockHash string

	// PollInterval is the delay between querying L2 for more transaction
	// and creating a new batch.
	PollInterval time.Duration

	// Hostname of the database connection.
	DBHost string

	// Port of the database connection.
	DBPort uint64

	// Username of the database connection.
	DBUser string

	// Password of the database connection.
	DBPassword string

	// Database name of the database connection.
	DBName string

	// LogLevel is the lowest log level that will be output.
	LogLevel string

	// LogTerminal if true, prints to stdout in terminal format, otherwise
	// prints using JSON. If SentryEnable is true this flag is ignored, and logs
	// are printed using JSON.
	LogTerminal bool

	// SentryEnable if true, logs any error messages to sentry. SentryDsn
	// must also be set if SentryEnable is true.
	SentryEnable bool

	// SentryDsn is the sentry Data Source Name.
	SentryDsn string

	// SentryTraceRate the frequency with which Sentry should flush buffered
	// events.
	SentryTraceRate time.Duration

	// StartBlockNumber is the block number to start indexing from.
	StartBlockNumber uint64

	// StartBlockHash is the block hash to start indexing from.
	StartBlockHash string

	// ConfDepth is the number of confirmations after which headers are
	// considered confirmed.
	ConfDepth uint64

	// MaxHeaderBatchSize is the maximum number of headers to request as a
	// batch.
	MaxHeaderBatchSize uint64

	// RESTHostname is the hostname at which the REST server is running.
	RESTHostname string

	// RESTPort is the port at which the REST server is running.
	RESTPort uint64

	// MetricsServerEnable if true, will create a metrics client and log to
	// Prometheus.
	MetricsServerEnable bool

	// MetricsHostname is the hostname at which the metrics server is running.
	MetricsHostname string

	// MetricsPort is the port at which the metrics server is running.
	MetricsPort uint64

	// DisableIndexer enables/disables the indexer.
	DisableIndexer bool
}

func NewConfig

func NewConfig(ctx *cli.Context) (Config, error)

NewConfig parses the Config from the provided flags or environment variables. This method fails if ValidateConfig deems the configuration to be malformed.

type Indexer

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

Indexer is a service that configures the necessary resources for running the Sync and BlockHandler sub-services.

func NewIndexer

func NewIndexer(cfg Config, gitVersion string) (*Indexer, error)

NewIndexer initializes the Indexer, gathering any resources that will be needed by the TxIndexer and StateIndexer sub-services.

func (*Indexer) Serve

func (b *Indexer) Serve() error

Serve spins up a REST API server at the given hostname and port.

func (*Indexer) Start

func (b *Indexer) Start() error

Start starts the starts the indexing service on L1 and L2 chains and also starts the REST server.

func (*Indexer) Stop

func (b *Indexer) Stop()

Stop stops the indexing service on L1 and L2 chains.

Directories

Path Synopsis
bindings
scc
cmd
l1
l2

Jump to

Keyboard shortcuts

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