public async Task UpdateSyncStatusActivityAsync(CancellationToken cancellationToken)
        {
            Activity activity = new Activity("update-sync-status");

            activity.Start();
            try
            {
                var syncingResponse = await _beaconNodeApi.GetSyncingAsync(cancellationToken).ConfigureAwait(false);

                if (syncingResponse.StatusCode == StatusCode.Success)
                {
                    await _beaconChainInformation.SetSyncStatus(syncingResponse.Content).ConfigureAwait(false);
                }
                else
                {
                    Log.ErrorGettingForkVersion(_logger, (int)syncingResponse.StatusCode, syncingResponse.StatusCode,
                                                null);
                }
            }
            catch (Exception ex)
            {
                Log.ExceptionGettingSyncStatus(_logger, ex.Message, ex);
            }
            finally
            {
                activity.Stop();
            }
        }
        public async Task UpdateSyncStatusActivityAsync(CancellationToken cancellationToken)
        {
            Activity activity = new Activity("update-sync-status");

            activity.Start();
            using IDisposable activityScope = _logger.BeginScope("[TraceId, {TraceId}], [SpanId, {SpanId}]",
                                                                 activity.TraceId, activity.SpanId);
            try
            {
                ApiResponse <Syncing> syncingResponse =
                    await _beaconNodeApi.GetSyncingAsync(cancellationToken).ConfigureAwait(false);

                if (syncingResponse.StatusCode == StatusCode.Success)
                {
                    await _beaconChainInformation.SetSyncStatus(syncingResponse.Content).ConfigureAwait(false);
                }
                else
                {
                    Log.ErrorGettingForkVersion(_logger, (int)syncingResponse.StatusCode, syncingResponse.StatusCode,
                                                null);
                }
            }
            catch (Exception ex)
            {
                Log.ExceptionGettingSyncStatus(_logger, ex.Message, ex);
            }
            finally
            {
                activity.Stop();
            }
        }
        public async Task ShouldGetStatusWhenSyncComplete()
        {
            // Arrange
            Slot            starting           = Slot.One;
            Slot            current            = new Slot(11);
            Slot            highest            = new Slot(11);
            INetworkPeering mockNetworkPeering = Substitute.For <INetworkPeering>();

            mockNetworkPeering.HighestPeerSlot.Returns(highest);
            mockNetworkPeering.SyncStartingSlot.Returns(starting);
            IStore            mockStore   = Substitute.For <IStore>();
            Root              root        = new Root(Enumerable.Repeat((byte)0x12, 32).ToArray());
            Checkpoint        checkpoint  = new Checkpoint(Epoch.Zero, root);
            SignedBeaconBlock signedBlock =
                new SignedBeaconBlock(new BeaconBlock(current, Root.Zero, Root.Zero, BeaconBlockBody.Zero),
                                      BlsSignature.Zero);
            BeaconState state = TestState.Create(slot: current, finalizedCheckpoint: checkpoint);

            mockStore.GetHeadAsync().Returns(root);
            mockStore.GetSignedBlockAsync(root).Returns(signedBlock);
            mockStore.GetBlockStateAsync(root).Returns(state);
            mockStore.IsInitialized.Returns(true);
            mockStore.JustifiedCheckpoint.Returns(checkpoint);

            IServiceCollection testServiceCollection = TestSystem.BuildTestServiceCollection(useStore: true);

            testServiceCollection.AddSingleton(mockNetworkPeering);
            testServiceCollection.AddSingleton(mockStore);
            testServiceCollection.AddSingleton <IHostEnvironment>(Substitute.For <IHostEnvironment>());
            testServiceCollection.AddSingleton <IEth1DataProvider>(Substitute.For <IEth1DataProvider>());
            testServiceCollection.AddSingleton <IOperationPool>(Substitute.For <IOperationPool>());
            ServiceProvider testServiceProvider = testServiceCollection.BuildServiceProvider();

            // Act
            IBeaconNodeApi beaconNode = testServiceProvider.GetService <IBeaconNodeApi>();

            beaconNode.ShouldBeOfType(typeof(BeaconNodeFacade));

            ApiResponse <Syncing> syncingResponse = await beaconNode.GetSyncingAsync(CancellationToken.None);

            Syncing syncing = syncingResponse.Content;

            // Assert
            syncing.IsSyncing.ShouldBeFalse();
            syncing.SyncStatus !.StartingSlot.ShouldBe(Slot.One);
            syncing.SyncStatus.CurrentSlot.ShouldBe(new Slot(11));
            syncing.SyncStatus.HighestSlot.ShouldBe(new Slot(11));
        }
        public async Task <IActionResult> GetAsync(CancellationToken cancellationToken)
        {
            if (_logger.IsDebug())
            {
                LogDebug.NodeSyncingRequested(_logger, null);
            }

            ApiResponse <Syncing> apiResponse =
                await _beaconNode.GetSyncingAsync(cancellationToken).ConfigureAwait(false);

            if (apiResponse.StatusCode == Core2.Api.StatusCode.Success)
            {
                return(Ok(apiResponse.Content));
            }

            return(Problem("Beacon node internal error.", statusCode: (int)apiResponse.StatusCode));
        }