noder

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 11 Imported by: 0

README

noder

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoHealthyNodesFound = errors.New("healthy node was not found")
)
View Source
var (
	ErrorNoSpecifiedNodesFound = errors.New("no specified nodes found")
)

Functions

This section is empty.

Types

type MultiChainNodesStorage

type MultiChainNodesStorage interface {
	GetByChainId(chainId int64) (*Node, error)
	GetNextByChainId(chainId int64) (*Node, error)
	GetHistoryByChainId(chainId int64) (*Node, error)
	GetNextHistoryByChainId(chainId int64) (*Node, error)
	ToSingleChain(chainId int64) (NodesStorage, error)
}

func NewInmemoryMultiChainNodesStorage

func NewInmemoryMultiChainNodesStorage(cfg NodesConfig) MultiChainNodesStorage

type Node

type Node struct {
	Rpc    *ethclient.Client `fig:"rpc,required"`
	RpcUrl string            `fig:"rpc,required"`

	Ws    *ethclient.Client `fig:"ws"`
	WsUrl string            `fig:"ws"`

	ChainId int64 `fig:"chain_id,required"`

	History bool `fig:"history"`
}

func (Node) CheckHealth

func (n Node) CheckHealth() bool

CheckHealth tries to get currentF block number and if it fails, returns false (and true otherwise, respectively)

func (Node) Name

func (n Node) Name() string

Name returns a string representation of the node

type Noder

type Noder interface {
	NodesConfig() NodesConfig
	MultiChainNodesStorage() MultiChainNodesStorage
	NodesStorage() NodesStorage
}

func NewInmemoryHealthy

func NewInmemoryHealthy(getter kv.Getter, kvKey *string) Noder

type NodesConfig added in v0.2.0

type NodesConfig struct {
	Nodes             []Node        `fig:"nodes,required"`
	HealthCheckPeriod time.Duration `fig:"health_check_period,required"`
}

type NodesStorage

type NodesStorage interface {
	Get() (*Node, error)
	GetNext() (*Node, error)
	GetHistory() (*Node, error)
	GetNextHistory() (*Node, error)
}

func NewInmemoryNodesStorage

func NewInmemoryNodesStorage(nodes []Node, healthCheckPeriod time.Duration) NodesStorage

Jump to

Keyboard shortcuts

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