Open
Description
We should refactor the host and swarm, such that the peerstore is owned by the host, not by the swarm. The swarm shouldn’t know about the peerstore at all. All it needs to do is dial addresses, accept incoming connections and manage existing ones.
This would allow us to get rid of the slightly convoluted dialing process that we have right now. When you want to dial a new peers, now you have to:
- Put the new addresses into the peerstore
- Ask the swarm to dial these new addresses
As a first step, this can be as easy as replacing the DialPeer(context.Context, peer.ID) error
with a DialPeer(context.Context, peer.ID, []ma.Multiaddr) error
function.
In a second iteration, we probably want to make it possible to interact more intimately with the dial job:
- feed newly discovered addresses into an existing job
- get feedback that an existing job is likely to fail and that it would make sense to start feeding in new addresses (e.g. by starting a DHT lookup for new addresses)