aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorwarptangent <warptangent@inbox.com>2015-04-23 05:13:07 -0700
committerwarptangent <warptangent@inbox.com>2015-04-23 07:04:36 -0700
commitb76857f9d9a8bf45b854e9c3da56b550ade1a7c6 (patch)
treeaead9c8412218045e3de48fe4b98a2bcc0393b67 /src/cryptonote_core
parentupdate lmdb64 (diff)
downloadmonero-b76857f9d9a8bf45b854e9c3da56b550ade1a7c6.tar.xz
Add mempool output to daemon via command and RPC
This is for the "print_pool" command and "get_transaction_pool" RPC method. Add mempool's spent key images to the results.
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp5
-rw-r--r--src/cryptonote_core/cryptonote_core.h1
-rw-r--r--src/cryptonote_core/tx_pool.cpp34
-rw-r--r--src/cryptonote_core/tx_pool.h2
4 files changed, 42 insertions, 0 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index f6eaff2b1..438753e50 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -654,6 +654,11 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
+ bool core::get_pool_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const
+ {
+ return m_mempool.get_transactions_and_spent_keys_info(tx_infos, key_image_infos);
+ }
+ //-----------------------------------------------------------------------------------------------
bool core::get_short_chain_history(std::list<crypto::hash>& ids)
{
return m_blockchain_storage.get_short_chain_history(ids);
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 973f01272..6fb211a32 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -108,6 +108,7 @@ namespace cryptonote
void set_enforce_dns_checkpoints(bool enforce_dns);
bool get_pool_transactions(std::list<transaction>& txs);
+ bool get_pool_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const;
size_t get_pool_transactions_count();
size_t get_blockchain_total_transactions();
//bool get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys);
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 03ced2c2e..7c8a61999 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -276,6 +276,40 @@ namespace cryptonote
BOOST_FOREACH(const auto& tx_vt, m_transactions)
txs.push_back(tx_vt.second.tx);
}
+ //------------------------------------------------------------------
+ bool tx_memory_pool::get_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const
+ {
+ CRITICAL_REGION_LOCAL(m_transactions_lock);
+ for (const auto& tx_vt : m_transactions)
+ {
+ tx_info txi;
+ const tx_details& txd = tx_vt.second;
+ txi.id_hash = epee::string_tools::pod_to_hex(tx_vt.first);
+ txi.tx_json = obj_to_json_str(*const_cast<transaction*>(&txd.tx));
+ txi.blob_size = txd.blob_size;
+ txi.fee = txd.fee;
+ txi.kept_by_block = txd.kept_by_block;
+ txi.max_used_block_height = txd.max_used_block_height;
+ txi.max_used_block_id_hash = epee::string_tools::pod_to_hex(txd.max_used_block_id);
+ 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;
+ tx_infos.push_back(txi);
+ }
+
+ for (const key_images_container::value_type& kee : m_spent_key_images) {
+ const crypto::key_image& k_image = kee.first;
+ const std::unordered_set<crypto::hash>& kei_image_set = kee.second;
+ spent_key_image_info ki;
+ ki.id_hash = epee::string_tools::pod_to_hex(k_image);
+ for (const crypto::hash& tx_id_hash : kei_image_set)
+ {
+ ki.txs_hashes.push_back(epee::string_tools::pod_to_hex(tx_id_hash));
+ }
+ key_image_infos.push_back(ki);
+ }
+ return true;
+ }
//---------------------------------------------------------------------------------
bool tx_memory_pool::get_transaction(const crypto::hash& id, transaction& tx) const
{
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index b867a1a7d..77f2e3483 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -43,6 +43,7 @@
#include "cryptonote_basic_impl.h"
#include "verification_context.h"
#include "crypto/hash.h"
+#include "rpc/core_rpc_server_commands_defs.h"
namespace cryptonote
{
@@ -81,6 +82,7 @@ namespace cryptonote
bool deinit();
bool fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee);
void get_transactions(std::list<transaction>& txs) const;
+ bool get_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const;
bool get_transaction(const crypto::hash& h, transaction& tx) const;
size_t get_transactions_count() const;
std::string print_pool(bool short_format) const;