Skip to content

Commit

Permalink
Merge pull request #101 from cryptochangements34/prune-json-tx
Browse files Browse the repository at this point in the history
rpc: allow pruning of json encoded txs
  • Loading branch information
cryptochangements34 authored Sep 18, 2018
2 parents 0b29931 + 4b4621a commit 3c2cd7d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/rpc/core_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ namespace cryptonote
return get_pruned_tx_blob(tx);
}
//------------------------------------------------------------------------------------------------------------------------------
static cryptonote::blobdata get_pruned_tx_json(cryptonote::transaction &tx)
{
std::stringstream ss;
json_archive<true> ar(ss);
bool r = tx.serialize_base(ar);
CHECK_AND_ASSERT_MES(r, cryptonote::blobdata(), "Failed to serialize rct signatures base");
return ss.str();
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
{
PERF_TIMER(on_get_blocks);
Expand Down Expand Up @@ -642,7 +651,7 @@ namespace cryptonote
blobdata blob = req.prune ? get_pruned_tx_blob(tx) : t_serializable_object_to_blob(tx);
e.as_hex = string_tools::buff_to_hex_nodelimer(blob);
if (req.decode_as_json)
e.as_json = obj_to_json_str(tx);
e.as_json = req.prune ? get_pruned_tx_json(tx) : obj_to_json_str(tx);
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
if (e.in_pool)
{
Expand Down Expand Up @@ -793,7 +802,7 @@ namespace cryptonote
blobdata blob = req.prune ? get_pruned_tx_blob(tx) : t_serializable_object_to_blob(tx);
e.as_hex = string_tools::buff_to_hex_nodelimer(blob);
if (req.decode_as_json)
e.as_json = obj_to_json_str(tx);
e.as_json = req.prune ? get_pruned_tx_json(tx) : obj_to_json_str(tx);
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
if (e.in_pool)
{
Expand Down

0 comments on commit 3c2cd7d

Please sign in to comment.