aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-03-23 11:46:57 +0200
committerRiccardo Spagni <ric@spagni.net>2017-03-23 11:46:57 +0200
commita73a886cb16c42a57d10c93e50eb4f84d965c124 (patch)
tree0df8bbd20301d53613b07493940417c70ccf7c4e /src/cryptonote_core/tx_pool.cpp
parentMerge pull request #1910 (diff)
parenttx_pool: ensure txes loaded from poolstate.bin have their txid cached (diff)
downloadmonero-a73a886cb16c42a57d10c93e50eb4f84d965c124.tar.xz
Merge pull request #1911
91d41090 tx_pool: ensure txes loaded from poolstate.bin have their txid cached (moneromooo-monero) aaeb164c tx_pool: remove transactions if they're in the blockchain (moneromooo-monero) 558cfc31 core, wallet: faster tx pool scanning (moneromooo-monero) f065234b core: cache tx and block hashes in the respective classes (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r--src/cryptonote_core/tx_pool.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 810d76c48..da5e6636a 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -423,6 +423,13 @@ namespace cryptonote
txs.push_back(tx_vt.second.tx);
}
//------------------------------------------------------------------
+ void tx_memory_pool::get_transaction_hashes(std::vector<crypto::hash>& txs) const
+ {
+ CRITICAL_REGION_LOCAL(m_transactions_lock);
+ for(const auto& tx_vt: m_transactions)
+ txs.push_back(get_transaction_hash(tx_vt.second.tx));
+ }
+ //------------------------------------------------------------------
//TODO: investigate whether boolean return is appropriate
bool tx_memory_pool::get_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const
{
@@ -710,13 +717,22 @@ namespace cryptonote
size_t n_removed = 0;
size_t tx_size_limit = get_transaction_size_limit(version);
for (auto it = m_transactions.begin(); it != m_transactions.end(); ) {
+ bool remove = false;
+ const crypto::hash &txid = get_transaction_hash(it->second.tx);
if (it->second.blob_size >= tx_size_limit) {
- LOG_PRINT_L1("Transaction " << get_transaction_hash(it->second.tx) << " is too big (" << it->second.blob_size << " bytes), removing it from pool");
+ LOG_PRINT_L1("Transaction " << txid << " is too big (" << it->second.blob_size << " bytes), removing it from pool");
+ remove = true;
+ }
+ else if (m_blockchain.have_tx(txid)) {
+ LOG_PRINT_L1("Transaction " << txid << " is in the blockchain, removing it from pool");
+ remove = true;
+ }
+ if (remove) {
remove_transaction_keyimages(it->second.tx);
- auto sorted_it = find_tx_in_sorted_container(it->first);
+ auto sorted_it = find_tx_in_sorted_container(txid);
if (sorted_it == m_txs_by_fee_and_receive_time.end())
{
- LOG_PRINT_L1("Removing tx " << it->first << " from tx pool, but it was not found in the sorted txs container!");
+ LOG_PRINT_L1("Removing tx " << txid << " from tx pool, but it was not found in the sorted txs container!");
}
else
{