From 4ecab0d80c6d2ddb909c0d6bd32e3e680b562705 Mon Sep 17 00:00:00 2001 From: Alexis Enston Date: Thu, 12 Jan 2017 23:39:24 +0000 Subject: [PATCH 1/3] Consider empty block when filling with TXs --- src/cryptonote_core/tx_pool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 6ad139023..c79d9bcf7 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -63,7 +63,7 @@ namespace cryptonote size_t const TRANSACTION_SIZE_LIMIT_V2 = (((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 * 125) / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE); time_t const MIN_RELAY_TIME = (60 * 5); // only start re-relaying transactions after that many seconds time_t const MAX_RELAY_TIME = (60 * 60 * 4); // at most that many seconds between resends - float const ACCEPT_THRESHOLD = 0.99f; + float const ACCEPT_THRESHOLD = 1.0f; // a kind of increasing backoff within min/max bounds time_t get_relay_delay(time_t now, time_t received) @@ -613,6 +613,10 @@ namespace cryptonote uint64_t best_coinbase = 0; total_size = 0; fee = 0; + + //baseline empty block + get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version); + size_t max_total_size = 2 * median_size - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; std::unordered_set k_images; From 5f7a8741b972b6176584a1718d7330dd844a120e Mon Sep 17 00:00:00 2001 From: Alexis Enston Date: Mon, 16 Jan 2017 12:18:43 +0000 Subject: [PATCH 2/3] Blockfill - Take TX fees into account properly --- src/cryptonote_core/tx_pool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index c79d9bcf7..77b3e70d2 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -645,7 +645,7 @@ namespace cryptonote sorted_it++; continue; } - uint64_t coinbase = block_reward + fee; + uint64_t coinbase = block_reward + fee + tx_it->second.fee; if (coinbase < template_accept_threshold(best_coinbase)) { LOG_PRINT_L2(" would decrease coinbase to " << print_money(coinbase)); From 58e825060e02b2ccad2b15342382e323b64daabe Mon Sep 17 00:00:00 2001 From: Alexis Enston Date: Wed, 18 Jan 2017 16:30:19 +0000 Subject: [PATCH 3/3] Blockfill - Sort tx pool correctly --- src/cryptonote_core/tx_pool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 77b3e70d2..f0d5d71bf 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -253,7 +253,7 @@ namespace cryptonote tvc.m_verifivation_failed = false; - m_txs_by_fee_and_receive_time.emplace(std::pair((double)blob_size / fee, receive_time), id); + m_txs_by_fee_and_receive_time.emplace(std::pair(fee / (double)blob_size, receive_time), id); return true; } @@ -732,7 +732,7 @@ namespace cryptonote // no need to store queue of sorted transactions, as it's easy to generate. for (const auto& tx : m_transactions) { - m_txs_by_fee_and_receive_time.emplace(std::pair((double)tx.second.blob_size / tx.second.fee, tx.second.receive_time), tx.first); + m_txs_by_fee_and_receive_time.emplace(std::pair(tx.second.fee / (double)tx.second.blob_size, tx.second.receive_time), tx.first); } // Ignore deserialization error