From 5a4523131d59b7b75a38ba8e3678b5652239a895 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 10 Feb 2021 20:16:33 +0200 Subject: [PATCH] feat: add pinner logs upon peer connection/ disconnection --- packages/concordia-pinner/.eslintrc.js | 1 + packages/concordia-pinner/src/app.js | 1 - packages/concordia-pinner/src/index.js | 8 ++++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/concordia-pinner/.eslintrc.js b/packages/concordia-pinner/.eslintrc.js index 9625123..d6c80de 100755 --- a/packages/concordia-pinner/.eslintrc.js +++ b/packages/concordia-pinner/.eslintrc.js @@ -44,6 +44,7 @@ module.exports = { 'no-console': 'off', 'no-shadow': 'warn', 'no-multi-str': 'warn', + 'no-underscore-dangle': 0, 'jsx-a11y/label-has-associated-control': [2, { labelAttributes: ['label'], controlComponents: ['Input'], diff --git a/packages/concordia-pinner/src/app.js b/packages/concordia-pinner/src/app.js index 690e450..c2fa553 100644 --- a/packages/concordia-pinner/src/app.js +++ b/packages/concordia-pinner/src/app.js @@ -19,7 +19,6 @@ const responseBody = { async function getStats(orbit) { try { - // eslint-disable-next-line no-underscore-dangle const ipfs = orbit._ipfs; const { id } = await ipfs.id(); const peers = await ipfs.swarm.peers(); diff --git a/packages/concordia-pinner/src/index.js b/packages/concordia-pinner/src/index.js index aa5dbb2..0d3c803 100644 --- a/packages/concordia-pinner/src/index.js +++ b/packages/concordia-pinner/src/index.js @@ -84,6 +84,14 @@ const main = async () => { topics: [eventJsonInterface.signature], }, handleWeb3LogEvent(web3, eventJsonInterface, orbit)); + orbit._ipfs.libp2p.connectionManager.on( + 'peer:connect', + (peerInfo) => console.log('Peer connected: ', peerInfo.remotePeer.toB58String()), + ); + orbit._ipfs.libp2p.connectionManager.on( + 'peer:disconnect', + (peerInfo) => console.log('Peer disconnected: ', peerInfo.remotePeer.toB58String()), + ); startAPI(orbit); }))); };