Skip to content

sgns::ChainRpcEndpointProvider

Encapsulates ChainList RPC endpoint loading and validator wiring. More...

#include <ChainRpcEndpointProvider.hpp>

Public Functions

Name
ChainRpcEndpointProvider() =default
void AddObserver(IBridgeInitObserver & observer)
Registers an observer to receive the chain/contract list on Init success.
bool Initialize(const std::filesystem::path & bridge_chains_config_path, PublicChainInputValidator & validator)
Loads RPC endpoints from bridge_chains_config.json and wires them into the validator, then calls IInputValidator::Register per chain.

Detailed Description

class sgns::ChainRpcEndpointProvider;

Encapsulates ChainList RPC endpoint loading and validator wiring.

Reads bridge_chains_config.json at the path provided, extracts chain_id and bridge_contract_address for each chain entry, loads RPC endpoints from the chainlist.org dataset, wires them into PublicChainInputValidator with consensus weights, calls IInputValidator::Register per chain, and notifies IBridgeInitObserver subscribers on success.

Public Functions Documentation

function ChainRpcEndpointProvider

ChainRpcEndpointProvider() =default

function AddObserver

void AddObserver(
    IBridgeInitObserver & observer
)

Registers an observer to receive the chain/contract list on Init success.

Parameters:

Subscription must occur before Initialize() is posted to the io_context so the callback fires inside that same Initialize() invocation.

function Initialize

bool Initialize(
    const std::filesystem::path & bridge_chains_config_path,
    PublicChainInputValidator & validator
)

Loads RPC endpoints from bridge_chains_config.json and wires them into the validator, then calls IInputValidator::Register per chain.

Parameters:

Return: True when at least one chain entry was accepted (had chain_id + bridge_contract_address).

Public endpoints from the ChainList provider contribute 25% consensus weight; any RPC URLs present in the config contribute 50% weight.


Updated on 2026-06-28 at 18:54:57 -0700