Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only update peer with the first and last block #5659

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
only update peer with the first and last block
Signed-off-by: Stefan <stefan.pingel@consensys.net>
  • Loading branch information
pinges committed Jun 29, 2023
commit 4ce1eb9df885d4546209bc4974280adfa0347d55
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ protected Optional<List<BlockHeader>> processResponse(
BlockHeader prevBlockHeader = firstHeader;
updatePeerChainState(peer, firstHeader);
final int expectedDelta = reverse ? -(skip + 1) : (skip + 1);
BlockHeader header = null;
for (int i = 1; i < headers.size(); i++) {
final BlockHeader header = headers.get(i);
header = headers.get(i);
if (header.getNumber() != prevBlockHeader.getNumber() + expectedDelta) {
// Skip doesn't match, this isn't our data
LOG.debug("header not matching the expected number. Peer: {}", peer);
Expand All @@ -116,8 +117,8 @@ protected Optional<List<BlockHeader>> processResponse(
}
prevBlockHeader = header;
headersList.add(header);
updatePeerChainState(peer, header);
}
updatePeerChainState(peer, header);

LOG.debug("Received {} of {} headers requested from peer {}", headersList.size(), count, peer);
return Optional.of(headersList);
Expand Down