config

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config allows you to pass in a custom config for which rpcs to hit

Index

Constants

View Source
const PublicRPCMapURL = "https://raw.githubusercontent.com/DefiLlama/chainlist/master/constants/extraRpcs.json"

PublicRPCMapURL is the url we pull the rpc list from. TODO: this has some rate-limits, they're relatively aggressive but something like gitcdn.xyz would be good here.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	// RPCS is a list of rpcs to use
	RPCs []string `yaml:"rpcs"`
	// Checks is how many rpcs must return the same result for it to be used. This does not apply to height/status based methods
	Checks uint16 `yaml:"confirmations,omitempty"`
}

ChainConfig is the config for a single chain.

type Config

type Config struct {
	// chainID -> chainConfig
	Chains map[uint32]ChainConfig `yaml:"chains"`
	// Port is the port
	Port uint16 `yaml:"port,omitempty"`
	// RefreshInterval is the refresh interval of rpc latency
	// expressed in seconds
	RefreshInterval int `yaml:"refresh_interval,omitempty"`
	// ClientType is the client type to use
	ClientType string `yaml:"client_type,omitempty"`
}

Config holds the config for the chain.

func GetPublicRPCConfig

func GetPublicRPCConfig(ctx context.Context) (c Config, err error)

GetPublicRPCConfig gets the rpc map from defillama. This should be done at startup time. this will retry on a backoffHelper until context cancellation.

func UnmarshallConfig

func UnmarshallConfig(input []byte) (cfg Config, err error)

UnmarshallConfig unmarshalls a config.

func (Config) Marshall

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

Marshall a config to yaml.

Jump to

Keyboard shortcuts

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