Commit 7ab20d18 authored by LaurentMT's avatar LaurentMT
Browse files

Add chart displaying #utxos created by tx0s

parent fe3748be
......@@ -68,12 +68,22 @@ class Plotter(object):
o_metrics = self.tx0_metrics
lbl_direction = 'Tx0s counterparties heterogeneity'
# Number of outputs created by the Tx0s
if metrics == 'outputs':
chart_type = CT_SCATTERPLOT
l_metrics = list(o_metrics.d_metrics.values())
y_values = [item[2] for item in l_metrics]
x_values = [item[3] for item in l_metrics]
lbl_x = 'tx0 index'
lbl_y = '#outputs created by Tx0'
chart_title = 'Whirlpool Tx0s #Outputs (pools %s)' % o_metrics.snapshot.denom
# Heterogeneity ratio
if metrics == 'hr':
elif metrics == 'hr':
chart_type = CT_SCATTERPLOT
l_metrics = list(o_metrics.d_metrics.values())
y_values = [float(item[1]) / float(item[0]) for item in l_metrics]
x_values = list(range(0, len(y_values)))
x_values = [item[3] for item in l_metrics]
lbl_x = 'tx0 index'
lbl_y = 'heterogeneity ratio (#counterparties / #mixed outputs)'
chart_title = 'Whirlpool %s (pools %s)' %\
......@@ -102,7 +112,7 @@ class Plotter(object):
# Invalid name
else:
print('Invalid metrics (values: hr, hrout, hrdist).')
print('Invalid metrics (values: outputs, hr, hrout, hrdist).')
return
......
......@@ -34,6 +34,8 @@ class Snapshot(object):
self.l_tx0s = []
# Ordered list of tx0s block timestamps
self.l_ts_tx0s = []
# Ordered list of #utxoscreated by tx0s
self.l_utxos_tx0s = []
# Ordered list of mix txs
self.l_mix_txs = []
# Ordered list of mix txs block timestamps
......@@ -104,6 +106,8 @@ class Snapshot(object):
self.d_tx0s[txid_prefix] = tiid
ts = int(row[2])
self.l_ts_tx0s.append(ts)
nb_utxos = int(row[3])
self.l_utxos_tx0s.append(nb_utxos)
print(' Tx0s loaded')
......
......@@ -38,12 +38,14 @@ class Tx0sMetrics(object):
for prefix, tiid in self.snapshot.d_tx0s.items():
s_counterparties = set()
# Gets the number of mixed outputs for the current Tx0
tx0_outs = self.snapshot.d_links[tiid]
nb_outs = len(tx0_outs)
# Gets the number of outputs created by the current Tx0
nb_txos = self.snapshot.l_utxos_tx0s[nb_processed]
# Gets the number of spent outputs for the current Tx0
first_mixes = self.snapshot.d_links[tiid]
nb_spent_txos = len(first_mixes)
# Lists the Tx0s acting as counterparties
# for the first mixes of the current Tx0
for tiid_mix in tx0_outs:
for tiid_mix in first_mixes:
prev_tiids = self.snapshot.d_reverse_links[tiid_mix]
# Checks if counterparty comes from a Tx0
for prev_tiid in prev_tiids:
......@@ -53,7 +55,7 @@ class Tx0sMetrics(object):
# (remove 1 for the current Tx0)
nb_counterparties = len(s_counterparties) - 1
# Stores the results
self.d_metrics[prefix] = (nb_outs, nb_counterparties)
self.d_metrics[prefix] = (nb_spent_txos, nb_counterparties, nb_txos, nb_processed)
# Updates the #tx0s created per day
day = get_datetime_of_day(self.snapshot.l_ts_tx0s[nb_processed])
self.d_nb_new_tx0s[day] += 1
......
......@@ -212,9 +212,10 @@ Available charts:
plot act tx0s_active => plot a linechart of the daily number of active Tx0s
- Tx0s metrics -----------------------------------------------------------------------------------------------------------
plot tx0 hr => plot a scatterplot displaying the heteogeneity ratio of the tx0s
plot tx0 outputs => plot a scatterplot displaying the number of outputs generated by the Tx0s
plot tx0 hr => plot a scatterplot displaying the heteogeneity ratio of the Tx0s
plot tx0 hrout => plot a scatterplot displaying the heteogeneity ratio vs the number of mixed Tx0s outputs
plot tx0 hrdist => plot a histogram displaying the distribution of tx0s per heterogeneity ratio
plot tx0 hrdist => plot a histogram displaying the distribution of Tx0s per heterogeneity ratio
'''
print('')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment