mirror of
https://github.com/monero-project/monero.git
synced 2025-01-19 16:13:40 +02:00
wallet2: speed up get_output_relatedness
This commit is contained in:
parent
d752464fbb
commit
fee4f9a076
@ -6338,29 +6338,25 @@ namespace
|
|||||||
// their ordering, but it could become more murky if we add scores later.
|
// 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
|
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
|
// don't think these are particularly related
|
||||||
if (td0.m_txid == td1.m_txid)
|
if (dh >= 10)
|
||||||
return 1.0f;
|
return 0.0f;
|
||||||
|
|
||||||
// same block height -> possibly tx burst, or same tx (since above is disabled)
|
// similar block heights
|
||||||
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 > 1)
|
||||||
if (dh == 0)
|
return 0.2f;
|
||||||
return 0.9f;
|
|
||||||
|
|
||||||
// adjacent blocks -> possibly tx burst
|
// adjacent blocks -> possibly tx burst
|
||||||
if (dh == 1)
|
if (dh == 1)
|
||||||
return 0.8f;
|
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
|
return 0.9f;
|
||||||
if (dh < 10)
|
|
||||||
return 0.2f;
|
|
||||||
|
|
||||||
// don't think these are particularly related
|
|
||||||
return 0.0f;
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
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
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user