diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-10-22 20:46:51 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-10-23 00:32:49 +0100 |
commit | 1e163666f3c5265d9d091eece0403de6bc5eca96 (patch) | |
tree | 8a7abe757ab6c2116d524e08d4a6a7f71d64e4f4 /src | |
parent | tx_pool: set relayed flag on relay (diff) | |
download | monero-1e163666f3c5265d9d091eece0403de6bc5eca96.tar.xz |
core: notify the txpool when transactions are relayed
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 14 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 5 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 3 |
3 files changed, 22 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_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 1d1cd3631..5232d550a 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -780,6 +780,9 @@ namespace cryptonote template<class t_core> bool t_cryptonote_protocol_handler<t_core>::relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context) { + // no check for success, so tell core they're relayed unconditionally + for(auto tx_blob_it = arg.txs.begin(); tx_blob_it!=arg.txs.end(); ++tx_blob_it) + m_core.on_transaction_relayed(*tx_blob_it); return relay_post_notify<NOTIFY_NEW_TRANSACTIONS>(arg, exclude_context); } |