config

package
v0.0.64 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package config handles config data decoded from config.yaml for the explorer service.

Index

Constants

View Source
const (
	// BridgeContractType is the type of a bridge contract.
	BridgeContractType = "bridge"
	// SwapContractType is the type of the swap contract.
	SwapContractType = "swap"
	// MessageBusContractType is the type of a message bus contract.
	MessageBusContractType = "messagebus"
)

TODO: these should be put into the contracts themselves and implement a custom type.

Variables

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

ErrAddressLength indicates that an invalid address length is found.

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 added in v0.0.11

type ChainConfig struct {
	// ChainID is the ID of the chain.
	ChainID uint32 `yaml:"chain_id"`
	// RPCURL is the RPC of the chain.
	RPCURL string `yaml:"rpc_url"`
	// FetchBlockIncrement is the number of blocks to fetch at a time.
	FetchBlockIncrement uint64 `yaml:"fetch_block_increment"`
	// MaxGoroutines is the maximum number of goroutines that can be spawned.
	MaxGoroutines int `yaml:"max_goroutines"`
	// Contracts are the contracts.
	Contracts ContractConfigs `yaml:"contracts"`
}

ChainConfig is the configuration for a chain.

func (ChainConfig) IsValid added in v0.0.11

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

IsValid validates the chain config.

type ChainConfigs added in v0.0.11

type ChainConfigs []ChainConfig

ChainConfigs contains an array fo ChainConfigs.

func (ChainConfigs) IsValid added in v0.0.11

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

IsValid validates the chain config by asserting no two chains appear twice.

type Config

type Config struct {
	// RefreshRate is the rate at which the explorer will refresh the last block height in seconds.
	RefreshRate uint `yaml:"refresh_rate"`
	// ScribeURL is the URL of the Scribe server.
	ScribeURL string `yaml:"scribe_url"`
	// RPCURL is the URL of the RPC server.
	RPCURL string `yaml:"rpc_url"`
	// BridgeConfigAddress is the address of BridgeConfig contract.
	BridgeConfigAddress string `yaml:"bridge_config_address"`
	// BridgeConfigChainID is the ChainID of BridgeConfig contract.
	BridgeConfigChainID uint32 `yaml:"bridge_config_chain_id"`
	// Chains stores the chain configurations.
	Chains ChainConfigs `yaml:"chains"`
}

Config is used to configure the explorer's data consumption.

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 added in v0.0.11

type ContractConfig struct {
	// ContractType is the type of contract.
	ContractType string `yaml:"contract_type"`
	// Addresses are the addresses of the contracts
	Address string `yaml:"address"`
	// StartBlock is where to start backfilling this address from.
	StartBlock int64 `yaml:"start_block"`
}

ContractConfig is the configuration for a contract.

func (ContractConfig) IsValid added in v0.0.11

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

IsValid validates the chain config.

type ContractConfigs added in v0.0.11

type ContractConfigs []ContractConfig

ContractConfigs contains an array fo ChainConfigs.

func (ContractConfigs) IsValid added in v0.0.11

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

IsValid validates the contract config by asserting no two contracts appear twice.

Jump to

Keyboard shortcuts

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