Example #1
0
        private void StartBeamSyncComponents()
        {
            // so bad
            BeamSyncDbProvider         beamSyncDbProvider = _dbProvider as BeamSyncDbProvider;
            ISyncFeed <StateSyncBatch> beamSyncFeed       = beamSyncDbProvider.BeamSyncFeed;
            StateSyncDispatcher        dispatcher         = new StateSyncDispatcher(beamSyncFeed, _syncPeerPool, new StateSyncAllocationStrategyFactory(), _logManager);

            dispatcher.Start(_syncCancellation.Token).ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    if (_logger.IsError)
                    {
                        _logger.Error("Beam sync failed", t.Exception);
                    }
                }
                else
                {
                    if (_logger.IsInfo)
                    {
                        _logger.Info("Beam sync completed.");
                    }
                }
            });
        }
        private void PrepareDownloader(ISyncPeer syncPeer)
        {
            DbContext dbContext = new DbContext(_logger);
            BlockTree blockTree = Build.A.BlockTree().OfChainLength((int)BlockTree.BestSuggestedHeader.Number).TestObject;

            _pool = new SyncPeerPool(blockTree, new NodeStatsManager(new StatsConfig(), LimboLogs.Instance), 25, LimboLogs.Instance);
            _pool.Start();
            _pool.AddPeer(syncPeer);

            SyncConfig syncConfig = new SyncConfig();

            syncConfig.FastSync = true;
            _syncModeSelector   = StaticSelector.StateNodesWithFastBlocks;
            _feed = new StateSyncFeed(dbContext.LocalCodeDb, dbContext.LocalStateDb, new MemDb(), _syncModeSelector, blockTree, _logManager);
            _stateSyncDispatcher = new StateSyncDispatcher(_feed, _pool, new StateSyncAllocationStrategyFactory(), _logManager);
        }
Example #3
0
 private void StartStateSyncComponents()
 {
     _stateSyncFeed = new StateSyncFeed(_dbProvider.CodeDb, _dbProvider.StateDb, _dbProvider.BeamStateDb, _syncMode, _blockTree, _logManager);
     StateSyncDispatcher stateSyncDispatcher = new StateSyncDispatcher(_stateSyncFeed, _syncPeerPool, new StateSyncAllocationStrategyFactory(), _logManager);
     Task syncDispatcherTask = stateSyncDispatcher.Start(_syncCancellation.Token).ContinueWith(t =>
     {
         if (t.IsFaulted)
         {
             if (_logger.IsError)
             {
                 _logger.Error("State sync failed", t.Exception);
             }
         }
         else
         {
             if (_logger.IsInfo)
             {
                 _logger.Info("State sync task completed.");
             }
         }
     });
 }