diff --git a/src/Nethermind/Nethermind.Synchronization.Test/SnapSync/StateSyncPivotTest.cs b/src/Nethermind/Nethermind.Synchronization.Test/SnapSync/StateSyncPivotTest.cs index 1e2e6e187e7..6e5e7b1ab8a 100644 --- a/src/Nethermind/Nethermind.Synchronization.Test/SnapSync/StateSyncPivotTest.cs +++ b/src/Nethermind/Nethermind.Synchronization.Test/SnapSync/StateSyncPivotTest.cs @@ -43,6 +43,6 @@ int syncPivot stateSyncPivot.GetPivotHeader().Should().NotBeNull(); blockTree.BestSuggestedHeader.Returns(Build.A.BlockHeader.WithNumber(newBestSuggested).TestObject); - stateSyncPivot.GetPivotHeader().Number.Should().Be(newPivotHeader); + stateSyncPivot.GetPivotHeader()?.Number.Should().Be(newPivotHeader); } } diff --git a/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs b/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs index 7d33bfb71ef..f9174805406 100644 --- a/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs +++ b/src/Nethermind/Nethermind.Synchronization/FastSync/StateSyncPivot.cs @@ -16,7 +16,7 @@ namespace Nethermind.Synchronization.FastSync public class StateSyncPivot { private readonly IBlockTree _blockTree; - private BlockHeader _bestHeader; + private BlockHeader? _bestHeader; private readonly ILogger _logger; private readonly ISyncConfig _syncConfig; @@ -35,7 +35,7 @@ public StateSyncPivot(IBlockTree blockTree, ISyncConfig syncConfig, ILogManager _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); } - public BlockHeader GetPivotHeader() + public BlockHeader? GetPivotHeader() { if (_bestHeader is null || (_blockTree.BestSuggestedHeader?.Number + MultiSyncModeSelector.FastSyncLag) - _bestHeader.Number >= _syncConfig.StateMaxDistanceFromHead) { diff --git a/src/Nethermind/Nethermind.Synchronization/SnapSync/ProgressTracker.cs b/src/Nethermind/Nethermind.Synchronization/SnapSync/ProgressTracker.cs index 253ac4b8bd1..0f6be8f9a67 100644 --- a/src/Nethermind/Nethermind.Synchronization/SnapSync/ProgressTracker.cs +++ b/src/Nethermind/Nethermind.Synchronization/SnapSync/ProgressTracker.cs @@ -137,7 +137,7 @@ public void UpdatePivot() public bool IsFinished(out SnapSyncBatch? nextBatch) { - if (!CanSync()) + if (_pivot.GetPivotHeader() is null) { nextBatch = null; return false;