aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-02-21 11:27:15 +0200
committerRiccardo Spagni <ric@spagni.net>2017-02-21 11:27:15 +0200
commit49efd3add9f7b9bbcbd2526538846f6d8e58ac86 (patch)
treee3f1c97cd7dfb7a1c82927f3c2d483bfbe1afbe2 /src/rpc
parentMerge pull request #1725 (diff)
parentblockchain_db: add "raw" blobdata getters for block and transaction (diff)
downloadmonero-49efd3add9f7b9bbcbd2526538846f6d8e58ac86.tar.xz
Merge pull request #1727
0288310e blockchain_db: add "raw" blobdata getters for block and transaction (moneromooo-monero)
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 157076e82..4570a3715 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -151,7 +151,7 @@ namespace cryptonote
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();
- std::list<std::pair<block, std::list<transaction> > > bs;
+ std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > > bs;
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
{
@@ -159,24 +159,30 @@ namespace cryptonote
return false;
}
- for(auto& b: bs)
+ for(auto& bd: bs)
{
res.blocks.resize(res.blocks.size()+1);
- res.blocks.back().block = block_to_blob(b.first);
+ res.blocks.back().block = bd.first;
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());
- bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.first.miner_tx), res.output_indices.back().indices.back().indices);
+ block b;
+ if (!parse_and_validate_block_from_blob(bd.first, b))
+ {
+ res.status = "Invalid block";
+ return false;
+ }
+ bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.miner_tx), res.output_indices.back().indices.back().indices);
if (!r)
{
res.status = "Failed";
return false;
}
size_t txidx = 0;
- for(auto& t: b.second)
+ for(const auto& t: bd.second)
{
- res.blocks.back().txs.push_back(tx_to_blob(t));
+ res.blocks.back().txs.push_back(t);
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
- bool r = m_core.get_tx_outputs_gindexs(b.first.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
+ bool r = m_core.get_tx_outputs_gindexs(b.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
if (!r)
{
res.status = "Failed";