chains

package
v2.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChainIDEmpty is returned when chain is required but was empty.
	ErrChainIDEmpty = errors.New("chain id empty")
	ErrNotFound     = errors.New("not found")
)

Functions

func EnsureChains

func EnsureChains[I ID](q pg.Q, prefix string, ids []I) (err error)

Types

type ChainConfig

type ChainConfig struct {
	ID      string
	Enabled bool
	Cfg     string // TOML
}

type ChainConfigs

type ChainConfigs[I ID] interface {
	Chains(offset, limit int, ids ...I) ([]ChainConfig, int, error)
}

type ChainService

type ChainService interface {
	services.ServiceCtx
}

ChainService is a live, runtime chain instance, with supporting services.

type ChainSet

type ChainSet[I ID, N Node, S ChainService] interface {
	services.ServiceCtx
	Chains[I]
	Nodes[I, N]

	Name() string
	HealthReport() map[string]error

	// Chain returns the ChainService for this ID (if a configuration is available), creating one if necessary.
	Chain(context.Context, I) (S, error)
}

ChainSet manages a live set of ChainService instances.

func NewChainSet

func NewChainSet[I ID, N Node, S ChainService](chains map[string]S,
	opts ChainSetOpts[I, N], formatID func(I) string,
) (ChainSet[I, N, S], error)

NewChainSet returns a new immutable ChainSet for the given ChainSetOpts.

type ChainSetOpts

type ChainSetOpts[I ID, N Node] interface {
	Validate() error
	ConfigsAndLogger() (Configs[I, N], logger.Logger)
}

ChainSetOpts holds options for configuring a ChainSet via NewChainSet.

type Chains

type Chains[I ID] interface {
	Show(id I) (ChainConfig, error)
	Index(offset, limit int) ([]ChainConfig, int, error)
}

Chains is a generic interface for ChainConfig[I, C] configuration.

type Configs

type Configs[I ID, N Node] interface {
	ChainConfigs[I]
	NodeConfigs[I, N]
}

Configs holds chain and node configurations.

func NewConfigs

func NewConfigs[I ID, N Node](cfgs ConfigsV2[I, N]) Configs[I, N]

NewConfigs returns a Configs backed by ConfigsV2.

type ConfigsV2

type ConfigsV2[I ID, N Node] interface {
	// contains filtered or unexported methods
}

type ID

type ID any

ID types represent unique identifiers within a particular chain type. Using string is recommended.

type Node

type Node any

Node types should be a struct including these default fields:

ID        int32
Name      string

type NodeConfigs

type NodeConfigs[I ID, N Node] interface {
	GetNodesByChainIDs(chainIDs []I) (nodes []N, err error)
	NodeNamed(string) (N, error)
	Nodes(offset, limit int) (nodes []N, count int, err error)
	NodesForChain(chainID I, offset, limit int) (nodes []N, count int, err error)
}

type Nodes

type Nodes[I ID, N Node] interface {
	GetNodes(ctx context.Context, offset, limit int) (nodes []N, count int, err error)
	GetNodesForChain(ctx context.Context, chainID I, offset, limit int) (nodes []N, count int, err error)
}

Nodes is a generic interface for Node configuration.

Directories

Path Synopsis
evm
gas
gas/cmd/arbgas
arbgas takes a single URL argument and prints the result of three GetLegacyGas calls to the Arbitrum gas estimator.
arbgas takes a single URL argument and prints the result of three GetLegacyGas calls to the Arbitrum gas estimator.
log
logpoller
Package logpoller is a service for querying EVM log data.
Package logpoller is a service for querying EVM log data.

Jump to

Keyboard shortcuts

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