diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index c4b679dc..28586736 100755 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -884,6 +884,18 @@ void rai::rpc_handler::blocks () void rai::rpc_handler::blocks_info () { + bool pending (false); + boost::optional pending_optional (request.get_optional ("pending")); + if (pending_optional.is_initialized ()) + { + pending = pending_optional.get (); + } + bool source (false); + boost::optional source_optional (request.get_optional ("source")); + if (source_optional.is_initialized ()) + { + source = source_optional.get (); + } std::vector hashes; boost::property_tree::ptree response_l; boost::property_tree::ptree blocks; @@ -906,6 +918,30 @@ void rai::rpc_handler::blocks_info () std::string contents; block->serialize_json (contents); entry.put ("contents", contents); + if (pending) + { + auto block_l (dynamic_cast (block.get ())); + bool exists (false); + if (block_l != nullptr) + { + auto destination (block_l->hashables.destination); + exists = node.store.pending_exists (transaction, rai::pending_key (destination, hash)); + } + entry.put ("pending", exists ? "1" : "0"); + } + if (source) + { + rai::block_hash source_hash (block->source ()); + std::unique_ptr block_a (node.store.block_get (transaction, source_hash)); + if (block_a != nullptr) + { + auto source_account (node.ledger.account (transaction, source_hash)); + entry.put ("source_account", source_account.to_account ()); + } + else { + entry.put ("source_account", "0"); + } + } blocks.push_back (std::make_pair (hash_text, entry)); } else