aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-11-21 13:04:56 +0200
committerRiccardo Spagni <ric@spagni.net>2015-11-21 13:05:01 +0200
commit830904ca4efeb49c87af246a975bc307e2d5f777 (patch)
tree70c92777fc82a486b459d89dac53bdfd4bbbc377 /src/cryptonote_core/cryptonote_core.cpp
parent0d09e15a1c0cc02255bf0c091efd3b28bbeb0a9f (diff)
parent932994c0cb25d21ccc5795c23b0e342427260625 (diff)
downloadmonzero-core-830904ca4efeb49c87af246a975bc307e2d5f777.tar.gz
monzero-core-830904ca4efeb49c87af246a975bc307e2d5f777.tar.xz
monzero-core-830904ca4efeb49c87af246a975bc307e2d5f777.zip
Merge pull request #492
932994c Relay transactions when they linger too long in the pool (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 4ade50cde..9881ae34f 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -401,7 +401,7 @@ namespace cryptonote
return false;
}
//-----------------------------------------------------------------------------------------------
- bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block)
+ bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block, bool relayed)
{
tvc = boost::value_initialized<tx_verification_context>();
//want to process all transactions sequentially
@@ -440,7 +440,7 @@ namespace cryptonote
return false;
}
- bool r = add_new_tx(tx, tx_hash, tx_prefixt_hash, tx_blob.size(), tvc, keeped_by_block);
+ bool r = add_new_tx(tx, tx_hash, tx_prefixt_hash, tx_blob.size(), tvc, keeped_by_block, relayed);
if(tvc.m_verifivation_failed)
{LOG_PRINT_RED_L1("Transaction verification failed: " << tx_hash);}
else if(tvc.m_verifivation_impossible)
@@ -542,13 +542,13 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
- bool core::add_new_tx(const transaction& tx, tx_verification_context& tvc, bool keeped_by_block)
+ bool core::add_new_tx(const transaction& tx, tx_verification_context& tvc, bool keeped_by_block, bool relayed)
{
crypto::hash tx_hash = get_transaction_hash(tx);
crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
blobdata bl;
t_serializable_object_to_blob(tx, bl);
- return add_new_tx(tx, tx_hash, tx_prefix_hash, bl.size(), tvc, keeped_by_block);
+ return add_new_tx(tx, tx_hash, tx_prefix_hash, bl.size(), tvc, keeped_by_block, relayed);
}
//-----------------------------------------------------------------------------------------------
size_t core::get_blockchain_total_transactions() const
@@ -561,7 +561,7 @@ namespace cryptonote
// return m_blockchain_storage.get_outs(amount, pkeys);
//}
//-----------------------------------------------------------------------------------------------
- bool core::add_new_tx(const transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block)
+ bool core::add_new_tx(const transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block, bool relayed)
{
if(m_mempool.have_tx(tx_hash))
{
@@ -575,7 +575,28 @@ namespace cryptonote
return true;
}
- return m_mempool.add_tx(tx, tx_hash, blob_size, tvc, keeped_by_block);
+ return m_mempool.add_tx(tx, tx_hash, blob_size, tvc, keeped_by_block, relayed);
+ }
+ //-----------------------------------------------------------------------------------------------
+ bool core::relay_txpool_transactions()
+ {
+ // we attempt to relay txes that should be relayed, but were not
+ std::list<std::pair<crypto::hash, cryptonote::transaction>> txs;
+ if (m_mempool.get_relayable_transactions(txs))
+ {
+ cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
+ tx_verification_context tvc = AUTO_VAL_INIT(tvc);
+ NOTIFY_NEW_TRANSACTIONS::request r;
+ blobdata bl;
+ for (auto it = txs.begin(); it != txs.end(); ++it)
+ {
+ t_serializable_object_to_blob(it->second, bl);
+ r.txs.push_back(bl);
+ }
+ get_protocol()->relay_transactions(r, fake_context);
+ m_mempool.set_relayed(txs);
+ }
+ return true;
}
//-----------------------------------------------------------------------------------------------
bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce)
@@ -831,6 +852,7 @@ namespace cryptonote
m_store_blockchain_interval.do_call(boost::bind(&blockchain_storage::store_blockchain, &m_blockchain_storage));
#endif
m_fork_moaner.do_call(boost::bind(&core::check_fork_time, this));
+ m_txpool_auto_relayer.do_call(boost::bind(&core::relay_txpool_transactions, this));
m_miner.on_idle();
m_mempool.on_idle();
return true;