aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-01-15 16:05:55 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-02-13 21:11:37 +0000
commit0288310e3b4e777dd4d120898319192f957996a2 (patch)
tree43faa373110305f0c4809f3c3e8421c5b973801a /src/rpc/core_rpc_server.cpp
parentMerge pull request #1719 (diff)
downloadmonero-0288310e3b4e777dd4d120898319192f957996a2.tar.xz
blockchain_db: add "raw" blobdata getters for block and transaction
This speeds up operations such as serving blocks to syncing peers
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-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 8165dacbc..2d2721140 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";