From aa523c7fe050e8f5e9caaa45554bd18b010e714a Mon Sep 17 00:00:00 2001 From: SergiySW Date: Tue, 18 Jul 2017 10:50:02 +0300 Subject: [PATCH] RPC pending_exists --- rai/node/rpc.cpp | 33 +++++++++++++++++++++++++++++++++ rai/node/rpc.hpp | 1 + 2 files changed, 34 insertions(+) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 57fc5289..773031f5 100755 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1392,6 +1392,35 @@ void rai::rpc_handler::pending () } } +void rai::rpc_handler::pending_exists () +{ + std::string hash_text (request.get ("hash")); + rai::uint256_union hash; + auto error (hash.decode_hex (hash_text)); + if (!error) + { + rai::transaction transaction (node.store.environment, nullptr, false); + auto block (node.store.block_get (transaction, hash)); + if (block != nullptr) + { + auto block_l (static_cast (block.release ())); + auto account (block_l->hashables.destination); + boost::property_tree::ptree response_l; + auto exists (node.store.pending_exists (transaction, rai::pending_key (account, hash))); + response_l.put ("exists", exists ? "1" : "0"); + response (response_l); + } + else + { + error_response (response, "Block not found"); + } + } + else + { + error_response (response, "Bad hash number"); + } +} + void rai::rpc_handler::pending_threshold () { std::string account_text (request.get ("account")); @@ -2872,6 +2901,10 @@ void rai::rpc_handler::process_request () { pending (); } + else if (action == "pending_exists") + { + pending_exists (); + } else if (action == "pending_threshold") { pending_threshold (); diff --git a/rai/node/rpc.hpp b/rai/node/rpc.hpp index 8f7ee457..6f0baa98 100644 --- a/rai/node/rpc.hpp +++ b/rai/node/rpc.hpp @@ -133,6 +133,7 @@ public: void payment_wait (); void peers (); void pending (); + void pending_exists (); void pending_threshold (); void process (); void rai_to_raw ();