Exemple #1
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;
        }