private void Discover() { var request = new AssetPairDiscoveryRequestMessage { Network = _req.NetworkSuggested, Pair = _req.Pair, ConversionEnabled = true, PeggedEnabled = true, ReversalEnabled = true }; var r = AssetPairDiscovery.I.Discover(request); if (r == null) { return; } if (!r.DiscoverFirst.Has <IPublicPricingProvider>()) { return; } ProcessDiscovery(_req, r.DiscoverFirst); _doAfterDiscovery?.Invoke(); }
internal AssetPairDiscoveries Discover(AssetPairDiscoveryRequestMessage request) { var i = GetOrCreateInstance(request); i.Wait(TimeSpan.FromSeconds(20)); return(!i.IsFinished() ? null : i); }
internal AssetPairDiscoveries(AssetPairDiscoveryRequestMessage requestMessage) { Context = requestMessage; ProcessState = ProcessState.None; Task.Run(() => Discover()); }
private AssetPairDiscoveries GetOrCreateInstance(AssetPairDiscoveryRequestMessage request) { lock (_lock) return(_cache.GetOrAdd(request, k => new AssetPairDiscoveries(k))); }
private void AssetPairProviderDiscoveryMessage(AssetPairDiscoveryRequestMessage m) { var networks = AssetPairDiscovery.I.Discover(m); _m.SendAsync(new AssetPairDiscoveryResultMessage(m, networks.DiscoverFirst, networks.Discovered)); }