RPC unchecked_get
This commit is contained in:
parent
39bfa42c42
commit
45e5eb4a2d
2 changed files with 41 additions and 0 deletions
|
@ -1911,6 +1911,42 @@ void rai::rpc_handler::unchecked_clear ()
|
|||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::unchecked_get ()
|
||||
{
|
||||
std::string hash_text (request.get <std::string> ("hash"));
|
||||
rai::uint256_union hash;
|
||||
auto error (hash.decode_hex (hash_text));
|
||||
if (!error)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (node.store.unchecked_begin (transaction)), n (node.store.unchecked_end ()); i != n; ++i)
|
||||
{
|
||||
rai::bufferstream stream (reinterpret_cast <uint8_t const *> (i->second.mv_data), i->second.mv_size);
|
||||
auto block (rai::deserialize_block (stream));
|
||||
if (block->hash () == hash)
|
||||
{
|
||||
std::string contents;
|
||||
block->serialize_json (contents);
|
||||
response_l.put ("contents", contents);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!response_l.empty ())
|
||||
{
|
||||
response (response_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_response (response, "Unchecked block not found");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error_response (response, "Bad hash number");
|
||||
}
|
||||
}
|
||||
|
||||
void rai::rpc_handler::unchecked_keys ()
|
||||
{
|
||||
uint64_t count (std::numeric_limits <uint64_t>::max ());
|
||||
|
@ -2794,6 +2830,10 @@ void rai::rpc_handler::process_request ()
|
|||
{
|
||||
unchecked_clear ();
|
||||
}
|
||||
else if (action == "unchecked_get")
|
||||
{
|
||||
unchecked_get ();
|
||||
}
|
||||
else if (action == "unchecked_keys")
|
||||
{
|
||||
unchecked_keys ();
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
void successors ();
|
||||
void unchecked ();
|
||||
void unchecked_clear ();
|
||||
void unchecked_get ();
|
||||
void unchecked_keys ();
|
||||
void validate_account_number ();
|
||||
void version ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue