diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-10-11 10:46:24 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-10-11 14:09:31 +0000 |
commit | 1ba9bafd3331f6534242e682bafbd6d863be42ed (patch) | |
tree | f043f9e564ce86d187575a6df647b8f47a3299c0 /src | |
parent | cryptonote: don't leave block_weight uninitialized (diff) | |
download | monero-1ba9bafd3331f6534242e682bafbd6d863be42ed.tar.xz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 4 |
1 files 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<double, std::time_t>(fee / (double)tx_weight, receive_time), id); + m_txs_by_fee_and_receive_time.emplace(std::pair<double, std::time_t>(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<double, std::time_t>(fee / (double)tx_weight, receive_time), id); + m_txs_by_fee_and_receive_time.emplace(std::pair<double, std::time_t>(fee / (double)(tx_weight ? tx_weight : 1), receive_time), id); lock.commit(); } catch (const std::exception &e) |