p2p: start p2p networking and DHT ops when starting services, not when instantiating them#5867
Conversation
7de0382 to
069374b
Compare
* Do not start listening/connecting until net.Start This is done by using NoListenAddr for p2p.Host and by providing an empty bootstrap callback to DHT * Move DHT init to p2p from node * TODO: p2p dht tests
069374b to
864da40
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## feature/p2p #5867 +/- ##
===============================================
- Coverage 55.92% 55.89% -0.03%
===============================================
Files 480 480
Lines 67692 67735 +43
===============================================
+ Hits 37855 37861 +6
- Misses 27272 27309 +37
Partials 2565 2565 ☔ View full report in Codecov by Sentry. |
331c69e to
0233a2d
Compare
| // the libp2p.NoListenAddrs builtin disables relays but this one does not | ||
| var noListenAddrs = func(cfg *libp2p.Config) error { | ||
| cfg.ListenAddrs = []multiaddr.Multiaddr{} | ||
| return nil | ||
| } |
There was a problem hiding this comment.
libp2p docs say that their NoListenAddrs disables relays because:
It also disables relay, unless the user explicitly specifies with an option, as the transport creates an implicit listen address that would make the node dialable through any relay it was connected to.
This is worth looking into, perhaps with another test. I'll see if I can find out more
There was a problem hiding this comment.
I found there is already a test for B -> A -> C transmission - see TestP2PSubmitTX. So we are all covered.
Summary
This is done by using
NoListenAddrfor p2p.Host and by providing an empty bootstrap callback to DHT.When
net.Start()is being called, manually callingListenon p2p host, and unblock thebootstrap callbackto return phonebook or DNS addresses for peering.GossipNode.Start()signature to return an error (and possibly explicitly abort node startup).Test Plan