private Task StartSync() { if (!_initConfig.SynchronizationEnabled) { if (_logger.IsWarn) { _logger.Warn($"Skipping blockchain synchronization init due to ({nameof(IInitConfig.SynchronizationEnabled)} set to false)"); } return(Task.CompletedTask); } if (_logger.IsDebug) { _logger.Debug($"Starting synchronization from block {_blockTree.Head.ToString(BlockHeader.Format.Short)}."); } _syncPeerPool.Start(); _synchronizer.Start(); return(Task.CompletedTask); }
public void Retrieves_missing_blocks_in_batches() { _remoteBlockTree = Build.A.BlockTree(_genesisBlock).OfChainLength(SyncBatchSize.Max * 2).TestObject; ISyncPeer peer = new SyncPeerMock(_remoteBlockTree); ManualResetEvent resetEvent = new ManualResetEvent(false); _synchronizer.SyncEvent += (sender, args) => { if (args.SyncEvent == SyncEvent.Completed || args.SyncEvent == SyncEvent.Failed) { resetEvent.Set(); } }; _pool.Start(); _synchronizer.Start(); _pool.AddPeer(peer); resetEvent.WaitOne(_standardTimeoutUnit); Assert.AreEqual(SyncBatchSize.Max * 2 - 1, (int)_blockTree.BestSuggestedHeader.Number); }