mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
Cleaner access to transaction pool info
This commit is contained in:
parent
9ddccbde63
commit
af3113560a
@ -502,9 +502,9 @@ namespace cryptonote
|
|||||||
return m_mempool.print_pool(short_format);
|
return m_mempool.print_pool(short_format);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
void core::each_transaction(std::function<void (crypto::hash const &, tx_memory_pool::tx_details const &)> callback)
|
std::vector<tx_info> core::transaction_pool_info()
|
||||||
{
|
{
|
||||||
m_mempool.each_transaction(callback);
|
return m_mempool.pool_info();
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::update_miner_block_template()
|
bool core::update_miner_block_template()
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "cryptonote_core/cryptonote_stat_info.h"
|
#include "cryptonote_core/cryptonote_stat_info.h"
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
|
#include "rpc/tx_info.h"
|
||||||
|
|
||||||
PUSH_WARNINGS
|
PUSH_WARNINGS
|
||||||
DISABLE_VS_WARNINGS(4355)
|
DISABLE_VS_WARNINGS(4355)
|
||||||
@ -88,7 +89,7 @@ namespace cryptonote
|
|||||||
void print_blockchain(uint64_t start_index, uint64_t end_index);
|
void print_blockchain(uint64_t start_index, uint64_t end_index);
|
||||||
void print_blockchain_index();
|
void print_blockchain_index();
|
||||||
std::string print_pool(bool short_format);
|
std::string print_pool(bool short_format);
|
||||||
void each_transaction(std::function<void (crypto::hash const &, tx_memory_pool::tx_details const &)> callback);
|
std::vector<tx_info> transaction_pool_info();
|
||||||
|
|
||||||
void print_blockchain_outs(const std::string& file);
|
void print_blockchain_outs(const std::string& file);
|
||||||
void on_synchronized();
|
void on_synchronized();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "misc_language.h"
|
#include "misc_language.h"
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
|
#include "string_tools.h"
|
||||||
|
|
||||||
DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated name length exceeded, name was truncated
|
DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated name length exceeded, name was truncated
|
||||||
|
|
||||||
@ -374,15 +375,29 @@ namespace cryptonote
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
void tx_memory_pool::each_transaction(std::function<void (crypto::hash const &, tx_details const &)> callback)
|
std::vector<tx_info> tx_memory_pool::pool_info()
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
||||||
|
|
||||||
|
std::vector<tx_info> result;
|
||||||
BOOST_FOREACH(transactions_container::value_type& txe, m_transactions)
|
BOOST_FOREACH(transactions_container::value_type& txe, m_transactions)
|
||||||
{
|
{
|
||||||
auto & id = txe.first;
|
auto & id = txe.first;
|
||||||
auto & details = txe.second;
|
auto & details = txe.second;
|
||||||
callback(id, details);
|
result.emplace_back(
|
||||||
|
epee::string_tools::pod_to_hex(id)
|
||||||
|
, obj_to_json_str(details.tx)
|
||||||
|
, details.blob_size
|
||||||
|
, details.fee
|
||||||
|
, epee::string_tools::pod_to_hex(details.max_used_block_id)
|
||||||
|
, details.max_used_block_height
|
||||||
|
, details.kept_by_block
|
||||||
|
, details.last_failed_height
|
||||||
|
, epee::string_tools::pod_to_hex(details.last_failed_id)
|
||||||
|
, details.receive_time
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee)
|
bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "cryptonote_basic_impl.h"
|
#include "cryptonote_basic_impl.h"
|
||||||
#include "verification_context.h"
|
#include "verification_context.h"
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
|
#include "rpc/tx_info.h"
|
||||||
|
|
||||||
|
|
||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
@ -73,7 +74,7 @@ namespace cryptonote
|
|||||||
bool have_key_images(const std::unordered_set<crypto::key_image>& kic, const transaction& tx);
|
bool have_key_images(const std::unordered_set<crypto::key_image>& kic, const transaction& tx);
|
||||||
bool append_key_images(std::unordered_set<crypto::key_image>& kic, const transaction& tx);
|
bool append_key_images(std::unordered_set<crypto::key_image>& kic, const transaction& tx);
|
||||||
std::string print_pool(bool short_format);
|
std::string print_pool(bool short_format);
|
||||||
void each_transaction(std::function<void (crypto::hash const &, tx_details const &)> callback);
|
std::vector<tx_info> pool_info();
|
||||||
|
|
||||||
/*bool flush_pool(const std::strig& folder);
|
/*bool flush_pool(const std::strig& folder);
|
||||||
bool inflate_pool(const std::strig& folder);*/
|
bool inflate_pool(const std::strig& folder);*/
|
||||||
|
@ -365,20 +365,7 @@ namespace cryptonote
|
|||||||
bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res, connection_context& cntx)
|
bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res, connection_context& cntx)
|
||||||
{
|
{
|
||||||
CHECK_CORE_BUSY();
|
CHECK_CORE_BUSY();
|
||||||
m_core.each_transaction([&res](crypto::hash const & id, tx_memory_pool::tx_details const & details) {
|
res.transactions = m_core.transaction_pool_info();
|
||||||
res.transactions.emplace_back(
|
|
||||||
string_tools::pod_to_hex(id)
|
|
||||||
, obj_to_json_str(const_cast<transaction &>(details.tx)) // The serialization macros do not handle const correctness
|
|
||||||
, details.blob_size
|
|
||||||
, details.fee
|
|
||||||
, string_tools::pod_to_hex(details.max_used_block_id)
|
|
||||||
, details.max_used_block_height
|
|
||||||
, details.kept_by_block
|
|
||||||
, details.last_failed_height
|
|
||||||
, string_tools::pod_to_hex(details.last_failed_id)
|
|
||||||
, details.receive_time
|
|
||||||
);
|
|
||||||
});
|
|
||||||
res.status = CORE_RPC_STATUS_OK;
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user