Skip to content

Commit

Permalink
Get best peer for receiving new blocks (hyperledger#1944)
Browse files Browse the repository at this point in the history
Signed-off-by: David Mechler <david.mechler@consensys.net>
  • Loading branch information
David Mechler authored Feb 24, 2021
1 parent f1c74ed commit a946152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ private void handleNewBlockHashesFromNetwork(final EthMessage message) {

// Process known blocks we care about
for (final NewBlockHash newBlock : newBlocks) {
processAnnouncedBlock(message.getPeer(), newBlock)
EthPeer bestPeer = ethContext.getEthPeers().bestPeer().orElse(message.getPeer());
processAnnouncedBlock(bestPeer, newBlock)
.whenComplete((r, t) -> requestedBlocks.remove(newBlock.hash()));
}
} catch (final RLPException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public void importsAnnouncedBlocks_aheadOfChainInOrder() {

blockPropagationManager.start();

// Setup additonal peer for best peers list
EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 0);
// Setup peer and messages
final RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 0);
final NewBlockHashesMessage nextAnnouncement =
Expand Down

0 comments on commit a946152

Please sign in to comment.