docs: update peer store api with metadata (#735)

This commit is contained in:
Vasco Santos 2020-08-21 13:03:29 +02:00 committed by GitHub
parent 4851680c4d
commit 0e3cc5866b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -1216,7 +1216,7 @@ Get the stored information of a given peer, namely its [`PeerId`][peer-id], know
| Type | Description | | Type | Description |
|------|-------------| |------|-------------|
| `{ id: PeerId, addresses: Array<Address>, protocols: Array<string> }` | Peer information of the provided peer | | `{ id: PeerId, addresses: Array<Address>, metadata: Map<string, Buffer>}, protocols: Array<string> }` | Peer information of the provided peer |
#### Example #### Example
@ -1243,13 +1243,13 @@ Get all the stored information of every peer.
| Type | Description | | Type | Description |
|------|-------------| |------|-------------|
| `Map<string, { id: PeerId, addresses: Array<Address>, protocols: Array<string> }>` | Peer data of every peer known | | `Map<string, { id: PeerId, addresses: Array<Address>, metadata: Map<string, Buffer>}, protocols: Array<string> }>` | Peer data of every peer known |
#### Example #### Example
```js ```js
for (let [peerIdString, peer] of peerStore.peers.entries()) { for (let [peerIdString, peer] of peerStore.peers.entries()) {
// peer { id, addresses, protocols } // peer { id, addresses, metadata, protocols }
} }
``` ```

View File

@ -32,6 +32,7 @@ class PeerStore extends EventEmitter {
* @property {PeerId} id peer's peer-id instance. * @property {PeerId} id peer's peer-id instance.
* @property {Array<Address>} addresses peer's addresses containing its multiaddrs and metadata. * @property {Array<Address>} addresses peer's addresses containing its multiaddrs and metadata.
* @property {Array<string>} protocols peer's supported protocols. * @property {Array<string>} protocols peer's supported protocols.
* @property {Map<string, Buffer>} metadata peer's metadata map.
*/ */
/** /**