Skip to content

Commit

Permalink
change 2^64-1 for an esmitation of blocks (0xPolygonHermez#3220) (0xP…
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr authored Feb 7, 2024
1 parent 2ee5030 commit 7756dd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion state/syncinginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ func (p *State) GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (SyncingInfo, e
return SyncingInfo{}, err
}

info.EstimatedHighestBlock = ^uint64(0)
info.IsSynchronizing = syncData.LastBatchNumberSeen > lastBatchNumber
if info.IsSynchronizing {
// Estimation of block counting 1 l2block per missing batch
info.EstimatedHighestBlock = lastBlockNumber + (syncData.LastBatchNumberConsolidated - lastBatchNumber)
} else {
info.EstimatedHighestBlock = lastBlockNumber
}

return info, nil
}
2 changes: 1 addition & 1 deletion state/syncinginfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestGetSyncingInfoOk(t *testing.T) {
require.Equal(t, state.SyncingInfo{
InitialSyncingBlock: uint64(123),
CurrentBlockNumber: uint64(567),
EstimatedHighestBlock: ^uint64(0),
EstimatedHighestBlock: uint64(597),
IsSynchronizing: true,
}, res)
}

0 comments on commit 7756dd3

Please sign in to comment.