aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-10-23 19:16:30 +0200
committerRiccardo Spagni <ric@spagni.net>2016-10-23 19:16:30 +0200
commit854abeb3bbdb1b9399309297a533be09442faa40 (patch)
treeb4814fa9f74ca734dccb598a6fffbfb8b3a5098c /src/cryptonote_core
parent4e98d2958c9950a1ae9054f20bf466563af5cd03 (diff)
parent10a79eae240753e4e63b9b5ac1b55bbc06da45d3 (diff)
downloadmonzero-core-854abeb3bbdb1b9399309297a533be09442faa40.tar.gz
monzero-core-854abeb3bbdb1b9399309297a533be09442faa40.tar.xz
monzero-core-854abeb3bbdb1b9399309297a533be09442faa40.zip
Merge pull request #1247
10a79ea daemon: report transaction relay status in print_pool* commands (moneromooo-monero) 1e16366 core: notify the txpool when transactions are relayed (moneromooo-monero) f3c374f tx_pool: set relayed flag on relay (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp14
-rw-r--r--src/cryptonote_core/cryptonote_core.h5
-rw-r--r--src/cryptonote_core/tx_pool.cpp5
3 files changed, 24 insertions, 0 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index a82d96416..95c49f627 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -709,6 +709,20 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
+ void core::on_transaction_relayed(const cryptonote::blobdata& tx_blob)
+ {
+ std::list<std::pair<crypto::hash, cryptonote::transaction>> txs;
+ cryptonote::transaction tx;
+ crypto::hash tx_hash, tx_prefix_hash;
+ if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash, tx_prefix_hash))
+ {
+ LOG_ERROR("Failed to parse relayed tranasction");
+ return;
+ }
+ txs.push_back(std::make_pair(tx_hash, std::move(tx)));
+ m_mempool.set_relayed(txs);
+ }
+ //-----------------------------------------------------------------------------------------------
bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce)
{
return m_blockchain_storage.create_block_template(b, adr, diffic, height, ex_nonce);
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index d925a184d..a5a97a5ad 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -180,6 +180,11 @@ namespace cryptonote
*/
virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce);
+ /**
+ * @brief called when a transaction is relayed
+ */
+ virtual void on_transaction_relayed(const cryptonote::blobdata& tx);
+
/**
* @brief gets the miner instance
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 178cbda3c..dba05a539 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -387,7 +387,10 @@ namespace cryptonote
{
auto i = m_transactions.find(it->first);
if (i != m_transactions.end())
+ {
+ i->second.relayed = true;
i->second.last_relayed_time = now;
+ }
}
}
//---------------------------------------------------------------------------------
@@ -422,6 +425,8 @@ namespace cryptonote
txi.last_failed_height = txd.last_failed_height;
txi.last_failed_id_hash = epee::string_tools::pod_to_hex(txd.last_failed_id);
txi.receive_time = txd.receive_time;
+ txi.relayed = txd.relayed;
+ txi.last_relayed_time = txd.last_relayed_time;
tx_infos.push_back(txi);
}