Skip to content

Commit

Permalink
remove unintended diff
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-o committed Oct 2, 2024
1 parent ff76ce5 commit ac973e2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/lambda_ethereum_consensus/p2p/peerbook.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do
Get some peer from the peerbook.
"""
def get_some_peer() do
# TODO: This is a very naive implementation of a peer selection algorithm.
# TODO: use some algorithm to pick a good peer, for now it's random
peerbook = fetch_peerbook!()

if peerbook == %{} do
nil
else
peerbook
|> Enum.sort_by(fn {_peer_id, score} -> score end)
|> Enum.take(4)
|> Enum.random()
|> elem(0)
{peer_id, _score} = Enum.random(peerbook)
peer_id
end
end

Expand Down

0 comments on commit ac973e2

Please sign in to comment.