aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-08-27 18:15:13 +0200
committerRiccardo Spagni <ric@spagni.net>2017-08-27 18:15:13 +0200
commit72b5f37f58754c05627f89fc9e6c1f44d4a3b3ce (patch)
tree9c097b08047e8508dca175344687810d084f93cb /src/cryptonote_core
parentMerge pull request #2347 (diff)
parenttxpool: update db tx metadata when it changes (diff)
downloadmonero-72b5f37f58754c05627f89fc9e6c1f44d4a3b3ce.tar.xz
Merge pull request #2349
1914c999 txpool: update db tx metadata when it changes (moneromooo) 4dbf29bd txpool: add tx size median to the pool stats (moneromooo)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/tx_pool.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 7b98acb63..265a4ca3e 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -571,7 +571,10 @@ namespace cryptonote
const uint64_t now = time(NULL);
std::map<uint64_t, txpool_histo> agebytes;
stats.txs_total = m_blockchain.get_txpool_tx_count();
- m_blockchain.for_all_txpool_txes([&stats, now, &agebytes](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){
+ std::vector<uint32_t> sizes;
+ sizes.reserve(stats.txs_total);
+ m_blockchain.for_all_txpool_txes([&stats, &sizes, now, &agebytes](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){
+ sizes.push_back(meta.blob_size);
stats.bytes_total += meta.blob_size;
if (!stats.bytes_min || meta.blob_size < stats.bytes_min)
stats.bytes_min = meta.blob_size;
@@ -591,6 +594,7 @@ namespace cryptonote
agebytes[age].bytes += meta.blob_size;
return true;
});
+ stats.bytes_med = epee::misc_utils::median(sizes);
if (stats.txs_total > 1)
{
/* looking for 98th percentile */
@@ -916,7 +920,21 @@ namespace cryptonote
// Skip transactions that are not ready to be
// included into the blockchain or that are
// missing key images
- if (!is_transaction_ready_to_go(meta, tx))
+ const cryptonote::txpool_tx_meta_t original_meta = meta;
+ bool ready = is_transaction_ready_to_go(meta, tx);
+ if (memcmp(&original_meta, &meta, sizeof(meta)))
+ {
+ try
+ {
+ m_blockchain.update_txpool_tx(sorted_it->second, meta);
+ }
+ catch (const std::exception &e)
+ {
+ MERROR("Failed to update tx meta: " << e.what());
+ // continue, not fatal
+ }
+ }
+ if (!ready)
{
LOG_PRINT_L2(" not ready to go");
sorted_it++;