boxo
boxo copied to clipboard
Improve peer connection handling
This PR was originaly submitted to https://github.com/ipfs/go-bitswap/pull/590
Currently, the bitswap network only adds peers to its client/server peer lists that connected after the network has started. This means the network must be started before enabling the libp2p listeners, otherwise some peers may connect too early and never be added to the network.
To address this, this PR updates the bitswap network's Start() method to first, listen for new peer connection events, and then iterate through all peers and add any that support the bitswap protocols. The issue and solution were originally described by @Stebalien in https://github.com/ipfs/boxo/issues/83.
Thank you for submitting this PR! A maintainer will be here shortly to review it. We are super grateful, but we are also overloaded! Help us by making sure that:
-
The context for this PR is clear, with relevant discussion, decisions and stakeholders linked/mentioned.
-
Your contribution itself is clear (code comments, self-review for the rest) and in its best form. Follow the code contribution guidelines if they apply.
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment. Next steps:
-
A maintainer will triage and assign priority to this PR, commenting on any missing things and potentially assigning a reviewer for high priority items.
-
The PR gets reviews, discussed and approvals as needed.
-
The PR is merged by maintainers when it has been approved and comments addressed.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. We are very grateful for your contribution!
Hey @Jorropo, I ported this change over.
I've filed two related libp2p issues:
- https://github.com/libp2p/go-libp2p/issues/2692 (easier, but may cause unexpected issues).
- https://github.com/libp2p/go-libp2p/issues/2693 (harder, but highly desirable and is likely to fix hidden issues and simplify quite a bit of code just about everywhere).
Codecov Report
Attention: Patch coverage is 73.33333% with 16 lines in your changes are missing coverage. Please review.
Project coverage is 65.48%. Comparing base (
79cb4e2) to head (decd8d9). Report is 23 commits behind head on main.
:exclamation: Current head decd8d9 differs from pull request most recent head a8040f8. Consider uploading reports for the commit a8040f8 to get more accurate results
@@ Coverage Diff @@
## main #526 +/- ##
==========================================
- Coverage 65.56% 65.48% -0.08%
==========================================
Files 207 204 -3
Lines 25597 25588 -9
==========================================
- Hits 16782 16756 -26
- Misses 7336 7351 +15
- Partials 1479 1481 +2
| Files | Coverage Δ | |
|---|---|---|
| bitswap/network/ipfs_impl.go | 74.70% <73.33%> (+0.23%) |
:arrow_up: |
I believe https://github.com/libp2p/go-libp2p/pull/2696 should unblock this from the libp2p side.
@Jorropo any chance you can take a look and provide any remaining feedback?
Triage notes:
- unsure if this is still needed, https://github.com/libp2p/go-libp2p/issues/2692 landed, and the stack is being refactored (e.g. https://github.com/libp2p/go-libp2p-kad-dht/pull/976) to take advantage of it
- thoughts @sukunrt @MarcoPolo @2color?
@lidel are you saying that on the latest version, peers who connect before the bitswap network is started will be included as peers?