Crates.io | brk_computer |
lib.rs | brk_computer |
version | 0.0.95 |
created_at | 2025-02-23 23:32:22.034672+00 |
updated_at | 2025-08-28 10:46:52.369987+00 |
description | A Bitcoin dataset computer built on top of brk_indexer |
homepage | https://bitcoinresearchkit.org |
repository | https://github.com/bitcoinresearchkit/brk |
max_upload_size | |
id | 1566727 |
size | 898,660 |
Bitcoin analytics engine that transforms indexed blockchain data into comprehensive metrics
brk_computer
is the computational layer of BRK that processes indexed blockchain data to generate analytics across multiple specialized domains. It provides comprehensive Bitcoin metrics with efficient storage and lazy computation for optimal performance.
The computer processes data through a fixed dependency chain:
use brk_computer::Computer;
use brk_indexer::Indexer;
use vecdb::Exit;
// Setup without external price data
let indexer = Indexer::forced_import("./brk_data")?;
let mut computer = Computer::forced_import("./brk_data", &indexer, None)?;
// Setup exit handler
let exit = Exit::new();
exit.set_ctrlc_handler();
// Compute all analytics
let starting_indexes = indexer.get_starting_indexes();
computer.compute(&indexer, starting_indexes, &exit)?;
use brk_fetcher::Fetcher;
// Setup with external price data for market analytics
let fetcher = Some(Fetcher::import(true, None)?);
let mut computer = Computer::forced_import("./brk_data", &indexer, fetcher)?;
// Compute all analytics including price/market domains
computer.compute(&indexer, starting_indexes, &exit)?;
// Access all computed vectors
let all_vecs = computer.vecs(); // Returns Vec<&dyn AnyCollectableVec>
// Access specific domain data
let block_metrics = &computer.blocks;
let mining_data = &computer.mining;
let transaction_stats = &computer.transactions;
// Access price data (if available)
if let Some(price_data) = &computer.price {
// Use OHLC data
}
// Continuous computation loop
loop {
// Get latest indexes from indexer
let current_indexes = indexer.get_current_indexes();
// Compute only new data
computer.compute(&indexer, current_indexes, &exit)?;
// Check for exit signal
if exit.is_signaled() {
break;
}
// Wait before next update
sleep(Duration::from_secs(60));
}
pub struct Computer {
pub indexes: indexes::Vecs, // Time indexing
pub constants: constants::Vecs, // Baseline values
pub blocks: blocks::Vecs, // Block analytics
pub mining: mining::Vecs, // Mining economics
pub market: market::Vecs, // Market metrics (optional)
pub price: Option<price::Vecs>, // OHLC price data (optional)
pub transactions: transactions::Vecs, // Transaction analysis
pub stateful: stateful::Vecs, // UTXO tracking
pub fetched: Option<fetched::Vecs>, // External data (optional)
pub cointime: cointime::Vecs, // Coin age analysis
}
Benchmarked on MacBook Pro M3 Pro:
brk_indexer
outputbrk_indexer
- Source of indexed blockchain databrk_fetcher
- External price data (optional)vecdb
- Vector database with lazy computationrayon
- Parallel processing frameworkbrk_structs
- Bitcoin-aware type systemThis README was generated by Claude Code