aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-27 00:09:25 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-03-22 16:03:31 +0000
commit054b4c7f412013e33c80efa8e0f0f33944572a11 (patch)
treee0285a3b2b57187b15c6bc77680bf3d7a44fb446 /src/cryptonote_core/tx_pool.cpp
parentMerge pull request #6388 (diff)
downloadmonero-054b4c7f412013e33c80efa8e0f0f33944572a11.tar.xz
protocol: request txpool contents when synced
A newly synced Alice sends a (typically quite small) list of txids in the local tpxool to a random peer Bob, who then uses the existing tx relay system to send Alice any tx in his txpool which is not in the list Alice sent
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r--src/cryptonote_core/tx_pool.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 1bc475879..8c8e43c90 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -594,6 +594,39 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------------------------
+ bool tx_memory_pool::get_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) const
+ {
+ CRITICAL_REGION_LOCAL(m_transactions_lock);
+ CRITICAL_REGION_LOCAL1(m_blockchain);
+
+ m_blockchain.for_all_txpool_txes([this, &hashes, &txes](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata*) {
+ const auto relay_method = meta.get_relay_method();
+ if (relay_method != relay_method::block && relay_method != relay_method::fluff)
+ return true;
+ const auto i = std::find(hashes.begin(), hashes.end(), txid);
+ if (i == hashes.end())
+ {
+ cryptonote::blobdata bd;
+ try
+ {
+ if (!m_blockchain.get_txpool_tx_blob(txid, bd, cryptonote::relay_category::broadcasted))
+ {
+ MERROR("Failed to get blob for txpool transaction " << txid);
+ return true;
+ }
+ txes.emplace_back(std::move(bd));
+ }
+ catch (const std::exception &e)
+ {
+ MERROR("Failed to get blob for txpool transaction " << txid << ": " << e.what());
+ return true;
+ }
+ }
+ return true;
+ }, false);
+ return true;
+ }
+ //---------------------------------------------------------------------------------
void tx_memory_pool::on_idle()
{
m_remove_stuck_tx_interval.do_call([this](){return remove_stuck_transactions();});