Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ AllTests-mainnet
+ Access peers by key test OK
+ Acquire from empty pool OK
+ Acquire/Sorting and consistency test OK
+ Custom filters test OK
+ Delete peer on release text OK
+ Iterators test OK
+ Peer lifetime test OK
Expand Down
13 changes: 5 additions & 8 deletions beacon_chain/networking/eth2_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,12 @@ func netKbps*(peer: Peer): float {.inline.} =
## Returns current network throughput average value in Kbps for peer ``peer``.
round(((peer.netThroughput.average / 1024) * 10_000) / 10_000)

# /!\ Must be exported to be seen by `peerCmp`
func `<`*(a, b: Peer): bool =
## Comparison function indicating `true` if peer `a` ranks worse than peer `b`
if a.score != b.score:
a.score < b.score
elif a.netThroughput.average != b.netThroughput.average:
a.netThroughput.average < b.netThroughput.average
# /!\ Must be exported to be seen by `peerpool`.
func cmp*(a, b: Peer): int =
if a.score == b.score:
cmp(a.netThroughput.average, b.netThroughput.average)
else:
system.`<`(a, b)
cmp(a.score, b.score)

const
maxRequestQuota = 1000000
Expand Down
Loading
Loading