Removes macro and goto code in wallet2::import_outputs function

This simply replaces a confusing code section and replaces an odd
macro/goto combination with a more reasonable if statment.
This commit is contained in:
Sean Darcy 2022-02-11 14:44:50 +11:00
parent 9588055440
commit f7bf4be664
1 changed files with 9 additions and 14 deletions

View File

@ -13867,23 +13867,18 @@ size_t wallet2::import_outputs(const std::pair<size_t, std::vector<tools::wallet
{
// compare the data used to create the key image below
const transfer_details &org_td = m_transfers[i + offset];
if (!org_td.m_key_image_known)
goto process;
#define CMPF(f) if (!(td.f == org_td.f)) goto process
CMPF(m_txid);
CMPF(m_key_image);
CMPF(m_internal_output_index);
#undef CMPF
if (!(get_transaction_prefix_hash(td.m_tx) == get_transaction_prefix_hash(org_td.m_tx)))
goto process;
if (org_td.m_key_image_known
&& td.m_txid == org_td.m_txid
&& td.m_key_image == org_td.m_key_image
&& td.m_internal_output_index == org_td.m_internal_output_index
&& get_transaction_prefix_hash(td.m_tx) == get_transaction_prefix_hash(org_td.m_tx)) {
// copy anyway, since the comparison does not include ancillary fields which may have changed
m_transfers[i + offset] = std::move(td);
continue;
// copy anyway, since the comparison does not include ancillary fields which may have changed
m_transfers[i + offset] = std::move(td);
continue;
}
}
process:
// the hot wallet wouldn't have known about key images (except if we already exported them)
cryptonote::keypair in_ephemeral;