core: dynamic fee algorithm from ArticMine

The fee will vary based on the base reward and the current
block size limit:

fee = (R/R0) * (M0/M) * F0

R: base reward
R0: reference base reward (10 monero)
M: block size limit
M0: minimum block size limit (60000)
F0: 0.002 monero

Starts applying at v4
This commit is contained in:
moneromooo-monero
2016-10-27 23:43:44 +01:00
parent 83b0511731
commit 82dbba10d4
6 changed files with 206 additions and 5 deletions
+27
View File
@@ -512,6 +512,33 @@ namespace cryptonote
*/
bool check_tx_inputs(transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id, tx_verification_context &tvc, bool kept_by_block = false);
/**
* @brief get dynamic per kB fee for a given block size
*
* The dynamic fee is based on the block size in a past window, and
* the current block reward. It is expressed by kB.
*
* @param block_reward the current block reward
* @param median_block_size the median blob's size in the past window
*
* @return the per kB fee
*/
static uint64_t get_dynamic_per_kb_fee(uint64_t block_reward, size_t median_block_size);
/**
* @brief validate a transaction's fee
*
* This function validates the fee is enough for the transaction.
* This is based on the size of the transaction blob, and, after a
* height threshold, on the average size of transaction in a past window
*
* @param blob_size the transaction blob's size
* @param fee the fee
*
* @return true if the fee is enough, false otherwise
*/
bool check_fee(size_t blob_size, uint64_t fee) const;
/**
* @brief check that a transaction's outputs conform to current standards
*