mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-29 18:53:14 +00:00
core: notify the txpool when transactions are relayed
This commit is contained in:
parent
f3c374fe08
commit
1e163666f3
5 changed files with 24 additions and 0 deletions
|
@ -709,6 +709,20 @@ namespace cryptonote
|
||||||
return true;
|
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)
|
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);
|
return m_blockchain_storage.create_block_template(b, adr, diffic, height, ex_nonce);
|
||||||
|
|
|
@ -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);
|
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
|
* @brief gets the miner instance
|
||||||
|
|
|
@ -780,6 +780,9 @@ namespace cryptonote
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
bool t_cryptonote_protocol_handler<t_core>::relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context)
|
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);
|
return relay_post_notify<NOTIFY_NEW_TRANSACTIONS>(arg, exclude_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,5 +88,6 @@ namespace tests
|
||||||
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
|
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
|
||||||
uint64_t get_target_blockchain_height() const { return 1; }
|
uint64_t get_target_blockchain_height() const { return 1; }
|
||||||
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
|
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
|
||||||
|
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
|
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
|
||||||
uint64_t get_target_blockchain_height() const { return 1; }
|
uint64_t get_target_blockchain_height() const { return 1; }
|
||||||
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
|
size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
|
||||||
|
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<test_core>> Server;
|
typedef nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<test_core>> Server;
|
||||||
|
|
Loading…
Reference in a new issue