Fixed ZMQ-RPC for transactions and GET_BLOCKS_FAST

This commit is contained in:
Lee Clagett 2018-08-01 22:10:09 -04:00
parent 702a41034d
commit 4616cf2641
7 changed files with 427 additions and 196 deletions

View file

@ -86,11 +86,27 @@ namespace rpc
res.error_details = "incorrect number of transactions retrieved for block";
return;
}
std::vector<transaction> txs;
for (const auto& p : it->second)
cryptonote::rpc::block_output_indices& indices = res.output_indices[block_count];
// miner tx output indices
{
txs.resize(txs.size() + 1);
if (!parse_and_validate_tx_from_blob(p.second, txs.back()))
cryptonote::rpc::tx_output_indices tx_indices;
if (!m_core.get_tx_outputs_gindexs(get_transaction_hash(bwt.block.miner_tx), tx_indices))
{
res.status = Message::STATUS_FAILED;
res.error_details = "core::get_tx_outputs_gindexs() returned false";
return;
}
indices.push_back(std::move(tx_indices));
}
auto hash_it = bwt.block.tx_hashes.begin();
bwt.transactions.reserve(it->second.size());
for (const auto& blob : it->second)
{
bwt.transactions.emplace_back();
if (!parse_and_validate_tx_from_blob(blob.second, bwt.transactions.back()))
{
res.blocks.clear();
res.output_indices.clear();
@ -98,41 +114,17 @@ namespace rpc
res.error_details = "failed retrieving a requested transaction";
return;
}
}
cryptonote::rpc::block_output_indices& indices = res.output_indices[block_count];
// miner tx output indices
{
cryptonote::rpc::tx_output_indices tx_indices;
bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(bwt.block.miner_tx), tx_indices);
if (!r)
{
res.status = Message::STATUS_FAILED;
res.error_details = "core::get_tx_outputs_gindexs() returned false";
return;
}
indices.push_back(tx_indices);
}
// assume each block returned is returned with all its transactions
// in the correct order.
auto tx_it = txs.begin();
for (const crypto::hash& h : bwt.block.tx_hashes)
{
bwt.transactions.emplace(h, *tx_it);
tx_it++;
cryptonote::rpc::tx_output_indices tx_indices;
bool r = m_core.get_tx_outputs_gindexs(h, tx_indices);
if (!r)
if (!m_core.get_tx_outputs_gindexs(*hash_it, tx_indices))
{
res.status = Message::STATUS_FAILED;
res.error_details = "core::get_tx_outputs_gindexs() returned false";
return;
}
indices.push_back(tx_indices);
indices.push_back(std::move(tx_indices));
++hash_it;
}
it++;