Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove peer info usage #610

Merged
merged 2 commits into from
Apr 24, 2020
Merged

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Apr 15, 2020

In the context of deprecating peer-info as described on libp2p/js-libp2p#589, this PR removes the peer-info usage on the API, internal code usage and tests. Moreover, all the modules were updated for the new versions also without using peer-info and the docs were also updated!

It is important point out that with these modifications:

BREAKING CHANGE: all API methods with peer-info parameters or return values were changed. You can check the API.md document, in order to check the new values to use

@@ -163,6 +164,10 @@ const libp2p = await Libp2p.create(options)
await libp2p.stop()
```

### addresses

TODO with `address-manager`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will come in a follow up PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BREAKING CHANGE: all API methods with peer-info parameters or return values were changed. You can check the API.md document, in order to check the new values to use
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good! Most of my comments are things to think about and would likely be best suited for subsequent PRs if we choose to do them.

doc/API.md Outdated Show resolved Hide resolved
doc/API.md Outdated Show resolved Hide resolved
| [`PeerInfo`][peer-info] | Peer information of the provided peer |

TODO: change when `peer-info` is deprecated to new pointer
| `{ id: PeerId, multiaddrInfos: Array<MultiaddrInfo>, protocols: Array<string> }` | Peer information of the provided peer |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a naming thought that occurred, should we just start referring to MultiaddrInfo as Address? The idea being, we have an AddressBook, it makes sense for it to store addresses (addrs). An Address includes a Multiaddr (describing the network location of a peer) along with other metadata (TTL, confidence, origin, etc).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was not totally happy with the MultiaddrInfo naming. we are already using that naming in the dht already, but I will do a follow up PR here and in the DHT to move into Address

doc/API.md Show resolved Hide resolved
}

if (addr && peerStore) {
peerStore.addressBook.add(peer, [addr])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're redoing this function it might be a good time to remove the update from it as it's a bit error prone (doing a get that includes a write). Perhaps this should be getPeer and we return { id, multiaddrs }? Then the calling function can choose whether or not it wants to store the address.

src/index.js Show resolved Hide resolved
src/index.js Show resolved Hide resolved
discoveryService = new DiscoveryService(Object.assign({}, config, { peerInfo: this.peerInfo, libp2p: this }))
discoveryService = new DiscoveryService(Object.assign({}, config, {
peerId: this.peerId,
multiaddrs: this.addresses.listen,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have an AddressManager the discovery service should just use that from libp2p.addressManager. While they don't right now, in the future our announce addresses will be able to change over time (AutoNat, AutoRelay, etc) and we should be sharing the most recent ones via the discovery services.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will include in #612 to remove this

src/registrar.js Show resolved Hide resolved
src/registrar.js Show resolved Hide resolved
@vasco-santos vasco-santos marked this pull request as ready for review April 24, 2020 10:59
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants