We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ff76ce5 commit ac973e2Copy full SHA for ac973e2
lib/lambda_ethereum_consensus/p2p/peerbook.ex
@@ -41,17 +41,14 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do
41
Get some peer from the peerbook.
42
"""
43
def get_some_peer() do
44
- # 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
45
peerbook = fetch_peerbook!()
46
47
if peerbook == %{} do
48
nil
49
else
50
- peerbook
51
- |> Enum.sort_by(fn {_peer_id, score} -> score end)
52
- |> Enum.take(4)
53
- |> Enum.random()
54
- |> elem(0)
+ {peer_id, _score} = Enum.random(peerbook)
+ peer_id
55
end
56
57
0 commit comments