From eaf1e4008651d977c3d25cf0afae32251fdf6f67 Mon Sep 17 00:00:00 2001 From: zeroxbt Date: Thu, 24 Mar 2022 12:16:14 +0100 Subject: [PATCH 1/2] add different logs for buyness --- modules/service/data-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/service/data-service.js b/modules/service/data-service.js index ae6b9273e..bab91e448 100644 --- a/modules/service/data-service.js +++ b/modules/service/data-service.js @@ -709,7 +709,7 @@ class DataService { this.logger.info('TripleStore is busy.'); } if (isToobusy) { - this.logger.info('TripleStore is busy.'); + this.logger.info('Node is busy.'); } return isToobusy || isTripleStoreBusy; } From ff20a555bfef3370533e8c9e921d69b3a5487497 Mon Sep 17 00:00:00 2001 From: zeroxbt Date: Thu, 24 Mar 2022 12:50:11 +0100 Subject: [PATCH 2/2] return after rejecting libp2p message --- external/libp2p-service.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/external/libp2p-service.js b/external/libp2p-service.js index d3f0c4173..10b57b9c2 100644 --- a/external/libp2p-service.js +++ b/external/libp2p-service.js @@ -165,19 +165,16 @@ class Libp2pService { this.node.handle(eventName, async (handlerProps) => { const {stream} = handlerProps; let timestamp = Date.now(); - this.limiter.limit(handlerProps.connection.remotePeer.toB58String()).then(async (blocked) => { - if (blocked) { - const preparedBlockedResponse = await this.prepareForSending(constants.NETWORK_RESPONSES.BLOCKED); - await pipe( - [preparedBlockedResponse], - stream - ); - requestBlocked = true; - this.logger.info(`Blocking request from ${handlerProps.connection.remotePeer._idB58String}. Max number of requests exceeded.`); - return; - } - } - ); + const blocked = await this.limiter.limit(handlerProps.connection.remotePeer.toB58String()); + if(blocked) { + const preparedBlockedResponse = await this.prepareForSending(constants.NETWORK_RESPONSES.BLOCKED); + await pipe( + [preparedBlockedResponse], + stream + ); + this.logger.info(`Blocking request from ${handlerProps.connection.remotePeer._idB58String}. Max number of requests exceeded.`); + return; + } let data = await pipe( stream, async function (source) {