From 31b1e613d8eafae8ddaeec296cd16fde5f22c543 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Mon, 30 Jul 2018 16:24:42 +0200 Subject: [PATCH] feat: create getters for peerInfo and peerBook --- examples/custom-libp2p/index.js | 4 ++-- src/core/index.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/custom-libp2p/index.js b/examples/custom-libp2p/index.js index e8ebe3d761..4bd8330d5b 100644 --- a/examples/custom-libp2p/index.js +++ b/examples/custom-libp2p/index.js @@ -21,8 +21,8 @@ const assert = require('assert') */ const libp2pFactory = (_ipfsNode, _ipfsConfig) => { // Set convenience variables to clearly showcase some of the useful things that are available - const peerInfo = _ipfsNode._peerInfo - const peerBook = _ipfsNode._peerBook + const peerInfo = _ipfsNode.peerInfo + const peerBook = _ipfsNode.peerBook const bootstrapList = _ipfsConfig.Bootstrap // Create our WebSocketStar transport and give it our PeerId, straight from the ipfs node diff --git a/src/core/index.js b/src/core/index.js index 36f7c3a118..8fc407920f 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -142,6 +142,20 @@ class IPFS extends EventEmitter { boot(this) } + + /** + * @type {PeerBook} + */ + get peerBook () { + return this._peerInfoBook + } + + /** + * @type {PeerInfo} + */ + get peerInfo () { + return this._peerInfo + } } exports = module.exports = IPFS