registry

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package registry implements the node registry interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DialOptionFunc added in v0.1.1

type DialOptionFunc func(node Node) []grpc.DialOption

type Node

type Node struct {
	NodeID        uint32
	SigningKey    *ecdsa.PublicKey
	HTTPAddress   string
	IsCanonical   bool
	IsValidConfig bool
}

func (*Node) BuildConn added in v1.0.0

func (n *Node) BuildConn(
	extraDialOpts ...grpc.DialOption,
) (*grpc.ClientConn, error)

func (*Node) Equals

func (n *Node) Equals(other Node) bool

type NodeRegistry

type NodeRegistry interface {
	GetNodes() ([]Node, error)
	GetNode(uint32) (*Node, error)
	OnNewNodes() <-chan []Node
	OnChangedNode(uint32) <-chan Node
	Stop()
}

NodeRegistry is responsible for fetching the list of nodes from the registry contract and notifying listeners when the list of nodes changes.

type NodeRegistryContract added in v0.3.0

type NodeRegistryContract interface {
	GetAllNodes(opts *bind.CallOpts) ([]noderegistry.INodeRegistryNodeWithId, error)
}

NodeRegistryContract is a dumbed down interface of abis.NodesCaller for generating mocks.

type SingleNotificationNotifier added in v0.5.0

type SingleNotificationNotifier[T any] struct {
	// contains filtered or unexported fields
}

type SmartContractRegistry

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

SmartContractRegistry notifies listeners of changes to the nodes by polling the contract and diffing the returned node list with what is currently in memory.

This allows it to operate statelessly and not require a database, with a trade-off for latency.

Given how infrequently this list changes, that trade-off seems acceptable.

func NewSmartContractRegistry

func NewSmartContractRegistry(
	ctx context.Context,
	ethclient bind.ContractCaller,
	logger *zap.Logger,
	options *config.ContractsOptions,
) (*SmartContractRegistry, error)

func (*SmartContractRegistry) GetNode

func (s *SmartContractRegistry) GetNode(nodeID uint32) (*Node, error)

func (*SmartContractRegistry) GetNodes

func (s *SmartContractRegistry) GetNodes() ([]Node, error)

func (*SmartContractRegistry) OnChangedNode

func (s *SmartContractRegistry) OnChangedNode(
	nodeID uint32,
) <-chan Node

func (*SmartContractRegistry) OnNewNodes

func (s *SmartContractRegistry) OnNewNodes() <-chan []Node

func (*SmartContractRegistry) SetContractForTest

func (s *SmartContractRegistry) SetContractForTest(contract NodeRegistryContract)

func (*SmartContractRegistry) Start

func (s *SmartContractRegistry) Start() error

Start loads the initial state from the contract and starts a background refresh loop. To stop refreshing callers should cancel the context

func (*SmartContractRegistry) Stop added in v0.1.1

func (s *SmartContractRegistry) Stop()

Jump to

Keyboard shortcuts

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