public override void Dispose() { base.Dispose(); QuantumHandler.Dispose(); AuditLedgerManager?.Dispose(); AuditResultManager?.Dispose(); DisposeAnalyticsManager().Wait(); DisposePerformanceStatisticsManager(); }
public static async Task TearDown() { PendingUpdatesManager?.Stop(); PendingUpdatesManager?.Dispose(); AuditLedgerManager?.Dispose(); AuditResultManager?.Dispose(); await DisposeAnalyticsManager(); AuditLedgerManager?.Dispose(); AuditResultManager?.Dispose(); ExtensionsManager?.Dispose(); WithdrawalStorage?.Dispose(); }
public static async Task Setup(Snapshot snapshot) { Constellation = snapshot.Settings; AccountStorage = new AccountStorage(snapshot.Accounts, Constellation.RequestRateLimits); if (Exchange != null) { Exchange.OnUpdates -= Exchange_OnUpdates; Exchange?.Dispose(); } Exchange = Exchange.RestoreExchange(snapshot.Settings.Assets, snapshot.Orders, IsAlpha); WithdrawalStorage?.Dispose(); WithdrawalStorage = new WithdrawalStorage(snapshot.Withdrawals, (!EnvironmentHelper.IsTest && IsAlpha)); TxCursorManager = new TxCursorManager(snapshot.TxCursor); TxListener?.Dispose(); TxListener = IsAlpha ? (TxListenerBase) new AlphaTxListener(snapshot.TxCursor) : new AuditorTxListener(snapshot.TxCursor); if (IsAlpha) { AuditLedgerManager?.Dispose(); AuditLedgerManager = new AuditLedgerManager(); AuditResultManager?.Dispose(); AuditResultManager = new ResultManager(); await DisposeAnalyticsManager(); AnalyticsManager = new AnalyticsManager( PermanentStorage, DepthsSubscription.Precisions.ToList(), Constellation.Assets.Where(a => !a.IsXlm).Select(a => a.Id).ToList(), snapshot.Orders.Select(o => o.ToOrderInfo()).ToList() ); await AnalyticsManager.Restore(DateTime.UtcNow); AnalyticsManager.StartTimers(); AnalyticsManager.OnError += AnalyticsManager_OnError; AnalyticsManager.OnUpdate += AnalyticsManager_OnUpdate; Exchange.OnUpdates += Exchange_OnUpdates; DisposePerformanceStatisticsManager(); PerformanceStatisticsManager = new PerformanceStatisticsManager(); PerformanceStatisticsManager.OnUpdates += PerformanceStatisticsManager_OnUpdates; } ExtensionsManager?.Dispose(); ExtensionsManager = new ExtensionsManager(); ExtensionsManager.RegisterAllExtensions(); }
public override async Task Setup(Snapshot snapshot) { if (Exchange != null) { Exchange.OnUpdates -= Exchange_OnUpdates; } if (WithdrawalStorage != null) { WithdrawalStorage.OnSubmitTimer -= OnWithdrawalSubmitTimer; } await base.Setup(snapshot); WithdrawalStorage.OnSubmitTimer += OnWithdrawalSubmitTimer; TxListener?.Dispose(); TxListener = new AlphaTxListener(this, snapshot.TxCursor); AuditLedgerManager?.Dispose(); AuditLedgerManager = new AuditLedgerManager(this); AuditResultManager?.Dispose(); AuditResultManager = new ResultManager(this); await DisposeAnalyticsManager(); AnalyticsManager = new AnalyticsManager( PermanentStorage, DepthsSubscription.Precisions.ToList(), Constellation.Assets.Where(a => !a.IsXlm).Select(a => a.Id).ToList(), snapshot.Orders.Select(o => o.ToOrderInfo()).ToList() ); await AnalyticsManager.Restore(DateTime.UtcNow); AnalyticsManager.StartTimers(); AnalyticsManager.OnError += AnalyticsManager_OnError; AnalyticsManager.OnUpdate += AnalyticsManager_OnUpdate; Exchange.OnUpdates += Exchange_OnUpdates; DisposePerformanceStatisticsManager(); PerformanceStatisticsManager = new AlphaPerformanceStatisticsManager(this); PerformanceStatisticsManager.OnUpdates += PerformanceStatisticsManager_OnUpdates; }