account/ChainRpcEndpointProvider.hpp¶
Loads RPC endpoints from the evmrelay ChainList provider and wires them into PublicChainInputValidator with weighted consensus support. More...
Namespaces¶
| Name |
|---|
| sgns |
Classes¶
| Name | |
|---|---|
| class | sgns::IBridgeInitObserver Observer interface notified when RPC endpoints have been loaded and wired. |
| class | sgns::ChainRpcEndpointProvider Encapsulates ChainList RPC endpoint loading and validator wiring. |
Types¶
| Name | |
|---|---|
| using std::function< std::optional< std::string >()> | ChainlistFetcher Fetches the chainlist dataset (JSON text) used to discover public RPC URLs at startup. |
Detailed Description¶
Loads RPC endpoints from the evmrelay ChainList provider and wires them into PublicChainInputValidator with weighted consensus support.
Date: 2026-05-27 SuperGenius
Types Documentation¶
using ChainlistFetcher¶
Fetches the chainlist dataset (JSON text) used to discover public RPC URLs at startup.
Return: The chainlist JSON text, or std::nullopt on fetch failure.
Production default: HTTPS GET of https://chainid.network/chains.json. Tests inject a callable returning canned JSON (no network).
Source code¶
#ifndef _CHAIN_RPC_ENDPOINT_PROVIDER_HPP_
#define _CHAIN_RPC_ENDPOINT_PROVIDER_HPP_
#include <cstdint>
#include <filesystem>
#include <functional>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include "account/ChainContractPair.hpp"
#include "account/PublicChainInputValidator.hpp"
namespace sgns
{
class IBridgeInitObserver
{
public:
virtual void OnRpcEndpointsReady( std::vector<ChainContractPair> chains ) = 0;
virtual ~IBridgeInitObserver() = default;
};
using ChainlistFetcher = std::function<std::optional<std::string>()>;
class ChainRpcEndpointProvider
{
public:
ChainRpcEndpointProvider() = default;
void AddObserver( IBridgeInitObserver &observer );
void SetChainlistFetcher( ChainlistFetcher fetcher )
{
chainlist_fetcher_ = std::move( fetcher );
}
using CancelChecker = std::function<bool()>;
using ObserverCallback = std::function<void( std::vector<ChainContractPair> )>;
bool Initialize( const std::filesystem::path &bridge_chains_config_path,
PublicChainInputValidator &validator,
CancelChecker is_cancelled = {} );
void AddObserverCallback( ObserverCallback observer );
private:
std::vector<IBridgeInitObserver *> observers_;
std::vector<ObserverCallback> observer_callbacks_;
ChainlistFetcher chainlist_fetcher_;
};
} // namespace sgns
#endif
Updated on 2026-07-12 at 22:42:53 -0700