Use a gamma distribution for mixin selection

This commit is contained in:
Luke Parker
2022-05-04 08:18:43 -04:00
parent f856faa762
commit 0f481773df
6 changed files with 71 additions and 21 deletions

View File

@@ -8,7 +8,6 @@ use curve25519_dalek::edwards::{EdwardsPoint, CompressedEdwardsY};
use monero::{
Hash,
cryptonote::hash::Hashable,
blockdata::{
transaction::{TxIn, Transaction},
block::Block
@@ -237,13 +236,30 @@ impl Rpc {
).collect()
}
pub async fn get_high_output(&self, height: usize) -> Result<u64, RpcError> {
let block = self.get_block(height).await?;
Ok(
*self.get_o_indexes(
*block.tx_hashes.last().unwrap_or(&block.miner_tx.hash())
).await?.last().ok_or(RpcError::InvalidTransaction)?
)
pub async fn get_output_distribution(&self, height: usize) -> Result<Vec<u64>, RpcError> {
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Distribution {
distribution: Vec<u64>
}
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
struct Distributions {
distributions: Vec<Distribution>
}
let mut distributions: JsonRpcResponse<Distributions> = self.rpc_call("json_rpc", Some(json!({
"method": "get_output_distribution",
"params": {
"binary": false,
"amounts": [0],
"cumulative": true,
"to_height": height
}
}))).await?;
Ok(distributions.result.distributions.swap_remove(0).distribution)
}
pub async fn publish_transaction(&self, tx: &Transaction) -> Result<(), RpcError> {