config

package
v0.0.0-...-fead75b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

config

Application configuration. Parses json/yaml into a configuration model as so

{
  "app_name": "carbonable-indexer",
  "start_block": 1,
  "contracts": [
    {
      "name": "carbonable-token",
      "address": "0x06a09ccb1caaecf3d9683efe335a667b2169a409a5293e49c23cb8b539c4e48",
      "events": {
        "Transfer": "token:transfer"
      }
    }
  ]
}
  • app_name is the name of the application.
  • start_block is the block number to start indexing from. must be > 0
  • contracts is an array of contracts to index.
    • name is the name of the contract
    • address is the address of the contract
    • events is an object of events to listen to.
      • key is the event name as defined in the contract
      • value is the event name you want to receive from the indexer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParseConfig         = errors.New("unable to parse config")
	ErrUnmarshalYamlFailed = errors.New("unable to unmarshal yaml config")
	ErrUnmarshalJsonFailed = errors.New("unable to unmarshal json config")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	AppName    string `yaml:"app_name" json:"app_name"`
	Hash       string
	Contracts  []Contract `yaml:"contracts" json:"contracts"`
	StartBlock uint64     `yaml:"start_block" json:"start_block"`
}

func FromJson

func FromJson(data []byte) (*Config, error)

Create config from json input

func FromYamlFile

func FromYamlFile(file string) (*Config, error)

Create config from yaml input

func NewCongig

func NewCongig() *Config

func (*Config) ComputeHash

func (c *Config) ComputeHash() *Config

func (*Config) GetContract

func (c *Config) GetContract(address string) *Contract

type Contract

type Contract struct {
	Events  map[string]string `yaml:"events" json:"events"`
	Address string            `yaml:"address" json:"address"`
	Name    string            `yaml:"name" json:"name"`
}

type ContractRepository

type ContractRepository interface {
	SaveConfig(Config) error
	GetConfigs() ([]Config, error)
	GetConfig(string) (*Config, error)
}

type NatsContractRepository

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

func NewPebbleContractRepository

func NewPebbleContractRepository(s storage.Storage) *NatsContractRepository

func (*NatsContractRepository) GetConfig

func (r *NatsContractRepository) GetConfig(name string) (*Config, error)

func (*NatsContractRepository) GetConfigs

func (r *NatsContractRepository) GetConfigs() ([]Config, error)

func (*NatsContractRepository) SaveConfig

func (r *NatsContractRepository) SaveConfig(c Config) error

Jump to

Keyboard shortcuts

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