aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp29
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h4
2 files changed, 31 insertions, 2 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 71f9534cb..b56725515 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -151,6 +151,23 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ static cryptonote::blobdata get_pruned_tx_blob(const cryptonote::blobdata &blobdata)
+ {
+ cryptonote::transaction tx;
+
+ if (!cryptonote::parse_and_validate_tx_from_blob(blobdata, tx))
+ {
+ MERROR("Failed to parse and validate tx from blob");
+ return blobdata;
+ }
+
+ std::stringstream ss;
+ binary_archive<true> ba(ss);
+ bool r = tx.serialize_base(ba);
+ CHECK_AND_ASSERT_MES(r, 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)
{
CHECK_CORE_BUSY();
@@ -162,10 +179,13 @@ namespace cryptonote
return false;
}
+ size_t pruned_size = 0, unpruned_size = 0, ntxes = 0;
for(auto& bd: bs)
{
res.blocks.resize(res.blocks.size()+1);
res.blocks.back().block = bd.first;
+ pruned_size += bd.first.size();
+ unpruned_size += bd.first.size();
res.output_indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices());
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
block b;
@@ -181,9 +201,15 @@ namespace cryptonote
return false;
}
size_t txidx = 0;
+ ntxes += bd.second.size();
for(const auto& t: bd.second)
{
- res.blocks.back().txs.push_back(t);
+ if (req.prune)
+ res.blocks.back().txs.push_back(get_pruned_tx_blob(t));
+ else
+ res.blocks.back().txs.push_back(t);
+ pruned_size += res.blocks.back().txs.back().size();
+ unpruned_size += t.size();
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
bool r = m_core.get_tx_outputs_gindexs(b.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
if (!r)
@@ -194,6 +220,7 @@ namespace cryptonote
}
}
+ MDEBUG("on_get_blocks: " << bs.size() << " blocks, " << ntxes << " txes, pruned size " << pruned_size << ", unpruned size " << unpruned_size);
res.status = CORE_RPC_STATUS_OK;
return true;
}
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 9f15da82a..d84dab0ba 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -49,7 +49,7 @@ namespace cryptonote
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define CORE_RPC_VERSION_MAJOR 1
-#define CORE_RPC_VERSION_MINOR 6
+#define CORE_RPC_VERSION_MINOR 7
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
@@ -80,9 +80,11 @@ namespace cryptonote
{
std::list<crypto::hash> block_ids; //*first 10 blocks id goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
uint64_t start_height;
+ bool prune;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(block_ids)
KV_SERIALIZE(start_height)
+ KV_SERIALIZE(prune)
END_KV_SERIALIZE_MAP()
};