mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-24 08:44:46 -07:00
global: big snapshot
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
chartsFromFullPerBlock,
|
||||
chartsFromCount,
|
||||
chartsFromCountEntries,
|
||||
chartsFromPercentCumulative,
|
||||
chartsFromAggregatedPerBlock,
|
||||
averagesArray,
|
||||
simpleDeltaTree,
|
||||
@@ -109,6 +110,18 @@ export function createNetworkSection() {
|
||||
/** @param {AddressableType} t */
|
||||
getSeries: (t) => addrs.total[t],
|
||||
},
|
||||
{
|
||||
name: "Funded Reused",
|
||||
title: "Funded Reused Address Count by Type",
|
||||
/** @param {AddressableType} t */
|
||||
getSeries: (t) => addrs.reused.funded[t],
|
||||
},
|
||||
{
|
||||
name: "Total Reused",
|
||||
title: "Total Reused Address Count by Type",
|
||||
/** @param {AddressableType} t */
|
||||
getSeries: (t) => addrs.reused.total[t],
|
||||
},
|
||||
]);
|
||||
|
||||
const countMetrics = /** @type {const} */ ([
|
||||
@@ -152,6 +165,51 @@ export function createNetworkSection() {
|
||||
})),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Reused",
|
||||
tree: [
|
||||
{
|
||||
name: "Compare",
|
||||
title: title("Reused Address Count"),
|
||||
bottom: [
|
||||
line({
|
||||
series: addrs.reused.funded[key],
|
||||
name: "Funded",
|
||||
unit: Unit.count,
|
||||
}),
|
||||
line({
|
||||
series: addrs.reused.total[key],
|
||||
name: "Total",
|
||||
color: colors.gray,
|
||||
unit: Unit.count,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Funded",
|
||||
title: title("Funded Reused Addresses"),
|
||||
bottom: [
|
||||
line({
|
||||
series: addrs.reused.funded[key],
|
||||
name: "Funded Reused",
|
||||
unit: Unit.count,
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Total",
|
||||
title: title("Total Reused Addresses"),
|
||||
bottom: [
|
||||
line({
|
||||
series: addrs.reused.total[key],
|
||||
name: "Total Reused",
|
||||
color: colors.gray,
|
||||
unit: Unit.count,
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
...simpleDeltaTree({
|
||||
delta: addrs.delta[key],
|
||||
title,
|
||||
@@ -213,6 +271,103 @@ export function createNetworkSection() {
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* @param {string} direction
|
||||
* @param {{ byType: Record<AddressableType, CountPattern<number>>, percent: Record<AddressableType, PercentRatioCumulativePattern> }} source
|
||||
*/
|
||||
const createTxTypeGroup = (direction, source) => {
|
||||
const lowerDir = direction.toLowerCase();
|
||||
return {
|
||||
name: `By ${direction} Type`,
|
||||
tree: [
|
||||
{
|
||||
name: "Count Compare",
|
||||
tree: [
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `${w.title} Transactions by ${direction} Type`,
|
||||
bottom: addressTypes.map((t) =>
|
||||
line({
|
||||
series: source.byType[t.key].sum[w.key],
|
||||
name: t.name,
|
||||
color: t.color,
|
||||
unit: Unit.count,
|
||||
defaultActive: t.defaultActive,
|
||||
}),
|
||||
),
|
||||
})),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `Cumulative Transactions by ${direction} Type`,
|
||||
bottom: addressTypes.map((t) =>
|
||||
line({
|
||||
series: source.byType[t.key].cumulative,
|
||||
name: t.name,
|
||||
color: t.color,
|
||||
unit: Unit.count,
|
||||
defaultActive: t.defaultActive,
|
||||
}),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "% Compare",
|
||||
tree: [
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: `${w.title} Share of Transactions by ${direction} Type`,
|
||||
bottom: addressTypes.map((t) =>
|
||||
line({
|
||||
series: source.percent[t.key][w.key].percent,
|
||||
name: t.name,
|
||||
color: t.color,
|
||||
unit: Unit.percentage,
|
||||
defaultActive: t.defaultActive,
|
||||
}),
|
||||
),
|
||||
})),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: `Cumulative Share of Transactions by ${direction} Type`,
|
||||
bottom: addressTypes.map((t) =>
|
||||
line({
|
||||
series: source.percent[t.key].cumulative.percent,
|
||||
name: t.name,
|
||||
color: t.color,
|
||||
unit: Unit.percentage,
|
||||
defaultActive: t.defaultActive,
|
||||
}),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
...addressTypes.map((t) => ({
|
||||
name: t.name,
|
||||
tree: [
|
||||
{
|
||||
name: "Count",
|
||||
tree: chartsFromCount({
|
||||
pattern: source.byType[t.key],
|
||||
metric: `Transactions with ${t.name} ${lowerDir}`,
|
||||
unit: Unit.count,
|
||||
color: t.color,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "% of All",
|
||||
tree: chartsFromPercentCumulative({
|
||||
pattern: source.percent[t.key],
|
||||
metric: `Share of Transactions with ${t.name} ${lowerDir}`,
|
||||
color: t.color,
|
||||
}),
|
||||
},
|
||||
],
|
||||
})),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @template {keyof typeof scripts.count} K
|
||||
* @param {string} groupName
|
||||
@@ -335,10 +490,10 @@ export function createNetworkSection() {
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "Fee Rate",
|
||||
name: "Effective Fee Rate",
|
||||
tree: chartsFromBlockAnd6b({
|
||||
pattern: transactions.fees.feeRate,
|
||||
metric: "Transaction Fee Rate",
|
||||
pattern: transactions.fees.effectiveFeeRate,
|
||||
metric: "Effective Transaction Fee Rate",
|
||||
unit: Unit.feeRate,
|
||||
}),
|
||||
},
|
||||
@@ -374,6 +529,8 @@ export function createNetworkSection() {
|
||||
unit: Unit.count,
|
||||
}),
|
||||
},
|
||||
createTxTypeGroup("Input", transactions.inputTypes),
|
||||
createTxTypeGroup("Output", transactions.outputTypes),
|
||||
{
|
||||
name: "Velocity",
|
||||
title: "Transaction Velocity",
|
||||
|
||||
@@ -1099,6 +1099,60 @@ export function chartsFromCount({ pattern, title = (s) => s, metric, unit, color
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent + ratio per rolling window + cumulative — mirrors chartsFromCount for percent data.
|
||||
* @param {Object} args
|
||||
* @param {PercentRatioCumulativePattern} args.pattern
|
||||
* @param {(metric: string) => string} [args.title]
|
||||
* @param {string} args.metric
|
||||
* @param {Color} [args.color]
|
||||
* @returns {PartialOptionsTree}
|
||||
*/
|
||||
export function chartsFromPercentCumulative({
|
||||
pattern,
|
||||
title = (s) => s,
|
||||
metric,
|
||||
color,
|
||||
}) {
|
||||
return [
|
||||
{
|
||||
name: "Compare",
|
||||
title: title(metric),
|
||||
bottom: ROLLING_WINDOWS.flatMap((w) =>
|
||||
percentRatio({
|
||||
pattern: pattern[w.key],
|
||||
name: w.name,
|
||||
color: w.color,
|
||||
}),
|
||||
).concat(
|
||||
percentRatio({
|
||||
pattern: pattern.cumulative,
|
||||
name: "All Time",
|
||||
color: colors.time.all,
|
||||
}),
|
||||
),
|
||||
},
|
||||
...ROLLING_WINDOWS.map((w) => ({
|
||||
name: w.name,
|
||||
title: title(`${w.title} ${metric}`),
|
||||
bottom: percentRatio({
|
||||
pattern: pattern[w.key],
|
||||
name: w.name,
|
||||
color: color ?? w.color,
|
||||
}),
|
||||
})),
|
||||
{
|
||||
name: "Cumulative",
|
||||
title: title(`Cumulative ${metric}`),
|
||||
bottom: percentRatio({
|
||||
pattern: pattern.cumulative,
|
||||
name: "All Time",
|
||||
color: color ?? colors.time.all,
|
||||
}),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Windowed sums + cumulative for multiple named entries (e.g. transaction versions)
|
||||
* @param {Object} args
|
||||
|
||||
Reference in New Issue
Block a user