0.9.2 • Published 5 years ago

peer-book v0.9.2

Weekly downloads
666
License
MIT
Repository
github
Last release
5 years ago

Peer Book JavaScript Implementation

npm.io npm.io npm.io Discourse posts npm.io npm.io Dependency Status js-standard-style

Peer Store for libp2p and IPFS

Lead Maintainer

Vasco Santos

Table of Contents

soon™

Installation

npm

> npm i peer-book

Node.JS, Browserify, Webpack

const PeerBook = require('peer-book')

Browser: <script> Tag

Loading this module through a script tag will make the PeerBook obj available in the global namespace.

<script src="https://unpkg.com/peer-book/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/peer-book/dist/index.js"></script>

Usage

put(peerInfo, replace)

Adds the peerInfo using it's peerId to the peerBook

If the peerInfo for that id was already added, the addresses are going to be merged

If replace is set to true, then the peerInfo will be completly overwritten by the new one, without keeping the previous addresses.

get(peerIdLike)

Gets the peerInfo using it's peerId

peerIdLike can be:

  • A base58 peerId string
    • Example: QmfHZLGRxYoF87esc98DetgKwzMhE4gumCC9kq39EBrueM
  • A Multiaddr string with a peer-id
    • Example: /ip4/127.0.0.1/tcp/1/ipfs/QmfHZLGRxYoF87esc98DetgKwzMhE4gumCC9kq39EBrueM
  • A peerId buffer
    • Example: <Buffer 12 20 fb cb db 25 57 c9 4c 7d 73 c6 d9 bb 83 cc e6 4d 7a de 66 59 12 94 bc 8d f3 95 5d 10 e6 ee ce 2e>
  • A PeerId object
  • A Multiaddr object with a peer-id
  • A PeerInfo object

License

MIT