Skip to main content

Crate brk_computer

Crate brk_computer 

Source
Expand description

§brk_computer

Derived metrics computation engine for Bitcoin on-chain analytics.

§What It Enables

Compute 1000+ on-chain metrics from indexed blockchain data: supply breakdowns, realized/unrealized P&L, SOPR, MVRV, cohort analysis (by age, amount, address type), cointime economics, mining pool attribution, and price-weighted valuations.

§Key Features

  • Cohort metrics: Filter by UTXO age (STH/LTH, age bands), amount ranges, address types
  • Stateful computation: Track per-UTXO cost basis, realized/unrealized states
  • Multi-index support: Metrics available by height, date, week, month, year, decade
  • Price integration: USD-denominated metrics when price data available
  • Mining pool attribution: Tag blocks/rewards to known pools
  • Cointime economics: Liveliness, vaultedness, activity-weighted metrics
  • Incremental updates: Resume from checkpoints, compute only new blocks

§Core API

let mut computer = Computer::forced_import(&outputs_path, &indexer, Some(fetcher))?;

// Compute all metrics for new blocks
computer.compute(&indexer, starting_indexes, &reader, &exit)?;

// Access computed data via traversable vecs
let supply = computer.distribution.utxo_cohorts.all.metrics.supply.total.sats.height;
let realized_cap = computer.distribution.utxo_cohorts.all.metrics.realized.unwrap().realized_cap.height;

§Metric Categories

ModuleExamples
blocksBlock count, interval, size, mining metrics, rewards
transactionsTransaction count, fee, size, volume
scriptsOutput type counts
distributionRealized cap, MVRV, SOPR, unrealized P&L, supply
cointimeLiveliness, vaultedness, true market mean
poolsPer-pool block counts, rewards, fees
marketMarket cap, NVT, Puell multiple
priceHeight-to-price mapping from fetched data

§Cohort System

UTXO and address cohorts support filtering by:

  • Age: STH (<150d), LTH (≥150d), 21 age bands (<1h, 1h-1d, 1d-1w, 1w-1m, 1m-2m, …, 6m-1y, 1y-2y, …, 12y-15y, 15y+)
  • Amount: 0-0.001 BTC, 0.001-0.01, …, 10k+ BTC
  • Type: P2PK, P2PKH, P2MS, P2SH, P2WPKH, P2WSH, P2TR, P2A
  • Epoch: By halving epoch

§Performance

§End-to-End

Full pipeline benchmarks (indexer + computer):

MachineTimeDiskPeak DiskMemoryPeak Memory
MBP M3 Pro (36GB, internal SSD)4.4h345 GB348 GB3.3 GB11 GB
Mac Mini M4 (16GB, external SSD)7h344 GB346 GB4 GB10 GB

Full benchmark data: bitcoinresearchkit/benches

Use mimalloc v3 as the global allocator to reduce memory usage.

§Built On

  • brk_indexer for indexed blockchain data
  • brk_cohort for cohort filtering
  • brk_fetcher for price data
  • brk_reader for raw block access
  • brk_traversable for data export

Modules§

indexes
price

Structs§

Computer