mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 00:37:43 +00:00
core: quantize per kB fee to 8 decimals
This commit is contained in:
parent
3e761c137d
commit
3153349325
2 changed files with 20 additions and 1 deletions
|
@ -128,6 +128,7 @@
|
|||
#define THREAD_STACK_SIZE 5 * 1024 * 1024
|
||||
|
||||
#define HF_VERSION_DYNAMIC_FEE 4
|
||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||
|
||||
// New constants are intended to go here
|
||||
namespace config
|
||||
|
|
|
@ -2795,6 +2795,19 @@ void Blockchain::check_ring_signature(const crypto::hash &tx_prefix_hash, const
|
|||
result = crypto::check_ring_signature(tx_prefix_hash, key_image, p_output_keys, sig.data()) ? 1 : 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
static uint64_t get_fee_quantization_mask()
|
||||
{
|
||||
static uint64_t mask = 0;
|
||||
if (mask == 0)
|
||||
{
|
||||
mask = 1;
|
||||
for (size_t n = PER_KB_FEE_QUANTIZATION_DECIMALS; n < CRYPTONOTE_DISPLAY_DECIMAL_POINT; ++n)
|
||||
mask *= 10;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
uint64_t Blockchain::get_dynamic_per_kb_fee(uint64_t block_reward, size_t median_block_size)
|
||||
{
|
||||
|
@ -2810,7 +2823,12 @@ uint64_t Blockchain::get_dynamic_per_kb_fee(uint64_t block_reward, size_t median
|
|||
div128_32(hi, lo, 1000000, &hi, &lo);
|
||||
assert(hi == 0);
|
||||
|
||||
return lo;
|
||||
// quantize fee up to 8 decimals
|
||||
uint64_t mask = get_fee_quantization_mask();
|
||||
uint64_t qlo = (lo + mask - 1) / mask * mask;
|
||||
MDEBUG("lo " << print_money(lo) << ", qlo " << print_money(qlo) << ", mask " << mask);
|
||||
|
||||
return qlo;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue