global: readmes

This commit is contained in:
nym21
2025-12-18 23:05:43 +01:00
parent 9ad3acbdf9
commit 57749da919
19 changed files with 44 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ Track disk usage, memory consumption (current + peak), and I/O throughput during
## Core API ## Core API
```rust ```rust,ignore
let mut bencher = Bencher::from_cargo_env("brk_indexer", &data_path)?; let mut bencher = Bencher::from_cargo_env("brk_indexer", &data_path)?;
bencher.start()?; bencher.start()?;

View File

@@ -16,7 +16,7 @@ Turn benchmark CSV data into publication-ready SVG charts showing disk usage, me
## Core API ## Core API
```rust ```rust,ignore
let viz = Visualizer::from_cargo_env()?; let viz = Visualizer::from_cargo_env()?;
viz.generate_all_charts()?; // Process all crates in benches/ viz.generate_all_charts()?; // Process all crates in benches/
``` ```

View File

@@ -15,7 +15,7 @@ Generate typed metric catalogs and constants for JavaScript/TypeScript clients.
## Core API ## Core API
```rust ```rust,ignore
generate_js_files(&query, &modules_path)?; generate_js_files(&query, &modules_path)?;
``` ```

View File

@@ -48,6 +48,10 @@ UTXO and address cohorts support filtering by:
- **Type**: P2PKH, P2SH, P2WPKH, P2WSH, P2TR - **Type**: P2PKH, P2SH, P2WPKH, P2WSH, P2TR
- **Epoch**: By halving epoch - **Epoch**: By halving epoch
## Recommended: mimalloc v3
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
## Built On ## Built On
- `brk_indexer` for indexed blockchain data - `brk_indexer` for indexed blockchain data

View File

