mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user