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

Commit

Permalink
Refactor sortByPriceAndNonce cache to.hex (#203)
Browse files Browse the repository at this point in the history
Removed the ! in the conditional to improve readability.
Cached the result of to.hex for subsequent calls.
  • Loading branch information
nicholasjpaterno authored and davidmurdoch committed Oct 24, 2018
1 parent 0139355 commit 398125f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/blockchain_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,11 @@ BlockchainDouble.prototype.sortByPriceAndNonce = function() {
var sortedByNonce = {};

self.pending_transactions.forEach((tx) => {
if (!sortedByNonce[to.hex(tx.from)]){
sortedByNonce[to.hex(tx.from)] = [tx];
const from = to.hex(tx.from);
if (sortedByNonce[from]){
sortedByNonce[from].push(tx);
} else {
sortedByNonce[to.hex(tx.from)].push(tx);
sortedByNonce[from] = [tx];
}
});

Expand Down
13 changes: 9 additions & 4 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 398125f

Please sign in to comment.