libp2p / libp2p/go-libp2p

host / swarm: move the peerstore out of the swarm

Open
#1,992 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

effort/days exp/intermediate kind/architecture
Dominant language
Go
Stars
6.9k
Forks
1.3k
Avg merge
13d 21h
Merged PRs (30d)
1

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:

  1. Put the new addresses into the peerstore
  2. 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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing DialPeer and the current peerstore ownership across the host and swarm, then follow the existing dialing flow. The initial milestone is for DialPeer to accept peer addresses while the swarm no longer owns or knows about the peerstore; the later dial-job interactions remain part of the broader design.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.