@@ -18,7 +18,7 @@ Slice the UTXO set and address population by age, amount, output type, halving e
## Filter Types ## Filter Types
```rust ```rust,ignore
pub enum Filter { pub enum Filter {
All, All,
Term(Term), // STH/LTH Term(Term), // STH/LTH
@@ -31,7 +31,7 @@ pub enum Filter {
## Core API ## Core API
```rust ```rust,ignore
let filter = Filter::Time(TimeFilter::GreaterOrEqual(155)); let filter = Filter::Time(TimeFilter::GreaterOrEqual(155));
// Check membership // Check membership

View File

@@ -17,7 +17,7 @@ Transform raw Bitcoin blockchain data into indexed vectors and key-value stores
## Core API ## Core API
```rust ```rust,ignore
let mut indexer = Indexer::forced_import(&outputs_dir)?; let mut indexer = Indexer::forced_import(&outputs_dir)?;
// Index new blocks // Index new blocks
@@ -60,6 +60,10 @@ let blockhash = indexer.vecs.block.height_to_blockhash.get(height)?;
Full benchmark data: [`/benches/brk_indexer`](/benches/brk_indexer) Full benchmark data: [`/benches/brk_indexer`](/benches/brk_indexer)
## Recommended: mimalloc v3
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
## Built On ## Built On
- `brk_iterator` for block iteration - `brk_iterator` for block iteration

View File

@@ -15,7 +15,7 @@ Iterate over Bitcoin blocks with a simple API that automatically chooses between
## Core API ## Core API
```rust ```rust,ignore
let blocks = Blocks::new(&rpc_client, &reader); let blocks = Blocks::new(&rpc_client, &reader);
// Various range specifications // Various range specifications
@@ -27,7 +27,7 @@ for block in blocks.after(Some(last_known_hash))? { ... }
## Source Modes ## Source Modes
```rust ```rust,ignore
// Auto-select (default) // Auto-select (default)
let blocks = Blocks::new(&client, &reader); let blocks = Blocks::new(&client, &reader);

View File

@@ -15,7 +15,7 @@ Drop-in logging initialization that silences noisy dependencies (bitcoin, fjall,
## Core API ## Core API
```rust ```rust,ignore
brk_logger::init(Some(Path::new("app.log")))?; // Console + file brk_logger::init(Some(Path::new("app.log")))?; // Console + file
brk_logger::init(None)?; // Console only brk_logger::init(None)?; // Console only
@@ -26,7 +26,7 @@ brk_logger::register_hook(|msg| {
## Usage ## Usage
```rust ```rust,ignore
use log::info; use log::info;
fn main() -> std::io::Result<()> { fn main() -> std::io::Result<()> {

View File

@@ -28,7 +28,7 @@ Expose BRK's query capabilities to AI assistants via the MCP standard. LLMs can
## Usage ## Usage
```rust ```rust,ignore
let mcp = MCP::new(&async_query); let mcp = MCP::new(&async_query);
// The MCP server implements ServerHandler for use with rmcp // The MCP server implements ServerHandler for use with rmcp

View File

@@ -15,7 +15,7 @@ Instead of rebuilding all projected blocks on every insert/remove:
### MempoolPackage ### MempoolPackage
```rust ```rust,ignore
enum MempoolPackage { enum MempoolPackage {
/// Tx with no unconfirmed parents - can be mined independently /// Tx with no unconfirmed parents - can be mined independently
Independent(MempoolEntry), Independent(MempoolEntry),
@@ -44,7 +44,7 @@ enum MempoolPackage {
### ProjectedBlock ### ProjectedBlock
```rust ```rust,ignore
struct ProjectedBlock { struct ProjectedBlock {
/// Packages sorted by fee rate (highest first) /// Packages sorted by fee rate (highest first)
packages: Vec<MempoolPackage>, packages: Vec<MempoolPackage>,
@@ -218,7 +218,7 @@ New tx A' replaces A (same inputs, higher fee)
When a tx is removed (confirmed), check all `Pending` entries: When a tx is removed (confirmed), check all `Pending` entries:
```rust ```rust,ignore
fn on_tx_removed(&mut self, txid: Txid) { fn on_tx_removed(&mut self, txid: Txid) {
let pending_to_update: Vec<_> = self.pending let pending_to_update: Vec<_> = self.pending
.iter() .iter()
@@ -243,7 +243,7 @@ fn on_tx_removed(&mut self, txid: Txid) {
### Cascade Down (after insert causes overflow) ### Cascade Down (after insert causes overflow)
```rust ```rust,ignore
fn cascade_down(&mut self, starting_block: usize) { fn cascade_down(&mut self, starting_block: usize) {
let mut block_idx = starting_block; let mut block_idx = starting_block;
@@ -277,7 +277,7 @@ fn cascade_down(&mut self, starting_block: usize) {
### Cascade Up (after remove causes underflow) ### Cascade Up (after remove causes underflow)
```rust ```rust,ignore
fn cascade_up(&mut self, starting_block: usize) { fn cascade_up(&mut self, starting_block: usize) {
let mut block_idx = starting_block; let mut block_idx = starting_block;
@@ -328,7 +328,7 @@ Need to track:
3. `txid → Vec<Txid>` - descendants waiting for this tx (Pending) 3. `txid → Vec<Txid>` - descendants waiting for this tx (Pending)
4. Per-block: sorted packages by fee rate 4. Per-block: sorted packages by fee rate
```rust ```rust,ignore
struct MempoolState { struct MempoolState {
/// All packages (Independent, Bundle, or Pending) /// All packages (Independent, Bundle, or Pending)
packages: FxHashMap<Txid, MempoolPackage>, packages: FxHashMap<Txid, MempoolPackage>,
@@ -422,7 +422,7 @@ Their solution: rebuild fast rather than update incrementally.
### Key Optimization: Ancestor Score ### Key Optimization: Ancestor Score
```rust ```rust,ignore
ancestor_score = (tx.fee + sum(ancestor.fee)) / (tx.weight + sum(ancestor.weight)) ancestor_score = (tx.fee + sum(ancestor.fee)) / (tx.weight + sum(ancestor.weight))
``` ```

View File

@@ -16,7 +16,7 @@ Track mempool state, estimate transaction fees via projected block building, and
## Core API ## Core API
```rust ```rust,ignore
let mempool = Mempool::new(&rpc_client); let mempool = Mempool::new(&rpc_client);
// Start background sync loop // Start background sync loop

View File

@@ -17,7 +17,7 @@ Query blocks, transactions, addresses, and 1000+ on-chain metrics through a unif
## Core API ## Core API
```rust ```rust,ignore
let query = Query::build(&reader, &indexer, &computer, Some(mempool)); let query = Query::build(&reader, &indexer, &computer, Some(mempool));
// Current height // Current height
@@ -54,7 +54,7 @@ let stats = query.address_stats(&address)?;
## Async Usage ## Async Usage
```rust ```rust,ignore
let async_query = AsyncQuery::build(&reader, &indexer, &computer, mempool); let async_query = AsyncQuery::build(&reader, &indexer, &computer, mempool);
// Run blocking queries in thread pool // Run blocking queries in thread pool
@@ -64,6 +64,10 @@ let result = async_query.run(|q| q.block_info(height)).await;
let height = async_query.inner().height(); let height = async_query.inner().height();
``` ```
## Recommended: mimalloc v3
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
## Built On ## Built On
- `brk_indexer` for raw indexed data - `brk_indexer` for raw indexed data

View File

@@ -17,7 +17,7 @@ Stream blocks directly from Bitcoin Core's `blk*.dat` files with parallel parsin
## Core API ## Core API
```rust ```rust,ignore
let reader = Reader::new(blocks_dir, &rpc_client); let reader = Reader::new(blocks_dir, &rpc_client);
// Stream blocks from height 800,000 to 850,000 // Stream blocks from height 800,000 to 850,000

View File

@@ -17,7 +17,7 @@ Query a Bitcoin Core node for blocks, transactions, mempool data, and chain stat
## Core API ## Core API
```rust ```rust,ignore
let client = Client::new("http://localhost:8332", Auth::CookieFile(cookie_path))?; let client = Client::new("http://localhost:8332", Auth::CookieFile(cookie_path))?;
let height = client.get_last_height()?; let height = client.get_last_height()?;

View File

@@ -17,7 +17,7 @@ Serve BRK data via REST API with OpenAPI documentation, response caching, MCP en
## Core API ## Core API
```rust ```rust,ignore
let server = Server::new(&async_query, Some(files_path)); let server = Server::new(&async_query, Some(files_path));
server.serve(true).await?; // true enables MCP endpoint server.serve(true).await?; // true enables MCP endpoint
``` ```
@@ -45,6 +45,10 @@ Uses ETag-based caching with stale-while-revalidate semantics:
Server binds to port 3110 by default, auto-incrementing if busy (up to 3210). Server binds to port 3110 by default, auto-incrementing if busy (up to 3210).
## Recommended: mimalloc v3
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
## Built On ## Built On
- `brk_query` for data access - `brk_query` for data access

View File

@@ -16,7 +16,7 @@ Persist and query Bitcoin index data (address→outputs, txid→height, etc.) wi
## Core API ## Core API
```rust ```rust,ignore
let store: Store<Txid, Height> = Store::import( let store: Store<Txid, Height> = Store::import(
&db, &path, "txid_to_height", &db, &path, "txid_to_height",
Version::new(1), Mode::default(), Kind::Random Version::new(1), Mode::default(), Kind::Random

View File

@@ -16,7 +16,7 @@ Traverse nested data collections (datasets, grouped metrics) as trees for inspec
## Core API ## Core API
```rust ```rust,ignore
pub trait Traversable { pub trait Traversable {
fn to_tree_node(&self) -> TreeNode; fn to_tree_node(&self) -> TreeNode;
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec>; fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec>;

View File

@@ -16,7 +16,7 @@ Automatically generate tree traversal and export iteration for structs, eliminat
## Core API ## Core API
```rust ```rust,ignore
#[derive(Traversable)] #[derive(Traversable)]
struct MyData { struct MyData {
pub metrics: MetricsCollection, pub metrics: MetricsCollection,

View File

@@ -32,7 +32,7 @@ Work with Bitcoin primitives (heights, satoshis, addresses, transactions) throug
All types implement standard traits: `Debug`, `Clone`, `Serialize`, `Deserialize`, plus domain-specific operations like `CheckedSub`, `Formattable`, and `PrintableIndex`. All types implement standard traits: `Debug`, `Clone`, `Serialize`, `Deserialize`, plus domain-specific operations like `CheckedSub`, `Formattable`, and `PrintableIndex`.
```rust ```rust,ignore
use brk_types::{Height, Sats, DateIndex, Date}; use brk_types::{Height, Sats, DateIndex, Date};
let height = Height::new(840_000); let height = Height::new(840_000);