mirror of
https://github.com/fosrl/gerbil.git
synced 2026-03-09 07:02:04 -05:00
[PR #39] feat: optimize calculatePeerBandwidth to avoid nested loops #38
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/gerbil/pull/39
Author: @LaurenceJJones
Created: 11/16/2025
Status: 🔄 Open
Base:
main← Head:fix/calcpeerbandwidth-optimization📝 Commits (2)
bba4345main: optimize calculatePeerBandwidth to avoid nested peer scans971452erevert: drop logger formatting changes from calcpeerbandwidth optimization branch📊 Changes
1 file changed (+6 additions, -8 deletions)
View changed files
📝
main.go(+6 -8)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
Build a set of current peer public keys during the primary iteration and prune lastReadings in a single pass, removing the O(n^2) nested loop.
How to test?
No behavior change; improves efficiency when peer lists and lastReadings grow large.
Whole function example calculation
With 5 peers:
old: 5 (primary) + O(5^2) = 30 passes
new: 5 (primary) + 5 (Secondary) = 10 passes
calculation are presumption pass loops had 5 peers and new iteration has same 5 peers
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.