mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: readmes
This commit is contained in:
@@ -16,7 +16,7 @@ Track disk usage, memory consumption (current + peak), and I/O throughput during
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let mut bencher = Bencher::from_cargo_env("brk_indexer", &data_path)?;
|
||||
bencher.start()?;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Turn benchmark CSV data into publication-ready SVG charts showing disk usage, me
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let viz = Visualizer::from_cargo_env()?;
|
||||
viz.generate_all_charts()?; // Process all crates in benches/
|
||||
```
|
||||
|
||||
@@ -15,7 +15,7 @@ Generate typed metric catalogs and constants for JavaScript/TypeScript clients.
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
generate_js_files(&query, &modules_path)?;
|
||||
```
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ UTXO and address cohorts support filtering by:
|
||||
- **Type**: P2PKH, P2SH, P2WPKH, P2WSH, P2TR
|
||||
- **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
|
||||
|
||||
- `brk_indexer` for indexed blockchain data
|
||||
|
||||
@@ -18,7 +18,7 @@ Slice the UTXO set and address population by age, amount, output type, halving e
|
||||
|
||||
## Filter Types
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
pub enum Filter {
|
||||
All,
|
||||
Term(Term), // STH/LTH
|
||||
@@ -31,7 +31,7 @@ pub enum Filter {
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let filter = Filter::Time(TimeFilter::GreaterOrEqual(155));
|
||||
|
||||
// Check membership
|
||||
|
||||
@@ -17,7 +17,7 @@ Transform raw Bitcoin blockchain data into indexed vectors and key-value stores
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let mut indexer = Indexer::forced_import(&outputs_dir)?;
|
||||
|
||||
// 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)
|
||||
|
||||
## Recommended: mimalloc v3
|
||||
|
||||
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
|
||||
|
||||
## Built On
|
||||
|
||||
- `brk_iterator` for block iteration
|
||||
|
||||
@@ -15,7 +15,7 @@ Iterate over Bitcoin blocks with a simple API that automatically chooses between
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let blocks = Blocks::new(&rpc_client, &reader);
|
||||
|
||||
// Various range specifications
|
||||
@@ -27,7 +27,7 @@ for block in blocks.after(Some(last_known_hash))? { ... }
|
||||
|
||||
## Source Modes
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
// Auto-select (default)
|
||||
let blocks = Blocks::new(&client, &reader);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Drop-in logging initialization that silences noisy dependencies (bitcoin, fjall,
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
brk_logger::init(Some(Path::new("app.log")))?; // Console + file
|
||||
brk_logger::init(None)?; // Console only
|
||||
|
||||
@@ -26,7 +26,7 @@ brk_logger::register_hook(|msg| {
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
use log::info;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
|
||||
@@ -28,7 +28,7 @@ Expose BRK's query capabilities to AI assistants via the MCP standard. LLMs can
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let mcp = MCP::new(&async_query);
|
||||
|
||||
// The MCP server implements ServerHandler for use with rmcp
|
||||
|
||||
@@ -15,7 +15,7 @@ Instead of rebuilding all projected blocks on every insert/remove:
|
||||
|
||||
### MempoolPackage
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
enum MempoolPackage {
|
||||
/// Tx with no unconfirmed parents - can be mined independently
|
||||
Independent(MempoolEntry),
|
||||
@@ -44,7 +44,7 @@ enum MempoolPackage {
|
||||
|
||||
### ProjectedBlock
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
struct ProjectedBlock {
|
||||
/// Packages sorted by fee rate (highest first)
|
||||
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:
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
fn on_tx_removed(&mut self, txid: Txid) {
|
||||
let pending_to_update: Vec<_> = self.pending
|
||||
.iter()
|
||||
@@ -243,7 +243,7 @@ fn on_tx_removed(&mut self, txid: Txid) {
|
||||
|
||||
### Cascade Down (after insert causes overflow)
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
fn cascade_down(&mut self, starting_block: usize) {
|
||||
let mut block_idx = starting_block;
|
||||
|
||||
@@ -277,7 +277,7 @@ fn cascade_down(&mut self, starting_block: usize) {
|
||||
|
||||
### Cascade Up (after remove causes underflow)
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
fn cascade_up(&mut self, starting_block: usize) {
|
||||
let mut block_idx = starting_block;
|
||||
|
||||
@@ -328,7 +328,7 @@ Need to track:
|
||||
3. `txid → Vec<Txid>` - descendants waiting for this tx (Pending)
|
||||
4. Per-block: sorted packages by fee rate
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
struct MempoolState {
|
||||
/// All packages (Independent, Bundle, or Pending)
|
||||
packages: FxHashMap<Txid, MempoolPackage>,
|
||||
@@ -422,7 +422,7 @@ Their solution: rebuild fast rather than update incrementally.
|
||||
|
||||
### Key Optimization: Ancestor Score
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
ancestor_score = (tx.fee + sum(ancestor.fee)) / (tx.weight + sum(ancestor.weight))
|
||||
```
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Track mempool state, estimate transaction fees via projected block building, and
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let mempool = Mempool::new(&rpc_client);
|
||||
|
||||
// Start background sync loop
|
||||
|
||||
@@ -17,7 +17,7 @@ Query blocks, transactions, addresses, and 1000+ on-chain metrics through a unif
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let query = Query::build(&reader, &indexer, &computer, Some(mempool));
|
||||
|
||||
// Current height
|
||||
@@ -54,7 +54,7 @@ let stats = query.address_stats(&address)?;
|
||||
|
||||
## Async Usage
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let async_query = AsyncQuery::build(&reader, &indexer, &computer, mempool);
|
||||
|
||||
// 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();
|
||||
```
|
||||
|
||||
## Recommended: mimalloc v3
|
||||
|
||||
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
|
||||
|
||||
## Built On
|
||||
|
||||
- `brk_indexer` for raw indexed data
|
||||
|
||||
@@ -17,7 +17,7 @@ Stream blocks directly from Bitcoin Core's `blk*.dat` files with parallel parsin
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let reader = Reader::new(blocks_dir, &rpc_client);
|
||||
|
||||
// Stream blocks from height 800,000 to 850,000
|
||||
|
||||
@@ -17,7 +17,7 @@ Query a Bitcoin Core node for blocks, transactions, mempool data, and chain stat
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let client = Client::new("http://localhost:8332", Auth::CookieFile(cookie_path))?;
|
||||
|
||||
let height = client.get_last_height()?;
|
||||
|
||||
@@ -17,7 +17,7 @@ Serve BRK data via REST API with OpenAPI documentation, response caching, MCP en
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let server = Server::new(&async_query, Some(files_path));
|
||||
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).
|
||||
|
||||
## Recommended: mimalloc v3
|
||||
|
||||
Use [mimalloc v3](https://crates.io/crates/mimalloc) as the global allocator to reduce memory usage.
|
||||
|
||||
## Built On
|
||||
|
||||
- `brk_query` for data access
|
||||
|
||||
@@ -16,7 +16,7 @@ Persist and query Bitcoin index data (address→outputs, txid→height, etc.) wi
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
let store: Store<Txid, Height> = Store::import(
|
||||
&db, &path, "txid_to_height",
|
||||
Version::new(1), Mode::default(), Kind::Random
|
||||
|
||||
@@ -16,7 +16,7 @@ Traverse nested data collections (datasets, grouped metrics) as trees for inspec
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
pub trait Traversable {
|
||||
fn to_tree_node(&self) -> TreeNode;
|
||||
fn iter_any_exportable(&self) -> impl Iterator<Item = &dyn AnyExportableVec>;
|
||||
|
||||
@@ -16,7 +16,7 @@ Automatically generate tree traversal and export iteration for structs, eliminat
|
||||
|
||||
## Core API
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
#[derive(Traversable)]
|
||||
struct MyData {
|
||||
pub metrics: MetricsCollection,
|
||||
|
||||
@@ -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`.
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
use brk_types::{Height, Sats, DateIndex, Date};
|
||||
|
||||
let height = Height::new(840_000);
|
||||
|
||||
Reference in New Issue
Block a user