Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core-transaction-pool-mem): sort transactions by numerical fee value #1288

Merged
merged 6 commits into from
Nov 5, 2018

Conversation

zillionn
Copy link
Contributor

@zillionn zillionn commented Nov 5, 2018

In getTransactionsOrderedByFee() a.transaction.fee and b.transaction.fee are BigNumber objects not numbers and the comparison fails.

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improve a current implementation without adding a new feature or fixing a bug)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build (changes that affect the build system)
  • Docs (documentation only changes)
  • Test (adding missing tests or fixing existing tests)
  • Other... Please describe:

Checklist

  • I have read the CONTRIBUTING documentation
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

return -1
}
if (a.transaction.fee < b.transaction.fee) {
if (+bignumify(a.transaction.fee).toFixed() < +bignumify(b.transaction.fee).toFixed()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -218,10 +219,10 @@ class Mem {
getTransactionsOrderedByFee () {
if (!this.allIsSorted) {
this.all.sort(function (a, b) {
if (a.transaction.fee > b.transaction.fee) {
if (+bignumify(a.transaction.fee).toFixed() > +bignumify(b.transaction.fee).toFixed()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost ghost assigned faustbrian Nov 5, 2018
@ghost ghost added the review label Nov 5, 2018
@faustbrian faustbrian changed the title bug(core-transaction-pool-mem): Wrong sorting by fee fix(core-transaction-pool-mem): wrong sorting by fee Nov 5, 2018
@faustbrian faustbrian changed the title fix(core-transaction-pool-mem): wrong sorting by fee fix(core-transaction-pool-mem): sort transactions by numerical fee value Nov 5, 2018
@codecov-io
Copy link

Codecov Report

Merging #1288 into develop will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1288      +/-   ##
===========================================
- Coverage    77.58%   77.55%   -0.03%     
===========================================
  Files          397      397              
  Lines         6925     6925              
  Branches       952      952              
===========================================
- Hits          5373     5371       -2     
- Misses        1364     1366       +2     
  Partials       188      188
Impacted Files Coverage Δ
packages/core-transaction-pool-mem/lib/mem.js 100% <100%> (ø) ⬆️
packages/core-blockchain/lib/blockchain.js 77.11% <0%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0856c1c...b3e54c0. Read the comment docs.

@faustbrian faustbrian merged commit ba9c990 into ArkEcosystem:develop Nov 5, 2018
@ghost ghost removed the review label Nov 5, 2018
@faustbrian
Copy link
Contributor

I resolved the test issues again this time. Next time run the tests locally before you send a PR and make sure they pass.

@zillionn
Copy link
Contributor Author

zillionn commented Nov 5, 2018

@faustbrian Sorry, I just saw the bug but it was 2:20 AM here...
@boldninja Don't count my solution for the bounty.

@zillionn zillionn deleted the patch-3 branch November 12, 2018 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants