public async Task StartSync_CurrentSyncStateIsNotUnInitialized_Test() { _syncStateProvider.SetSyncTarget(10); _peerPool.TryAddPeer(CreatePeer(15)); _peerPool.TryAddPeer(CreatePeer(16)); await _syncStateService.StartSyncAsync(); _syncStateService.GetCurrentSyncTarget().ShouldBe(10); }
public Task HandleEventAsync(BlockAcceptedEvent eventData) { if (_syncStateService.SyncState == SyncState.Finished) { // if sync is finished we announce the block _networkService.BroadcastAnnounceAsync(eventData.Block.Header); } else if (_syncStateService.SyncState == SyncState.Syncing) { // if syncing and the block is higher the current target, try and update. if (_syncStateService.GetCurrentSyncTarget() <= eventData.Block.Header.Height) { _taskQueueManager.Enqueue(async() => { await _syncStateService.UpdateSyncStateAsync(); }, OSConstants.InitialSyncQueueName); } } return(Task.CompletedTask); }