sgns::ChainRpcEndpointProvider¶
Encapsulates ChainList RPC endpoint loading and validator wiring. More...
#include <ChainRpcEndpointProvider.hpp>
Public Types¶
| Name | |
|---|---|
| using std::function< bool()> | CancelChecker Loads RPC endpoints from bridge_chains_config.json + a runtime chainlist fetch, wires them into the validator, then calls IInputValidator::Register per chain. |
| using std::function< void(std::vector< ChainContractPair >)> | ObserverCallback |
Public Functions¶
| Name | |
|---|---|
| ChainRpcEndpointProvider() =default | |
| void | AddObserver(IBridgeInitObserver & observer) Registers an observer to receive the chain/contract list on Init success. |
| void | SetChainlistFetcher(ChainlistFetcher fetcher) Overrides the chainlist dataset fetcher (for tests; no network). |
| bool | Initialize(const std::filesystem::path & bridge_chains_config_path, PublicChainInputValidator & validator, CancelChecker is_cancelled ={}) |
| void | AddObserverCallback(ObserverCallback observer) |
Detailed Description¶
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, runtime-fetches public RPC URLs from the chainid.network chainlist dataset (filter: bridge_contract_address + topic0 attached per chain), wires them into PublicChainInputValidator with consensus weights, calls IInputValidator::Register per chain, and notifies IBridgeInitObserver subscribers on success.
Public Types Documentation¶
using CancelChecker¶
Loads RPC endpoints from bridge_chains_config.json + a runtime chainlist fetch, wires them into the validator, then calls IInputValidator::Register per chain.
Parameters:
- bridge_chains_config_path Path to bridge_chains_config.json.
- validator PublicChainInputValidator to configure.
- is_cancelled Optional cancellation predicate, checked after the blocking chainlist fetch and BEFORE publishing (validator registration + observer notification). Used by GeniusNode to abort a stale init whose account was switched mid-fetch, so it never publishes raw validator pointers / notifies freed observers.
Return: True when at least one chain entry was accepted (had chain_id + bridge_contract_address).
Each fetched public RPC URL contributes 25% consensus weight (≥3 reach the 75-weight quorum). A chainlist fetch failure leaves a chain with no endpoints — it still registers for relayer watch, but receipt verification and catch-up scan fail closed.
using ObserverCallback¶
using sgns::ChainRpcEndpointProvider::ObserverCallback = std::function<void( std::vector<ChainContractPair> )>;
Public Functions Documentation¶
function ChainRpcEndpointProvider¶
function AddObserver¶
Registers an observer to receive the chain/contract list on Init success.
Parameters:
- observer Non-owning reference to an IBridgeInitObserver.
Subscription must occur before Initialize() is posted to the io_context so the callback fires inside that same Initialize() invocation.
function SetChainlistFetcher¶
Overrides the chainlist dataset fetcher (for tests; no network).
Parameters:
- fetcher Callable returning the chainlist JSON text (or nullopt).
Must be called before Initialize(). When unset, Initialize() performs a real HTTPS GET of https://chainid.network/chains.json.
function Initialize¶
bool Initialize(
const std::filesystem::path & bridge_chains_config_path,
PublicChainInputValidator & validator,
CancelChecker is_cancelled ={}
)
function AddObserverCallback¶
Updated on 2026-08-14 at 19:28:58 +0000