From 98d1413d0fae2258397d35e6a24f4a87ada8d671 Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Wed, 7 Apr 2021 18:02:40 -0400 Subject: [PATCH] fix(dot/network): fix justification request at head logic (#1510) --- dot/network/sync_justification.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dot/network/sync_justification.go b/dot/network/sync_justification.go index c5310cc144..e0897d0d10 100644 --- a/dot/network/sync_justification.go +++ b/dot/network/sync_justification.go @@ -36,6 +36,15 @@ func (q *syncQueue) finalizeAtHead() { return } + head, err := q.s.blockState.BestBlockNumber() + if err != nil { + continue + } + + if head.Int64() < q.goal { + continue + } + curr, err := q.s.blockState.GetFinalizedHeader(0, 0) if err != nil { continue @@ -50,12 +59,6 @@ func (q *syncQueue) finalizeAtHead() { prev = curr - // no new blocks have been finalized, request block justifications from peers - head, err := q.s.blockState.BestBlockNumber() - if err != nil { - continue - } - start := head.Uint64() - uint64(blockRequestSize) if curr.Number.Uint64() > start { start = curr.Number.Uint64() + 1