Skip to content

Commit

Permalink
Try to get headers from remote nodes if the current header is not upd…
Browse files Browse the repository at this point in the history
…ated for a while
  • Loading branch information
yongjiema committed Jul 9, 2019
1 parent f16cd47 commit 42d6b88
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion neo/Network/P2P/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ private void RequestTasks(TaskSession session)
return;
}
}
if ((!HasHeaderTask || globalTasks[HeaderTaskHash] < MaxConncurrentTasks) && Blockchain.Singleton.HeaderHeight < session.Version.StartHeight)
if ((!HasHeaderTask || globalTasks[HeaderTaskHash] < MaxConncurrentTasks)
&& (Blockchain.Singleton.HeaderHeight < session.Version.StartHeight
|| (Blockchain.Singleton.HeaderHeight == session.Version.StartHeight
&& Blockchain.Singleton.HeaderHeight == sessions.Select(x => x.Value.Version.StartHeight).Max()
&& TimeProvider.Current.UtcNow.ToTimestamp() - 60 >= Blockchain.Singleton.GetBlock(Blockchain.Singleton.CurrentHeaderHash)?.Timestamp)))
{
session.Tasks[HeaderTaskHash] = DateTime.UtcNow;
IncrementGlobalTask(HeaderTaskHash);
Expand Down

0 comments on commit 42d6b88

Please sign in to comment.