[amount] Extend GetFee() by optional flag ceil #7660

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1603-amountCeil changing 4 files +69 −11
  1. MarcoFalke commented at 3:23 pm on March 9, 2016: member
    • This flag causes rounding up to the next satoshi instead of just truncating (default behavior)
    • This reverts the hard-to-read and buggy code introduced in d88af560111863c3e9c1ae855dcc287f04dffb02 (#4465)

    master happily produces the following results:

    0    feeRate = CFeeRate(123);
    1    BOOST_CHECK_EQUAL(feeRate.GetFee(0), 123);   // TODO: Should be 0
    2    BOOST_CHECK_EQUAL(feeRate.GetFee(8), 123);   // TODO: Should be 1
    3    BOOST_CHECK_EQUAL(feeRate.GetFee(9), 1);     // TODO: Should be 2
    4    BOOST_CHECK_EQUAL(feeRate.GetFee(121), 14);  // TODO: Should be 15
    5    BOOST_CHECK_EQUAL(feeRate.GetFee(122), 15);  // TODO: Should be 16
    6    BOOST_CHECK_EQUAL(feeRate.GetFee(999), 122); // TODO: Should be 123
    
  2. [amount] Extend GetFee() by optional flag ceil
    * This flag causes rounding up to the next satoshi instead of just
      truncating (default behavior)
    
    * This reverts the hard-to-read and buggy code introduced in
      d88af560111863c3e9c1ae855dcc287f04dffb02
    faccb1818c
  3. jonasschnelli added the label Refactoring on Mar 9, 2016
  4. MarcoFalke commented at 5:49 pm on March 9, 2016: member
    @morcos suggested an alternative would be to use std::ceil in all cases. This also changes the dust value by a small amount (fa03771), so I am not sure if this really is preferred?
  5. jtimon commented at 4:47 pm on March 16, 2016: contributor

    I don’t know what is the expected usage, but wouldn’t it be simpler to just add a CFeeRate::GetFeeSatoshis(size) method ? Maybe that would be too disruptive for the indended use, I don’t really know.

    EDIT: Although it may look unrelated, maybe this would also a good opportunity to move CFeeRate, CTxOut::GetDustThreshold() and CTxOut::IsDust() finally out of libconsensus. Something like https://github.com/jtimon/bitcoin/commit/dc1b96d368d471ea5242ca021148f9f900f69661 or #5114 but maybe not based on #6068, since #6068 seems extremely hard for reasons I still don’t understand. I guess I just leave it there in case someone wants to rebase or rewrite such a thing. Sorry, I cannot help remembering every time I review changes in amount.o.

  6. MarcoFalke commented at 8:05 pm on March 16, 2016: member
    Closing this per IRC discussion.
  7. MarcoFalke closed this on Mar 16, 2016

  8. MarcoFalke deleted the branch on Mar 16, 2016
  9. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-24 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me