Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1014 from LiskHQ/1008-refactor-peers-consensus-reuse
Browse files Browse the repository at this point in the history
Remove consensus calculation from Peers.prototype.list - Subtask #1008
  • Loading branch information
karmacoma authored Nov 22, 2017
2 parents 229e0ac + 5a584e8 commit 0877380
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
6 changes: 3 additions & 3 deletions logic/broadcaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ Broadcaster.prototype.getPeers = function (params, cb) {

var originalLimit = params.limit;

modules.peers.list(params, function (err, peers, consensus) {
modules.peers.list(params, function (err, peers) {
if (err) {
return setImmediate(cb, err);
}

if (self.consensus !== undefined && originalLimit === constants.maxPeers) {
library.logger.info(['Broadhash consensus now', consensus, '%'].join(' '));
self.consensus = consensus;
self.consensus = modules.peers.getConsensus(null, peers);
library.logger.info(['Broadhash consensus now', self.consensus, '%'].join(' '));
}

return setImmediate(cb, null, peers);
Expand Down
9 changes: 1 addition & 8 deletions modules/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,7 @@ Peers.prototype.list = function (options, cb) {
return setImmediate(waterCb, null, peers);
}
}
], function (err, peers) {
// Calculate consensus
var consensus = Math.round(options.matched / peers.length * 100 * 1e2) / 1e2;
consensus = isNaN(consensus) ? 0 : consensus;

library.logger.debug(['Listing', peers.length, 'total peers'].join(' '));
return setImmediate(cb, err, peers, consensus);
});
], cb);
};

// Events
Expand Down

0 comments on commit 0877380

Please sign in to comment.