Commit 13d31089 authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

Initial commit

parents
/target
**/*.rs.bk
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "crossbeam-deque"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-epoch"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-queue"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "either"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "getrandom"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)",
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gmixer_analyzer"
version = "0.1.0"
dependencies = [
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hermit-abi"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itoa"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memoffset"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hermit-abi 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ppv-lite86"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon-core"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ryu"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-xid"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
"checksum hermit-abi 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15"
"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)" = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8"
"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
"checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76"
"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
"checksum serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
"checksum serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
"checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9"
"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[package]
name = "gmixer_analyzer"
version = "0.1.0"
authors = ["tuxmain <t@txmn.tk>"]
edition = "2018"
license = "AGPL3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.7.3"
rayon = "1.3.0"
serde = { version="1.0.106", features=["derive"] }
serde_json = "1.0.51"
This diff is collapsed.
hard_tabs = true
use rand::Rng;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use serde::Serialize;
use std::collections::HashMap;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct Pubkey(u32);
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct BlockId(u32);
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
struct Amount(u32);
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct MixId(u32);
#[derive(Debug, PartialEq)]
enum TxType {
Input,
Internal,
Output,
}
#[derive(Debug)]
struct Tx {
amount: Amount,
block_id: BlockId,
mix_id: MixId,
receiver: Pubkey,
sender: Pubkey,
tx_type: TxType,
}
#[derive(Debug)]
struct PendingTx {
amount: Amount,
expire_local: BlockId,
expire_global: BlockId,
mix_id: MixId,
path: Vec<Pubkey>,
}
#[derive(Debug)]
struct Node {
pending_txs: HashMap<Amount, Vec<PendingTx>>,
pubkey: Pubkey,
}
#[derive(Debug)]
struct Client {
pubkey: Pubkey,
}
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize)]
struct Proba(f64);
#[derive(Debug, Serialize)]
struct ProbaEvent<T> {
event: T,
proba: Proba,
}
#[derive(Debug, Serialize)]
struct ProbaList<T>(Vec<ProbaEvent<T>>);
#[derive(Debug)]
struct TxResult {
mean: Proba,
std_dev: Proba,
max: Proba,
min: Proba,
true_proba: Proba,
}
#[derive(Debug)]
enum PathResult {
Input(Vec<MixId>),
Internal(Vec<PathResult>),
}
#[derive(Debug, Serialize)]
struct Settings {
amounts: ProbaList<Amount>,
expire_local: u32,
expire_global: u32,
layers: usize,
nb_blocks: u32,
nb_clients: u32,
nb_nodes: u32,
smart_clients: bool,
txmin: usize,
txs_per_block_per_client: Proba,
}
fn prepare(
clients_index: &mut HashMap<Pubkey, Client>,
nodes_index: &mut HashMap<Pubkey, Node>,
settings: &Settings,
) {
for i in 0..settings.nb_clients {
clients_index.insert(Pubkey(i), Client { pubkey: Pubkey(i) });
}
for i in settings.nb_clients..(settings.nb_clients + settings.nb_nodes) {
nodes_index.insert(
Pubkey(i),
Node {
pubkey: Pubkey(i),
pending_txs: HashMap::new(),
},
);
}
}
// TODO apply expiration
fn simulate(
clients_index: &HashMap<Pubkey, Client>,
nodes_index: &mut HashMap<Pubkey, Node>,
settings: &Settings,
txs: &mut Vec<Tx>,
) {
let mut rng = rand::thread_rng();
let clients_pubkeys: Vec<Pubkey> = clients_index.iter().map(|x| x.1.pubkey.clone()).collect();
let mut nodes_pubkeys: Vec<Pubkey> = nodes_index.iter().map(|x| x.1.pubkey.clone()).collect();
let mut mix_id = MixId(0);
for block_id in 0..settings.nb_blocks {
let mut new_pending_txs: HashMap<Pubkey, Vec<PendingTx>> = HashMap::new();
for (_, node) in nodes_index.iter_mut() {
let mut to_send: Vec<Amount> = vec![];
for (amount, pending_txs) in node.pending_txs.iter() {
if pending_txs.len() >= settings.txmin {
to_send.push(amount.clone());
}
}
for amount in to_send {
for pending_tx in node.pending_txs.remove(&amount).unwrap() {
if pending_tx.path.len() > 1 {
let new_pending_tx = PendingTx {
amount,
expire_global: pending_tx.expire_global,
expire_local: BlockId(block_id + settings.expire_local),
mix_id: pending_tx.mix_id,
path: pending_tx.path[1..].to_vec(),
};
if new_pending_txs.contains_key(&pending_tx.path[0]) {
new_pending_txs
.get_mut(&pending_tx.path[0])
.unwrap()
.push(new_pending_tx);
} else {
new_pending_txs.insert(pending_tx.path[0], vec![new_pending_tx]);
}
}
txs.push(Tx {
amount,
block_id: BlockId(block_id),
mix_id: pending_tx.mix_id,
receiver: pending_tx.path[0],
sender: node.pubkey,
tx_type: if pending_tx.path.len() > 1 {
TxType::Internal
} else {
TxType::Output
},
});
}
}
}
for (pubkey, pending_txs) in new_pending_txs {
let node = nodes_index.get_mut(&pubkey).unwrap();
for pending_tx in pending_txs {
if node.pending_txs.contains_key(&pending_tx.amount) {
node.pending_txs
.get_mut(&pending_tx.amount)
.unwrap()
.push(pending_tx);
} else {
node.pending_txs.insert(pending_tx.amount, vec![pending_tx]);
}
}
}
for (_, client) in clients_index.iter() {
if rng.gen_bool(settings.txs_per_block_per_client.0) {
// TODO implement smart_clients
let mut path: Vec<Pubkey> = Vec::new();
for layer in 0..settings.layers {
let r: usize = rand::Rng::gen_range(&mut rng, layer, nodes_pubkeys.len());
path.push(nodes_pubkeys[r].clone());
nodes_pubkeys.swap(layer, r);
}
path.push(clients_pubkeys[rand::Rng::gen_range(&mut rng, 0, clients_index.len())]);
let tx = Tx {
block_id: BlockId(block_id),
amount: settings.amounts.0[0].event,
mix_id,
sender: client.pubkey,
receiver: path[0],
tx_type: TxType::Input,
};
if settings.layers > 0 {
let mut next_path = path.clone();
next_path.remove(0);
let node = nodes_index.get_mut(&path[0]).unwrap();
let pending_tx = PendingTx {
amount: tx.amount,
expire_global: BlockId(block_id + settings.expire_global),
expire_local: BlockId(block_id + settings.expire_local),
mix_id,
path: next_path,
};
if node.pending_txs.contains_key(&tx.amount) {
node.pending_txs
.get_mut(&tx.amount)
.unwrap()
.push(pending_tx);
} else {
node.pending_txs.insert(tx.amount, vec![pending_tx]);
}
}
mix_id.0 += 1;
txs.push(tx);
}
}
}
}
/// Returns (sum, min, max, std_dev)
fn compute_stats(v: &HashMap<MixId, usize>) -> (usize, usize, usize, f64) {
let mut sum2: usize = 0;
let mut sum: usize = 0; // sum
let mut min = usize::max_value();
let mut max = usize::min_value();
v.iter().for_each(|(_, x)| {
sum2 += x.pow(2);
sum += x;
if *x < min {
min = *x;
}
if *x > max {
max = *x;
}
});
(
sum,
min,
max,
(sum2 as f64 / v.len() as f64 - (sum as f64 / v.len() as f64).powi(2)).sqrt(),
)
}
fn retro_tx(
clients_index: &HashMap<Pubkey, Client>,
layers: usize,
nodes_index: &HashMap<Pubkey, Node>,
settings: &Settings,
tx: &Tx,
txs: &Vec<Tx>,
) -> PathResult {
let from_block = BlockId(
tx.block_id
.0
.checked_sub(settings.expire_local)
.unwrap_or(0),
);
if layers == 1 {
let mut result: Vec<MixId> = vec![];
for txi in txs {
if txi.block_id >= tx.block_id {
break;
}
if txi.block_id > from_block
&& txi.receiver == tx.sender
&& txi.tx_type == TxType::Input
{
result.push(txi.mix_id);
}
}
PathResult::Input(result)
} else {
let mut result: Vec<PathResult> = vec![];
for txi in txs {
if txi.block_id >= tx.block_id {
break;
}
if txi.block_id > from_block
&& txi.receiver == tx.sender
&& txi.tx_type == TxType::Internal
{
result.push(retro_tx(
clients_index,
layers - 1,
nodes_index,
settings,
txi,
txs,
));
}
}
PathResult::Internal(result)
}
}
fn count_possible_inputs(mix_ids: &mut HashMap<MixId, usize>, path: PathResult) {
match path {
PathResult::Input(v) => {
for mix_id in v {
if mix_ids.contains_key(&mix_id) {
mix_ids.insert(mix_id, mix_ids.get(&mix_id).unwrap() + 1);
} else {
mix_ids.insert(mix_id, 1);
}
}
}
PathResult::Internal(v) => {
for subpath in v {
count_possible_inputs(mix_ids, subpath);
}
}