config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Overview

Package config contains the config for the Scribe

Index

Constants

This section is empty.

Variables

View Source
var ErrAddressLength = errors.New("invalid address length")

ErrAddressLength indicates that an invalid address length is found.

View Source
var ErrDuplicateAddress = errors.New("duplicate address")

ErrDuplicateAddress indicates that a duplicate address is found.

View Source
var ErrDuplicateChainID = errors.New("duplicate chain id")

ErrDuplicateChainID indicates that a duplicate chain ID is found.

View Source
var ErrInvalidChainID = errors.New("invalid chain id")

ErrInvalidChainID indicates that the chain ID is invalid.

View Source
var ErrRequiredField = errors.New("field is required")

ErrRequiredField indicates that a required field is missing.

Functions

func GenerateConfig added in v0.0.26

func GenerateConfig(ctx context.Context, omniRPCUrl, deployPath string, outputPath string, skippedChainIDS []int, cg ClientGenerator) error

GenerateConfig generates a config using a hardhat deployment and scribe. this requires scribe to be live.

Types

type ChainConfig

type ChainConfig struct {
	// ChainID is the ID of the chain.
	ChainID uint32 `yaml:"chain_id"`
	// Contracts stores all the contract information for the chain.
	Contracts ContractConfigs `yaml:"contracts"`
	// GetLogsRange is the max number of blocks to request in a single getLogs request.
	GetLogsRange uint64 `yaml:"get_logs_range"`
	// GetLogsBatchAmount is the number of getLogs requests to include in a single batch request.
	GetLogsBatchAmount uint64 `yaml:"get_logs_batch_amount"`
	// StoreConcurrency is the number of goroutines to use when storing data.
	StoreConcurrency int `yaml:"store_concurrency"`
	// ConcurrencyThreshold is the max number of block from head in which concurrent operations (store, getlogs) is allowed.
	ConcurrencyThreshold uint64 `yaml:"concurrency_threshold"`
	// GetBlockBatchSize is the amount of blocks to get at a time when doing confirmations.
	GetBlockBatchAmount int `yaml:"get_block_batch_amount"`
	// Confirmations is the number of blocks away from the head to livefill to.
	Confirmations uint64 `yaml:"confirmations"`
	// LivefillThreshold is the number of blocks away from the head minus confirmations to livefill to.
	LivefillThreshold uint64 `yaml:"livefill_threshold"`
	// LivefillRange is the number of blocks that the livefill indexer with request for with get logs at once.
	LivefillRange uint64 `yaml:"livefill_range"`
	// LivefillFlushInterval is how long to wait before flushing the livefill indexer db (in seconds)
	LivefillFlushInterval uint64 `yaml:"livefill_flush_interval"`
}

ChainConfig defines the config for a specific chain.

func (ChainConfig) IsValid

func (c ChainConfig) IsValid() (ok bool, err error)

IsValid validates the chain config.

type ChainConfigs

type ChainConfigs []ChainConfig

ChainConfigs contains an array of ChainConfigs.

func (ChainConfigs) IsValid

func (c ChainConfigs) IsValid() (ok bool, err error)

IsValid validates the chain config by asserting no two chains appear twice. It also calls IsValid on each individual ContractConfig.

type ClientGenerator added in v0.0.26

type ClientGenerator func(ctx context.Context, rawURL string) (ReceiptClient, error)

ClientGenerator generates an ethclient from a context and a url, this is used so we can override ethclient.DialContext for testing.

type Config

type Config struct {
	// Chains stores all chain information
	Chains ChainConfigs `yaml:"chains"`
	// RPCURL is the url of the omnirpc.
	RPCURL string `yaml:"rpc_url"`
	// Verbose is used to enable verbose logging.
	Verbose bool `yaml:"verbose"`
}

Config is used to configure a Scribe instance and information about chains and contracts.

func DecodeConfig

func DecodeConfig(filePath string) (cfg Config, err error)

DecodeConfig parses in a config from a file.

func (Config) Encode

func (c Config) Encode() ([]byte, error)

Encode gets the encoded config.yaml file.

func (*Config) IsValid

func (c *Config) IsValid() (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type ContractConfig

type ContractConfig struct {
	// Address is the address of the contract.
	Address string `yaml:"address"`
	// StartBlock is the block number to start indexing events from.
	StartBlock uint64 `yaml:"start_block"`
	// EndBlock is the block number to stop indexing events at. If this is set, it will enforce the start block and ignore the last indexed block.
	EndBlock uint64 `yaml:"end_block"`
	// RefreshRate is the rate at which the contract is refreshed.
	RefreshRate uint64 `yaml:"refresh_rate"`
}

ContractConfig defines the config for a specific contract.

func (ContractConfig) IsValid

func (c ContractConfig) IsValid() (ok bool, err error)

IsValid validates the contract config.

type ContractConfigs

type ContractConfigs []ContractConfig

ContractConfigs contains a list of ContractConfigs.

func (ContractConfigs) IsValid

func (c ContractConfigs) IsValid() (ok bool, err error)

IsValid validates the contract configs by asserting no two contracts appear twice. It also calls IsValid on each individual ContractConfig.

type DBConfig

type DBConfig struct {
	// Type of the database to use for sql.
	Type string `toml:"Type"`
	// ConnString is the connection string used for mysql
	ConnString string `toml:"ConnString"`
}

DBConfig is used for configuring the.

func (*DBConfig) IsValid

func (d *DBConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid asserts the database connection is valid.

type ReceiptClient added in v0.0.26

type ReceiptClient interface {
	// TransactionReceipt returns the receipt of a mined transaction. Note that the
	// transaction may not be included in the current canonical chain even if a receipt
	// exists.
	// TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
}

ReceiptClient is an client that implements receipt fetching.

func DefaultClientGenerator added in v0.0.26

func DefaultClientGenerator(ctx context.Context, rawURL string) (ReceiptClient, error)

DefaultClientGenerator generates the default ethclient.

Jump to

Keyboard shortcuts

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