From f98b994f67cb37fed59bf587f6baa1ac688270fb Mon Sep 17 00:00:00 2001 From: Rucknium <86333515+Rucknium@users.noreply.github.com> Date: Fri, 12 Nov 2021 12:53:07 +0000 Subject: [PATCH] Create analysis-monero-PR-8047-prevent-duplicate-outs.R --- ...is-monero-PR-8047-prevent-duplicate-outs.R | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 monero-PR-8047-prevent-duplicate-outs/analysis-monero-PR-8047-prevent-duplicate-outs.R diff --git a/monero-PR-8047-prevent-duplicate-outs/analysis-monero-PR-8047-prevent-duplicate-outs.R b/monero-PR-8047-prevent-duplicate-outs/analysis-monero-PR-8047-prevent-duplicate-outs.R new file mode 100644 index 0000000..7e4e966 --- /dev/null +++ b/monero-PR-8047-prevent-duplicate-outs/analysis-monero-PR-8047-prevent-duplicate-outs.R @@ -0,0 +1,59 @@ +# install.packages("RPostgreSQL") +# install.packages("data.table") + +library(RPostgreSQL) +library(data.table) + +dbDriver("PostgreSQL") + +drv <- dbDriver("PostgreSQL") + +dbname.arg <- "" +host.arg <- "" +port.arg <- # numeric +user.arg <- "" +password.arg <- "" + +con <- dbConnect(drv, dbname = dbname.arg, + host = host.arg, port = port.arg, + user = user.arg, password = password.arg) + +dbListTables(con) + + +xmr.tx <- dbGetQuery(con, "SELECT * FROM tx_input_list") + +setDT(xmr.tx) + +xmr.tx[, unique.tx := paste(vin_amount, amount_index, sep = "-")] + +xmr.tx.collisions <- xmr.tx[, .( + collision.index = anyDuplicated(unique.tx), + n.inputs = uniqueN(vin_index)), + by = .(block_height, tx_index)] + +setorder(xmr.tx.collisions, block_height, tx_index) + +prop.table(table(xmr.tx.collisions$collision.index != 0)) + + +xmr.tx.collisions[, block.interval := cut(block_height, 100)] + +xmr.tx.collisions[, .(prop.collisions = 100 * mean(collision.index != 0)), by = .(block.interval)] + + +xmr.tx.collisions[n.inputs <= 2, .(prop.collisions = 100 * mean(collision.index != 0)), by = .(block.interval)] + +prop.table(table(xmr.tx.collisions$collision.index[xmr.tx.collisions$n.inputs <= 2] != 0)) + + +xmr.tx.collisions[n.inputs == 2, .(prop.collisions = 100 * mean(collision.index != 0)), by = .(block.interval)] + +prop.table(table(xmr.tx.collisions$collision.index[xmr.tx.collisions$n.inputs == 2] != 0)) + + +xmr.tx.collisions[n.inputs == 1, .(prop.collisions = 100 * mean(collision.index != 0)), by = .(block.interval)] + +prop.table(table(xmr.tx.collisions$collision.index[xmr.tx.collisions$n.inputs == 1] != 0)) + +