config

package
v0.0.161 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 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, requiredConfirmations uint32, 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"`
	// RequiredConfirmations is the number of confirmations required for a block to be finalized.
	RequiredConfirmations uint32 `yaml:"required_confirmations"`
	// Contracts stores all the contract information for the chain.
	Contracts ContractConfigs `yaml:"contracts"`
	// BlockTimeChunkCount is the number of chunks (goroutines) to process at a time while backfilling blocktimes.
	BlockTimeChunkCount uint64 `yaml:"block_time_chunk_count"`
	// BlockTimeChunkSize is the number of blocks to process per chunk (goroutine) while backfilling blocktimes.
	BlockTimeChunkSize uint64 `yaml:"block_time_chunk_size"`
	// ContractSubChunkSize is the number of blocks to request for in each get logs request in the batch request.
	ContractSubChunkSize int `yaml:"contract_sub_chunk_size"`
	// ContractChunkSize is the number of blocks to process per chunk while backfilling contracts.
	ContractChunkSize int `yaml:"contract_chunk_size"`
	// StoreConcurrency is the number of goroutines to use when storing data.
	StoreConcurrency int `yaml:"store_concurrency"`
	// storeConcurrencyThreshold is the max number of block from head in which concurrent store is allowed.
	StoreConcurrencyThreshold uint64 `yaml:"store_concurrency_threshold"`
}

ChainConfig defines the config for a specific chain.

func (ChainConfig) IsValid

func (c ChainConfig) IsValid(ctx context.Context) (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(ctx context.Context) (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"`
	// RefreshRate is the rate at which the scribe will refresh the last block height in seconds.
	RefreshRate uint `yaml:"refresh_rate"`
	// RPCURL is the url of the omnirpc.
	RPCURL string `yaml:"rpc_url"`
	// ConfirmationRefreshRate is the rate at which the scribe will refresh the last confirmed block height in seconds.
	ConfirmationRefreshRate int64 `yaml:"confirmation_refresh_rate"`
}

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(ctx context.Context) (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"`
	// 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(ctx context.Context) (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(ctx context.Context) (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