diff --git a/crates/brk_indexer/src/processor/tx.rs b/crates/brk_indexer/src/processor/tx.rs index b50592494..4ec0e446c 100644 --- a/crates/brk_indexer/src/processor/tx.rs +++ b/crates/brk_indexer/src/processor/tx.rs @@ -78,8 +78,6 @@ impl<'a> BlockProcessor<'a> { pub fn store_transaction_metadata(&mut self, txs: Vec) -> Result<()> { let height = self.height; - let mut inserted = 0usize; - let mut skipped = 0usize; for ct in txs { if ct.prev_txindex_opt.is_none() { @@ -88,9 +86,6 @@ impl<'a> BlockProcessor<'a> { ct.txindex, height, ); - inserted += 1; - } else { - skipped += 1; } self.vecs @@ -123,11 +118,6 @@ impl<'a> BlockProcessor<'a> { .checked_push(ct.txindex, StoredBool::from(ct.tx.is_explicitly_rbf()))?; } - tracing::debug!( - "store_transaction_metadata: height={}, inserted={}, skipped={}", - height, inserted, skipped - ); - Ok(()) } } diff --git a/website/scripts/chart/colors.js b/website/scripts/chart/colors.js index 2d64a7552..fca4ea708 100644 --- a/website/scripts/chart/colors.js +++ b/website/scripts/chart/colors.js @@ -216,6 +216,22 @@ export const colors = { _200w: fuchsia, _4y: pink, }, + + /** Script type colors (oldest to newest) */ + scriptType: { + p2pk65: red, + p2pk33: orange, + p2pkh: yellow, + p2ms: lime, + p2sh: green, + p2wpkh: teal, + p2wsh: blue, + p2tr: indigo, + p2a: purple, + opreturn: pink, + unknown: violet, + empty: fuchsia, + }, }; /** diff --git a/website/scripts/options/context.js b/website/scripts/options/context.js index 937c001a1..18cba71ec 100644 --- a/website/scripts/options/context.js +++ b/website/scripts/options/context.js @@ -1,15 +1,11 @@ import { fromBaseStatsPattern, fromStatsPattern, - fromSupplyPattern, chartsFromFull, chartsFromSum, - chartsFromCount, - chartsFromValue, chartsFromValueFull, } from "./series.js"; import { colors } from "../chart/colors.js"; -import { Unit } from "../utils/units.js"; /** * @template {(arg: any, ...args: any[]) => any} F @@ -29,18 +25,6 @@ const bind = (fn) => (...args) => fn(colors, ...args) ); -/** - * Create distribution series for btc/sats/usd from a value pattern with stats (average + percentiles) - * @param {FullValuePattern | SumValuePattern} source - * @returns {AnyFetchedSeriesBlueprint[]} - */ -const distributionBtcSatsUsd = (source) => [ - ...fromStatsPattern(colors, { pattern: source.bitcoin, unit: Unit.btc }), - ...fromStatsPattern(colors, { pattern: source.sats, unit: Unit.sats }), - ...fromStatsPattern(colors, { pattern: source.dollars, unit: Unit.usd }), -]; - - /** * Create a context object with all dependencies for building partial options * @param {Object} args @@ -53,13 +37,9 @@ export function createContext({ brk }) { // Series helpers (return series arrays for a single chart) fromBaseStatsPattern: bind(fromBaseStatsPattern), fromStatsPattern: bind(fromStatsPattern), - fromSupplyPattern, - distributionBtcSatsUsd, // Chart helpers (return chart trees for Sum/Distribution/Cumulative folders) chartsFromFull: bind(chartsFromFull), chartsFromSum: bind(chartsFromSum), - chartsFromCount, - chartsFromValue, chartsFromValueFull: bind(chartsFromValueFull), }; } diff --git a/website/scripts/options/mining.js b/website/scripts/options/mining.js index 445f86a1d..8c43b3a98 100644 --- a/website/scripts/options/mining.js +++ b/website/scripts/options/mining.js @@ -3,7 +3,13 @@ import { Unit } from "../utils/units.js"; import { entries, includes } from "../utils/array.js"; import { colorAt } from "../chart/colors.js"; -import { line, baseline, dots, dotted } from "./series.js"; +import { + line, + baseline, + dots, + dotted, + distributionBtcSatsUsd, +} from "./series.js"; import { satsBtcUsd, satsBtcUsdFrom, @@ -47,7 +53,7 @@ const ANTPOOL_AND_FRIENDS_IDS = /** @type {const} */ ([ * @returns {PartialOptionsGroup} */ export function createMiningSection(ctx) { - const { colors, brk, distributionBtcSatsUsd } = ctx; + const { colors, brk } = ctx; const { blocks, transactions, pools } = brk.metrics; // Pre-compute pool entries with resolved names diff --git a/website/scripts/options/network.js b/website/scripts/options/network.js index 6e5f88d3e..7d529cea7 100644 --- a/website/scripts/options/network.js +++ b/website/scripts/options/network.js @@ -1,10 +1,10 @@ /** Network section - On-chain activity and health */ import { Unit } from "../utils/units.js"; +import { includes } from "../utils/array.js"; import { priceLine } from "./constants.js"; -import { line, dots } from "./series.js"; +import { line, dots, fromSupplyPattern } from "./series.js"; import { satsBtcUsd, satsBtcUsdFrom } from "./shared.js"; -import { spendableTypeColors } from "./colors/index.js"; /** * Create Network section @@ -17,7 +17,6 @@ export function createNetworkSection(ctx) { brk, fromBaseStatsPattern, fromStatsPattern, - fromSupplyPattern, chartsFromFull, chartsFromSum, chartsFromValueFull, diff --git a/website/scripts/options/series.js b/website/scripts/options/series.js index 6590a078c..c7ecc7eb9 100644 --- a/website/scripts/options/series.js +++ b/website/scripts/options/series.js @@ -1,5 +1,6 @@ /** Series helpers for creating chart series blueprints */ +import { colors } from "../chart/colors.js"; import { Unit } from "../utils/units.js"; // ============================================================================ @@ -55,13 +56,55 @@ export function price({ function percentileSeries(colors, pattern, unit, title) { const { stat } = colors; return [ - dots({ metric: pattern.max, name: `${title} max`.trim(), color: stat.max, unit, defaultActive: false }), - dots({ metric: pattern.min, name: `${title} min`.trim(), color: stat.min, unit, defaultActive: false }), - dots({ metric: pattern.median, name: `${title} median`.trim(), color: stat.median, unit, defaultActive: false }), - dots({ metric: pattern.pct75, name: `${title} pct75`.trim(), color: stat.pct75, unit, defaultActive: false }), - dots({ metric: pattern.pct25, name: `${title} pct25`.trim(), color: stat.pct25, unit, defaultActive: false }), - dots({ metric: pattern.pct90, name: `${title} pct90`.trim(), color: stat.pct90, unit, defaultActive: false }), - dots({ metric: pattern.pct10, name: `${title} pct10`.trim(), color: stat.pct10, unit, defaultActive: false }), + dots({ + metric: pattern.max, + name: `${title} max`.trim(), + color: stat.max, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.min, + name: `${title} min`.trim(), + color: stat.min, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.median, + name: `${title} median`.trim(), + color: stat.median, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct75, + name: `${title} pct75`.trim(), + color: stat.pct75, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct25, + name: `${title} pct25`.trim(), + color: stat.pct25, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct90, + name: `${title} pct90`.trim(), + color: stat.pct90, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct10, + name: `${title} pct10`.trim(), + color: stat.pct10, + unit, + defaultActive: false, + }), ]; } @@ -278,7 +321,12 @@ export function fromBaseStatsPattern( ) { const { stat } = colors; return [ - dots({ metric: pattern.base, name: title || "base", color: baseColor, unit }), + dots({ + metric: pattern.base, + name: title || "base", + color: baseColor, + unit, + }), dots({ metric: pattern.average, name: `${title} avg`.trim(), @@ -311,6 +359,17 @@ export function fromStatsPattern(colors, { pattern, unit, title = "" }) { ]; } +/** + * Create distribution series for btc/sats/usd from a value pattern with stats (average + percentiles) + * @param {FullValuePattern | SumValuePattern} source + * @returns {AnyFetchedSeriesBlueprint[]} + */ +export const distributionBtcSatsUsd = (source) => [ + ...fromStatsPattern(colors, { pattern: source.bitcoin, unit: Unit.btc }), + ...fromStatsPattern(colors, { pattern: source.sats, unit: Unit.sats }), + ...fromStatsPattern(colors, { pattern: source.dollars, unit: Unit.usd }), +]; + /** * Create series from a SupplyPattern (sats/bitcoin/dollars, no sum/cumulative) * @param {Object} args @@ -358,13 +417,55 @@ function distributionSeries(colors, pattern, unit) { const { stat } = colors; return [ dots({ metric: pattern.average, name: "avg", color: stat.avg, unit }), - dots({ metric: pattern.median, name: "median", color: stat.median, unit, defaultActive: false }), - dots({ metric: pattern.max, name: "max", color: stat.max, unit, defaultActive: false }), - dots({ metric: pattern.min, name: "min", color: stat.min, unit, defaultActive: false }), - dots({ metric: pattern.pct75, name: "pct75", color: stat.pct75, unit, defaultActive: false }), - dots({ metric: pattern.pct25, name: "pct25", color: stat.pct25, unit, defaultActive: false }), - dots({ metric: pattern.pct90, name: "pct90", color: stat.pct90, unit, defaultActive: false }), - dots({ metric: pattern.pct10, name: "pct10", color: stat.pct10, unit, defaultActive: false }), + dots({ + metric: pattern.median, + name: "median", + color: stat.median, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.max, + name: "max", + color: stat.max, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.min, + name: "min", + color: stat.min, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct75, + name: "pct75", + color: stat.pct75, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct25, + name: "pct25", + color: stat.pct25, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct90, + name: "pct90", + color: stat.pct90, + unit, + defaultActive: false, + }), + dots({ + metric: pattern.pct10, + name: "pct10", + color: stat.pct10, + unit, + defaultActive: false, + }), ]; } @@ -379,9 +480,27 @@ function distributionSeries(colors, pattern, unit) { */ function btcSatsUsdSeries({ metrics, name, color, defaultActive }) { return [ - { metric: metrics.bitcoin, title: name, color, unit: Unit.btc, defaultActive }, - { metric: metrics.sats, title: name, color, unit: Unit.sats, defaultActive }, - { metric: metrics.dollars, title: name, color, unit: Unit.usd, defaultActive }, + { + metric: metrics.bitcoin, + title: name, + color, + unit: Unit.btc, + defaultActive, + }, + { + metric: metrics.sats, + title: name, + color, + unit: Unit.sats, + defaultActive, + }, + { + metric: metrics.dollars, + title: name, + color, + unit: Unit.usd, + defaultActive, + }, ]; } @@ -485,7 +604,11 @@ export function chartsFromValue({ pattern, title, color }) { name: "Sum", title, bottom: btcSatsUsdSeries({ - metrics: { bitcoin: pattern.bitcoin.sum, sats: pattern.sats.sum, dollars: pattern.dollars.sum }, + metrics: { + bitcoin: pattern.bitcoin.sum, + sats: pattern.sats.sum, + dollars: pattern.dollars.sum, + }, name: "sum", color, }), @@ -494,7 +617,11 @@ export function chartsFromValue({ pattern, title, color }) { name: "Cumulative", title: `${title} (Total)`, bottom: btcSatsUsdSeries({ - metrics: { bitcoin: pattern.bitcoin.cumulative, sats: pattern.sats.cumulative, dollars: pattern.dollars.cumulative }, + metrics: { + bitcoin: pattern.bitcoin.cumulative, + sats: pattern.sats.cumulative, + dollars: pattern.dollars.cumulative, + }, name: "all-time", color, }), @@ -517,11 +644,19 @@ export function chartsFromValueFull(colors, { pattern, title }) { title, bottom: [ ...btcSatsUsdSeries({ - metrics: { bitcoin: pattern.bitcoin.base, sats: pattern.sats.base, dollars: pattern.dollars.base }, + metrics: { + bitcoin: pattern.bitcoin.base, + sats: pattern.sats.base, + dollars: pattern.dollars.base, + }, name: "sum", }), ...btcSatsUsdSeries({ - metrics: { bitcoin: pattern.bitcoin.sum, sats: pattern.sats.sum, dollars: pattern.dollars.sum }, + metrics: { + bitcoin: pattern.bitcoin.sum, + sats: pattern.sats.sum, + dollars: pattern.dollars.sum, + }, name: "sum", }), ], @@ -539,7 +674,11 @@ export function chartsFromValueFull(colors, { pattern, title }) { name: "Cumulative", title: `${title} (Total)`, bottom: btcSatsUsdSeries({ - metrics: { bitcoin: pattern.bitcoin.cumulative, sats: pattern.sats.cumulative, dollars: pattern.dollars.cumulative }, + metrics: { + bitcoin: pattern.bitcoin.cumulative, + sats: pattern.sats.cumulative, + dollars: pattern.dollars.cumulative, + }, name: "all-time", }), },