Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for libp2p private networks (pnet) by implementing swarm key functionality. The key change enables users to specify a private network swarm key file via a --pnet flag, which is then used to configure libp2p hosts for secure, isolated network operations.
- Introduces pnet swarm key loading and context management
- Updates all libp2p host creation points to accept and use context-based pnet configuration
- Adds comprehensive test coverage for pnet functionality
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| main.go | Adds global --pnet flag and Before hook to load swarm key into context; updates GetBitswapCID call signature |
| lib/pnet.go | Implements pnet PSK loading from file and context storage/retrieval functions |
| lib/pnet_test.go | Tests pnet PSK loading, validation, and network isolation behavior |
| lib/libp2p.go | Updates libp2pHost to accept context and conditionally apply pnet configuration |
| lib/ping.go | Passes context to libp2pHost call |
| lib/only_connect.go | Passes context to libp2pHost call |
| lib/identify.go | Passes context to libp2pHost call |
| lib/dht.go | Passes context to libp2pHost call |
| lib/bitswap.go | Updates CheckBitswapCID and GetBitswapCID to pass context to libp2pHost |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 24.47% 27.16% +2.69%
==========================================
Files 7 8 +1
Lines 568 578 +10
==========================================
+ Hits 139 157 +18
+ Misses 390 380 -10
- Partials 39 41 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| type pnetPSKContextKey struct{} | ||
|
|
||
| func WithPnetPSK(ctx context.Context, psk pnet.PSK) context.Context { |
There was a problem hiding this comment.
Note: I went with the context plumbing approach mostly for ease. I'm also happy to swap this to something else (e.g. passing around libp2p options or switching to passing a host explicitly and then exposing a default constructor).
No description provided.