config

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 9 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

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	// ChainID is the ID of the chain.
	ChainID uint32 `toml:"ChainID"`
	// RPCUrl is the URL of the chain's RPC server.
	RPCUrl string `toml:"RPCUrl"`
	// Contracts stores all the contract information for the chain.
	Contracts ContractConfigs `toml:"Contracts"`
}

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 Config

type Config struct {
	// Chains stores all chain information
	Chains ChainConfigs `toml:"Chains"`
	// RefreshRate is the rate at which the scribe will refresh the last block height in seconds.
	RefreshRate uint `toml:"RefreshRate"`
}

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() (string, error)

Encode gets the encoded config.toml 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 `toml:"Address"`
	// StartBlock is the block number to start indexing events from.
	StartBlock uint64 `toml:"StartBlock"`
}

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.

Jump to

Keyboard shortcuts

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