public virtual void Dispose()
        {
            PendingUpdatesManager?.Stop(TimeSpan.FromMilliseconds(0)); PendingUpdatesManager?.Dispose();

            ExtensionsManager?.Dispose();
            WithdrawalStorage?.Dispose();
            TxListener?.Dispose();
        }
        public override async Task Setup(Snapshot snapshot)
        {
            await base.Setup(snapshot);

            TxListener?.Dispose(); TxListener = new AuditorTxListener(this, snapshot.TxCursor);

            DisposePerformanceStatisticsManager(); PerformanceStatisticsManager = new AuditorPerformanceStatisticsManager(this);
            PerformanceStatisticsManager.OnUpdates += PerformanceStatisticsManager_OnUpdates;
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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;
        }