Skip to content

Commit

Permalink
Fix spammy log during snap sync (#7977)
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap authored Dec 30, 2024
1 parent 68261dc commit 950a5a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void UpdatePivot()

public bool IsFinished(out SnapSyncBatch? nextBatch)
{
if (!CanSync())
if (_pivot.GetPivotHeader() is null)
{
nextBatch = null;
return false;
Expand Down

0 comments on commit 950a5a4

Please sign in to comment.