mirror of
https://github.com/monero-project/monero.git
synced 2025-08-12 23:35:25 -04:00
rpc: speedup get_outs.bin
This commit is contained in:
parent
b37ce24cdd
commit
fc98f7a0a1
8 changed files with 45 additions and 18 deletions
|
@ -229,7 +229,7 @@ bool Blockchain::scan_outputkeys_for_indexes(size_t tx_version, const txin_to_ke
|
|||
{
|
||||
try
|
||||
{
|
||||
m_db->get_output_key(tx_in_to_key.amount, absolute_offsets, outputs, true);
|
||||
m_db->get_output_key(epee::span<const uint64_t>(&tx_in_to_key.amount, 1), absolute_offsets, outputs, true);
|
||||
if (absolute_offsets.size() != outputs.size())
|
||||
{
|
||||
MERROR_VER("Output does not exist! amount = " << tx_in_to_key.amount);
|
||||
|
@ -255,7 +255,7 @@ bool Blockchain::scan_outputkeys_for_indexes(size_t tx_version, const txin_to_ke
|
|||
add_offsets.push_back(absolute_offsets[i]);
|
||||
try
|
||||
{
|
||||
m_db->get_output_key(tx_in_to_key.amount, add_offsets, add_outputs, true);
|
||||
m_db->get_output_key(epee::span<const uint64_t>(&tx_in_to_key.amount, 1), add_offsets, add_outputs, true);
|
||||
if (add_offsets.size() != add_outputs.size())
|
||||
{
|
||||
MERROR_VER("Output does not exist! amount = " << tx_in_to_key.amount);
|
||||
|
@ -1767,16 +1767,34 @@ bool Blockchain::get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMA
|
|||
|
||||
res.outs.clear();
|
||||
res.outs.reserve(req.outputs.size());
|
||||
|
||||
std::vector<cryptonote::output_data_t> data;
|
||||
try
|
||||
{
|
||||
std::vector<uint64_t> amounts, offsets;
|
||||
amounts.reserve(req.outputs.size());
|
||||
offsets.reserve(req.outputs.size());
|
||||
for (const auto &i: req.outputs)
|
||||
{
|
||||
// get tx_hash, tx_out_index from DB
|
||||
const output_data_t od = m_db->get_output_key(i.amount, i.index);
|
||||
tx_out_index toi = m_db->get_output_tx_and_index(i.amount, i.index);
|
||||
bool unlocked = is_tx_spendtime_unlocked(m_db->get_tx_unlock_time(toi.first));
|
||||
amounts.push_back(i.amount);
|
||||
offsets.push_back(i.index);
|
||||
}
|
||||
m_db->get_output_key(epee::span<const uint64_t>(amounts.data(), amounts.size()), offsets, data);
|
||||
if (data.size() != req.outputs.size())
|
||||
{
|
||||
MERROR("Unexpected output data size: expected " << req.outputs.size() << ", got " << data.size());
|
||||
return false;
|
||||
}
|
||||
for (const auto &t: data)
|
||||
res.outs.push_back({t.pubkey, t.commitment, is_tx_spendtime_unlocked(t.unlock_time), t.height, crypto::null_hash});
|
||||
|
||||
res.outs.push_back({od.pubkey, od.commitment, unlocked, od.height, toi.first});
|
||||
if (req.get_txid)
|
||||
{
|
||||
for (size_t i = 0; i < req.outputs.size(); ++i)
|
||||
{
|
||||
tx_out_index toi = m_db->get_output_tx_and_index(req.outputs[i].amount, req.outputs[i].index);
|
||||
res.outs[i].txid = toi.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -3795,7 +3813,7 @@ void Blockchain::output_scan_worker(const uint64_t amount, const std::vector<uin
|
|||
{
|
||||
try
|
||||
{
|
||||
m_db->get_output_key(amount, offsets, outputs, true);
|
||||
m_db->get_output_key(epee::span<const uint64_t>(&amount, 1), offsets, outputs, true);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue