From 87e2e8979193b32b1b5adfc605388db809fb6e90 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 17 Apr 2020 17:22:43 +0200 Subject: [PATCH] chore: update content and peer routing interfaces removing peer-info (#43) * chore: update content and peer routing interfaces removing peer-info BREAKING CHANGE: content-routing and peer-routing APIs return an object with relevant properties instead of peer-info --- src/content-routing/README.md | 30 ++++++++++++++++++++++++++++-- src/peer-routing/README.md | 15 ++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/content-routing/README.md b/src/content-routing/README.md index bfda78b04..4d6223702 100644 --- a/src/content-routing/README.md +++ b/src/content-routing/README.md @@ -30,6 +30,32 @@ TBD A valid (read: that follows this abstraction) Content Routing module must implement the following API. -### `.findProviders` +### findProviders -### `.provide` +- `findProviders(cid)` + +Find peers in the network that can provide a specific value, given a key. + +**Parameters** +- [CID](https://github.com/multiformats/js-cid) + +**Returns** + +It returns an `AsyncIterable` containing the identification and addresses of the peers providing the given key, as follows: + +`AsyncIterable<{ id: PeerId, addrs: Multiaddr[] }>` + +### provide + +- `provide(cid)` + +Announce to the network that we are providing the given value. + +**Parameters** +- [CID](https://github.com/multiformats/js-cid) + +**Returns** + +It returns a promise that is resolved on the success of the operation. + +`Promise` diff --git a/src/peer-routing/README.md b/src/peer-routing/README.md index b0667cdfa..66302209c 100644 --- a/src/peer-routing/README.md +++ b/src/peer-routing/README.md @@ -30,12 +30,17 @@ TBD A valid (read: that follows this abstraction) Peer Routing module must implement the following API. -### `.findPeers` - Find peers 'responsible' or 'closest' to a given key +### findPeer -- `Node.js` peerRouting.findPeers(key, function (err, peersPriorityQueue) {}) +- `findPeer(peerId)` -In a peer to peer context, the concept of 'responsability' or 'closeness' for a given key translates to having a way to find deterministically or that at least there is a significant overlap between searches, the same group of peers when searching for the same given key. +Query the network for all multiaddresses associated with a `PeerId`. -This method will query the network (route it) and return a Priority Queue data structure with a list of PeerInfo objects, ordered by 'closeness'. +**Parameters** +- [peerId](https://github.com/libp2p/js-peer-id). -key is a multihash +**Returns** + +It returns the [peerId](https://github.com/libp2p/js-peer-id) together with the known peers [multiaddrs](https://github.com/multiformats/js-multiaddr), as follows: + +`Promise<{ id: PeerId, addrs: Multiaddr[] }>`