|
|
@ -226,9 +226,9 @@ namespace cryptonote
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCKS_FAST>(invoke_http_mode::BIN, "/getblocks.bin", req, res, r))
|
|
|
|
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCKS_FAST>(invoke_http_mode::BIN, "/getblocks.bin", req, res, r))
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::pair<cryptonote::blobdata, std::vector<cryptonote::blobdata> > > bs;
|
|
|
|
std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > > bs;
|
|
|
|
|
|
|
|
|
|
|
|
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, req.prune, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
|
|
|
|
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, req.prune, !req.no_miner_tx, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -240,46 +240,33 @@ namespace cryptonote
|
|
|
|
for(auto& bd: bs)
|
|
|
|
for(auto& bd: bs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.blocks.resize(res.blocks.size()+1);
|
|
|
|
res.blocks.resize(res.blocks.size()+1);
|
|
|
|
res.blocks.back().block = bd.first;
|
|
|
|
res.blocks.back().block = bd.first.first;
|
|
|
|
pruned_size += bd.first.size();
|
|
|
|
pruned_size += bd.first.first.size();
|
|
|
|
unpruned_size += bd.first.size();
|
|
|
|
unpruned_size += bd.first.first.size();
|
|
|
|
res.output_indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices());
|
|
|
|
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());
|
|
|
|
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
|
|
|
|
block b;
|
|
|
|
|
|
|
|
if (!parse_and_validate_block_from_blob(bd.first, b))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res.status = "Invalid block";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!req.no_miner_tx)
|
|
|
|
if (!req.no_miner_tx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.miner_tx), res.output_indices.back().indices.back().indices);
|
|
|
|
bool r = m_core.get_tx_outputs_gindexs(bd.first.second, res.output_indices.back().indices.back().indices);
|
|
|
|
if (!r)
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(b.tx_hashes.size() != bd.second.size())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MERROR("block " << get_block_hash(b) << ": tx_hashes.size() " << b.tx_hashes.size() << ", bd.second.size() " << bd.second.size());
|
|
|
|
|
|
|
|
res.status = "Failed";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t txidx = 0;
|
|
|
|
|
|
|
|
ntxes += bd.second.size();
|
|
|
|
ntxes += bd.second.size();
|
|
|
|
res.blocks.back().txs.reserve(bd.second.size());
|
|
|
|
res.blocks.back().txs.reserve(bd.second.size());
|
|
|
|
res.output_indices.back().indices.reserve(bd.second.size());
|
|
|
|
res.output_indices.back().indices.reserve(bd.second.size());
|
|
|
|
for (std::vector<cryptonote::blobdata>::iterator i = bd.second.begin(); i != bd.second.end(); ++i)
|
|
|
|
for (std::vector<std::pair<crypto::hash, cryptonote::blobdata>>::iterator i = bd.second.begin(); i != bd.second.end(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unpruned_size += i->size();
|
|
|
|
unpruned_size += i->second.size();
|
|
|
|
res.blocks.back().txs.push_back(std::move(*i));
|
|
|
|
res.blocks.back().txs.push_back(std::move(i->second));
|
|
|
|
i->clear();
|
|
|
|
i->second.clear();
|
|
|
|
i->shrink_to_fit();
|
|
|
|
i->second.shrink_to_fit();
|
|
|
|
pruned_size += res.blocks.back().txs.back().size();
|
|
|
|
pruned_size += res.blocks.back().txs.back().size();
|
|
|
|
|
|
|
|
|
|
|
|
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_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(b.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
|
|
|
|
bool r = m_core.get_tx_outputs_gindexs(i->first, res.output_indices.back().indices.back().indices);
|
|
|
|
if (!r)
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.status = "Failed";
|
|
|
|
res.status = "Failed";
|
|
|
|