diff options
author | warptangent <warptangent@inbox.com> | 2015-04-23 05:13:07 -0700 |
---|---|---|
committer | warptangent <warptangent@inbox.com> | 2015-04-23 07:04:36 -0700 |
commit | b76857f9d9a8bf45b854e9c3da56b550ade1a7c6 (patch) | |
tree | aead9c8412218045e3de48fe4b98a2bcc0393b67 /src/daemon | |
parent | update lmdb64 (diff) | |
download | monero-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 '')
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 5d73c7e8c..8ef91600c 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -523,20 +523,58 @@ bool t_rpc_command_executor::print_transaction_pool_long() { } } - if (res.transactions.empty()) + if (res.transactions.empty() && res.spent_key_images.empty()) { tools::msg_writer() << "Pool is empty" << std::endl; } - for (auto & tx_info : res.transactions) + if (! res.transactions.empty()) { - tools::msg_writer() << "id: " << tx_info.id_hash << std::endl - << "blob_size: " << tx_info.blob_size << std::endl - << "fee: " << tx_info.fee << std::endl - << "kept_by_block: " << tx_info.kept_by_block << std::endl - << "max_used_block_height: " << tx_info.max_used_block_height << std::endl - << "max_used_block_id: " << tx_info.max_used_block_id_hash << std::endl - << "last_failed_height: " << tx_info.last_failed_height << std::endl - << "last_failed_id: " << tx_info.last_failed_id_hash << std::endl; + tools::msg_writer() << "Transactions: "; + for (auto & tx_info : res.transactions) + { + tools::msg_writer() << "id: " << tx_info.id_hash << std::endl + << tx_info.tx_json << std::endl + << "blob_size: " << tx_info.blob_size << std::endl + << "fee: " << cryptonote::print_money(tx_info.fee) << std::endl + << "kept_by_block: " << (tx_info.kept_by_block ? 'T' : 'F') << std::endl + << "max_used_block_height: " << tx_info.max_used_block_height << std::endl + << "max_used_block_id: " << tx_info.max_used_block_id_hash << std::endl + << "last_failed_height: " << tx_info.last_failed_height << std::endl + << "last_failed_id: " << tx_info.last_failed_id_hash << std::endl; + } + if (res.spent_key_images.empty()) + { + tools::msg_writer() << "WARNING: Inconsistent pool state - no spent key images"; + } + } + if (! res.spent_key_images.empty()) + { + tools::msg_writer() << ""; // one newline + tools::msg_writer() << "Spent key images: "; + for (const cryptonote::spent_key_image_info& kinfo : res.spent_key_images) + { + tools::msg_writer() << "key image: " << kinfo.id_hash; + if (kinfo.txs_hashes.size() == 1) + { + tools::msg_writer() << " tx: " << kinfo.txs_hashes[0]; + } + else if (kinfo.txs_hashes.size() == 0) + { + tools::msg_writer() << " WARNING: spent key image has no txs associated"; + } + else + { + tools::msg_writer() << " NOTE: key image for multiple txs: " << kinfo.txs_hashes.size(); + for (const std::string& tx_id : kinfo.txs_hashes) + { + tools::msg_writer() << " tx: " << tx_id; + } + } + } + if (res.transactions.empty()) + { + tools::msg_writer() << "WARNING: Inconsistent pool state - no transactions"; + } } return true; @@ -571,10 +609,9 @@ bool t_rpc_command_executor::print_transaction_pool_short() { for (auto & tx_info : res.transactions) { tools::msg_writer() << "id: " << tx_info.id_hash << std::endl - << tx_info.tx_json << std::endl << "blob_size: " << tx_info.blob_size << std::endl - << "fee: " << tx_info.fee << std::endl - << "kept_by_block: " << tx_info.kept_by_block << std::endl + << "fee: " << cryptonote::print_money(tx_info.fee) << std::endl + << "kept_by_block: " << (tx_info.kept_by_block ? 'T' : 'F') << std::endl << "max_used_block_height: " << tx_info.max_used_block_height << std::endl << "max_used_block_id: " << tx_info.max_used_block_id_hash << std::endl << "last_failed_height: " << tx_info.last_failed_height << std::endl |