Skip to content

Commit

Permalink
Merge pull request #1849 from OriginTrail/v6/bugfix/busyness-check
Browse files Browse the repository at this point in the history
properly return after rejecting libp2p message
  • Loading branch information
kotlarmilos authored Mar 24, 2022
2 parents 8359e5f + ff20a55 commit eec83d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions external/libp2p-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion modules/service/data-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit eec83d0

Please sign in to comment.