Skip to content

sgns::LocalPriceManager

#include <LocalPriceManager.hpp>

Public Types

Name
using std::function< std::chrono::system_clock::time_point()> Clock
Injectable clock for hermetic band tests — same type as RateLimitHoldOff::Clock (PriceRetryPolicy.hpp).
using boost::asio::strand< boost::asio::io_context::executor_type > Strand
Strand over the manager's io_context executor (P-3 typedef precedent: ws_client_impl.hpp:22). All manager state is confined to handlers running on this strand.

Public Functions

Name
LocalPriceManager(std::shared_ptr< IPriceSource > coinGeckoTier, std::shared_ptr< IPriceSource > gnusServiceTier, std::chrono::milliseconds coalescingWindow =std::chrono::milliseconds(50), Clock now =[] { return std::chrono::system_clock::now();})
Construct the manager and start its runner thread.
~LocalPriceManager()
Drain-then-join teardown: posts a shutdown handler onto the strand (03-02 extends it to cancel window timers and resolve parked waiters), releases the work guard, then joins the runner thread. ioc_->stop() is NEVER called — it would abandon queued handlers.
LocalPriceManager(const LocalPriceManager & ) =delete
LocalPriceManager & operator=(const LocalPriceManager & ) =delete
PriceResult< std::vector< PriceQuote > > GetQuotes(const std::vector< std::string > & ids, const std::string & currency ="usd")
Get quotes for the given asset ids, serving fresh L1 entries with zero network (LPM-01) and fetching only misses.

Public Types Documentation

using Clock

using sgns::LocalPriceManager::Clock =  std::function<std::chrono::system_clock::time_point()>;

Injectable clock for hermetic band tests — same type as RateLimitHoldOff::Clock (PriceRetryPolicy.hpp).

using Strand

using sgns::LocalPriceManager::Strand =  boost::asio::strand<boost::asio::io_context::executor_type>;

Strand over the manager's io_context executor (P-3 typedef precedent: ws_client_impl.hpp:22). All manager state is confined to handlers running on this strand.

Public Functions Documentation

function LocalPriceManager

LocalPriceManager(
    std::shared_ptr< IPriceSource > coinGeckoTier,
    std::shared_ptr< IPriceSource > gnusServiceTier,
    std::chrono::milliseconds coalescingWindow =std::chrono::milliseconds(50),
    Clock now =[] { return std::chrono::system_clock::now();}
)

Construct the manager and start its runner thread.

Parameters:

  • coinGeckoTier Tier 1 — CoinGecko direct (IPriceSource seam, D-13)
  • gnusServiceTier Tier 2 — token.gnus.ai (held from day one; the chain walk reaches it in 03-03 — the ctor signature is final for the phase)
  • coalescingWindow Batch-collection window before dispatch (D-05, default 50ms; tests inject 0ms / 1000ms regimes)
  • now Injectable clock for hermetic freshness-band tests

function ~LocalPriceManager

~LocalPriceManager()

Drain-then-join teardown: posts a shutdown handler onto the strand (03-02 extends it to cancel window timers and resolve parked waiters), releases the work guard, then joins the runner thread. ioc_->stop() is NEVER called — it would abandon queued handlers.

function LocalPriceManager

LocalPriceManager(
    const LocalPriceManager & 
) =delete

function operator=

LocalPriceManager & operator=(
    const LocalPriceManager & 
) =delete

function GetQuotes

PriceResult< std::vector< PriceQuote > > GetQuotes(
    const std::vector< std::string > & ids,
    const std::string & currency ="usd"
)

Get quotes for the given asset ids, serving fresh L1 entries with zero network (LPM-01) and fetching only misses.

Parameters:

  • ids Asset ids, e.g. {"genius-ai"}
  • currency Target currency, default "usd"

Return: One PriceQuote per servable requested id, or a status-bearing PriceFetchFailure

Note:

  • BLOCKING (D-01): posts a handler onto the strand and parks the calling thread on a future until the chain resolves. Worst-case latency is bounded by the tier retry schedule when both tiers time out.
  • MUST NOT be called from the manager's own runner thread — the future-wait would self-deadlock (the GeniusNode:: HostConnectedness caveat). Phase 3 callers (test threads) and Phase 4 node threads are all off-thread — safe by construction.

Updated on 2026-10-09 at 04:02:48 +0000