From 88c9d90ac44522b9ac152be4af9595558da8ba7e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 11 Oct 2019 10:37:39 +0000 Subject: protocol: initialize block_weight in block_complete_entry ctor CID 204479 --- src/cryptonote_protocol/cryptonote_protocol_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_protocol/cryptonote_protocol_defs.h b/src/cryptonote_protocol/cryptonote_protocol_defs.h index 3d594bf83..dcd108626 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_defs.h +++ b/src/cryptonote_protocol/cryptonote_protocol_defs.h @@ -160,7 +160,7 @@ namespace cryptonote } END_KV_SERIALIZE_MAP() - block_complete_entry(): pruned(false) {} + block_complete_entry(): pruned(false), block_weight(0) {} }; -- cgit v1.2.3 From fe443bbdec3ad6cdb7409f61a1e64eda6b32016b Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 11 Oct 2019 10:42:57 +0000 Subject: cryptonote: don't leave block_weight uninitialized CID 204467 --- src/cryptonote_core/cryptonote_core.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index b831cc9ff..eed5317e1 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1367,6 +1367,7 @@ namespace cryptonote { block_complete_entry bce; bce.block = cryptonote::block_to_blob(b); + bce.block_weight = 0; // we can leave it to 0, those txes aren't pruned for (const auto &tx_hash: b.tx_hashes) { cryptonote::blobdata txblob; -- cgit v1.2.3 From 1ba9bafd3331f6534242e682bafbd6d863be42ed Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 11 Oct 2019 10:46:24 +0000 Subject: tx_pool: do not divide by 0 In case of a 0 tx weight, we use a placeholder value to insert in the fee-per-byte set. This is used for pruning and mining, and those txes are pruned, so will not be too large, nor added to the block template if mining, so this is safe. CID 204465 --- 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 0b7e5c199..78c7863cd 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -259,7 +259,7 @@ namespace cryptonote m_blockchain.add_txpool_tx(id, blob, meta); if (!insert_key_images(tx, id, kept_by_block)) return false; - m_txs_by_fee_and_receive_time.emplace(std::pair(fee / (double)tx_weight, receive_time), id); + m_txs_by_fee_and_receive_time.emplace(std::pair(fee / (double)(tx_weight ? tx_weight : 1), receive_time), id); lock.commit(); } catch (const std::exception &e) @@ -305,7 +305,7 @@ namespace cryptonote m_blockchain.add_txpool_tx(id, blob, meta); if (!insert_key_images(tx, id, kept_by_block)) return false; - m_txs_by_fee_and_receive_time.emplace(std::pair(fee / (double)tx_weight, receive_time), id); + m_txs_by_fee_and_receive_time.emplace(std::pair(fee / (double)(tx_weight ? tx_weight : 1), receive_time), id); lock.commit(); } catch (const std::exception &e) -- cgit v1.2.3