Skip to content

Commit 7a2aa5f

Browse files
author
Marcin Jachymiak
committed
Track many-to-one consolidations
getblockstats now counts the number of transactions with at least 3 inputs and exactly one output as "many-to-one" (mto) consolidations. It also counts the total number of outputs consolidated by mto transactions per block.
1 parent ecb3ea0 commit 7a2aa5f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/rpc/blockchain.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,8 @@ static UniValue getblockstats(const JSONRPCRequest& request)
17531753
" \"txs_batching\": xxxxx, (numeric) The total number batching transactions (defined as at least 3 outputs)\n"
17541754
" \"outcount_bins\": xxxxx, (numeric_array) The numbers of transactions that have certain numbers of outputs\n"
17551755
" \"dust_bins\": xxxxx, (numeric_array) The total number of outputs that are dust at several fee-rates\n"
1756+
" \"mto_consolidations\": xxxxx, (numeric) The total number of transactions with at least 3 inputs and exactly 1 output\n"
1757+
" \"mto_output_count\": xxxxx, (numeric) The total number of outputs spent in all mto_consolidation transactions\n"
17561758
"}\n"
17571759
"\nExamples:\n"
17581760
+ HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
@@ -1847,6 +1849,11 @@ static UniValue getblockstats(const JSONRPCRequest& request)
18471849
int64_t outputs_consolidated = 0;
18481850
int64_t txs_batching = 0;
18491851

1852+
std::vector<CTxDestination> high_consolidation_addrs;
1853+
std::vector<int64_t> cons_in_count;
1854+
int64_t many_to_one_consolidating_txs = 0;
1855+
int64_t many_to_one_consolidated_outputs = 0;
1856+
18501857
// Batch ranges = [(1), (2), (3-4), (5-9), (10-49), (50-99), (100+)]
18511858
constexpr int NUM_OUTCOUNT_BINS = 7;
18521859
int64_t output_count_bins[NUM_OUTCOUNT_BINS] = {0};
@@ -1926,6 +1933,12 @@ static UniValue getblockstats(const JSONRPCRequest& request)
19261933
outputs_consolidated += tx->vin.size();
19271934
}
19281935

1936+
// Look for transactions with high number of inputs and low outputs
1937+
if ((tx->vin.size() >= CONSOLIDATION_THRESHOLD) && tx->vout.size() == 1) {
1938+
++many_to_one_consolidating_txs;
1939+
many_to_one_consolidated_outputs += tx->vin.size();
1940+
}
1941+
19291942
int64_t tx_size = 0;
19301943
if (do_calculate_size) {
19311944

@@ -2108,6 +2121,9 @@ static UniValue getblockstats(const JSONRPCRequest& request)
21082121
}
21092122
ret_all.pushKV("dust_bins", dust_res);
21102123

2124+
ret_all.pushKV("mto_consolidations", many_to_one_consolidating_txs);
2125+
ret_all.pushKV("mto_output_count", many_to_one_consolidated_outputs);
2126+
21112127
if (do_all) {
21122128
return ret_all;
21132129
}
@@ -2120,6 +2136,7 @@ static UniValue getblockstats(const JSONRPCRequest& request)
21202136
}
21212137
ret.pushKV(stat, value);
21222138
}
2139+
21232140
return ret;
21242141
}
21252142

0 commit comments

Comments
 (0)