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 virtual Task Setup(Snapshot snapshot) { Constellation = snapshot.Settings; AccountStorage = new AccountStorage(snapshot.Accounts); Exchange?.Dispose(); Exchange = Exchange.RestoreExchange(snapshot.Settings.Assets, snapshot.Orders, IsAlpha, useLegacyOrderbook); WithdrawalStorage?.Dispose(); WithdrawalStorage = new WithdrawalStorage(snapshot.Withdrawals); TxCursorManager = new TxCursorManager(snapshot.TxCursor); return(Task.CompletedTask); }
public TxCursorUpdateEffectProcessor(TxCursorUpdateEffect effect, TxCursorManager txManager) : base(effect) { this.txManager = txManager; }
public static void AddCursorUpdate(this EffectProcessorsContainer effectProcessors, TxCursorManager txManager, long newCursor, long prevCursor) { effectProcessors.Add(new TxCursorUpdateEffectProcessor( new TxCursorUpdateEffect { Apex = effectProcessors.Apex, Cursor = newCursor, PrevCursor = prevCursor }, txManager )); }