Optimize decoy selection

Saves roughly 0.8s when running the tests, which took 16.6s and now take 
15.8 (5%).

Removes the larger sample size, which replaced the closest selected 
decoy with the real spend, per advice of Rucknium.
This commit is contained in:
Luke Parker
2022-05-28 03:17:02 -04:00
parent 469ce9106b
commit ba032cca4a
3 changed files with 78 additions and 68 deletions

View File

@@ -25,10 +25,8 @@ pub async fn rpc() -> Rpc {
PublicKey { point: (&random_scalar(&mut OsRng) * &ED25519_BASEPOINT_TABLE).compress() }
).to_string();
// Mine enough blocks decoy selection doesn't fail
for _ in 0 .. 1 {
mine_block(&rpc, &addr).await.unwrap();
}
// Mine 10 blocks so we have 10 decoys so decoy selection doesn't fail
mine_block(&rpc, &addr).await.unwrap();
rpc
}

View File

@@ -113,6 +113,15 @@ async fn send_core(test: usize, multisig: bool) {
continue;
}
// We actually need 80 decoys for this transaction, so mine until then
// 80 + 60 (miner TX maturity) + 10 (lock blocks)
// It is possible for this to be lower, by noting maturity is sufficient regardless of lock
// blocks, yet that's not currently implemented
// TODO, if we care
while rpc.get_height().await.unwrap() < 160 {
mine_block(&rpc, &addr.to_string()).await.unwrap();
}
for i in (start + 1) .. (start + 9) {
let tx = rpc.get_block_transactions(i).await.unwrap().swap_remove(0);
let output = tx.scan(view, spend_pub).swap_remove(0);