wallet2: speed up get_output_relatedness

This commit is contained in:
Crypto City 2023-01-09 11:23:07 +00:00 committed by moneromooo-monero
parent d752464fbb
commit fee4f9a076
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -6338,29 +6338,25 @@ namespace
// their ordering, but it could become more murky if we add scores later.
float wallet2::get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const
{
int dh;
const int64_t dh = td0.m_block_height > td1.m_block_height ? td0.m_block_height - td1.m_block_height : td1.m_block_height - td0.m_block_height;
// expensive test, and same tx will fall onto the same block height below
if (td0.m_txid == td1.m_txid)
return 1.0f;
// don't think these are particularly related
if (dh >= 10)
return 0.0f;
// same block height -> possibly tx burst, or same tx (since above is disabled)
dh = td0.m_block_height > td1.m_block_height ? td0.m_block_height - td1.m_block_height : td1.m_block_height - td0.m_block_height;
if (dh == 0)
return 0.9f;
// similar block heights
if (dh > 1)
return 0.2f;
// adjacent blocks -> possibly tx burst
if (dh == 1)
return 0.8f;
// could extract the payment id, and compare them, but this is a bit expensive too
// expensive test, and same tx will fall onto the same block height below
if (td0.m_txid == td1.m_txid)
return 1.0f;
// similar block heights
if (dh < 10)
return 0.2f;
// don't think these are particularly related
return 0.0f;
return 0.9f;
}
//----------------------------------------------------------------------------------------------------
size_t wallet2::pop_best_value_from(const transfer_container &transfers, std::vector<size_t> &unused_indices, const std::vector<size_t>& selected_transfers, bool smallest) const