Merge pull request #5981

88c9d90 protocol: initialize block_weight in block_complete_entry ctor (moneromooo-monero)
fe443bb cryptonote: don't leave block_weight uninitialized (moneromooo-monero)
1ba9baf tx_pool: do not divide by 0 (moneromooo-monero)
This commit is contained in:
luigi1111 2019-10-22 10:18:28 -05:00
commit 426d2ac8ee
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
3 changed files with 4 additions and 3 deletions

View File

@ -1367,6 +1367,7 @@ namespace cryptonote
{ {
block_complete_entry bce; block_complete_entry bce;
bce.block = cryptonote::block_to_blob(b); 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) for (const auto &tx_hash: b.tx_hashes)
{ {
cryptonote::blobdata txblob; cryptonote::blobdata txblob;

View File

@ -259,7 +259,7 @@ namespace cryptonote
m_blockchain.add_txpool_tx(id, blob, meta); m_blockchain.add_txpool_tx(id, blob, meta);
if (!insert_key_images(tx, id, kept_by_block)) if (!insert_key_images(tx, id, kept_by_block))
return false; 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(); lock.commit();
} }
catch (const std::exception &e) catch (const std::exception &e)
@ -305,7 +305,7 @@ namespace cryptonote
m_blockchain.add_txpool_tx(id, blob, meta); m_blockchain.add_txpool_tx(id, blob, meta);
if (!insert_key_images(tx, id, kept_by_block)) if (!insert_key_images(tx, id, kept_by_block))
return false; 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(); lock.commit();
} }
catch (const std::exception &e) catch (const std::exception &e)

View File

@ -160,7 +160,7 @@ namespace cryptonote
} }
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
block_complete_entry(): pruned(false) {} block_complete_entry(): pruned(false), block_weight(0) {}
}; };