mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
1.2 KiB
1.2 KiB
brk_binder
Code generation for BRK client libraries.
What It Enables
Generate typed metric catalogs and constants for JavaScript/TypeScript clients. Keeps frontend code in sync with available metrics without manual maintenance.
Key Features
- Metric catalog: Generates
metrics.jswith all metric IDs and their supported indexes - Compression: Metric names compressed via word-to-base62 mapping for smaller bundles
- Mining pools: Generates
pools.jswith pool ID to name mapping - Version sync: Generates
version.jsmatching server version
Core API
generate_js_files(&query, &modules_path)?;
Generated Files
modules/brk-client/generated/
├── version.js # export const VERSION = "vX.Y.Z"
├── metrics.js # INDEXES, COMPRESSED_METRIC_TO_INDEXES
└── pools.js # POOL_ID_TO_POOL_NAME
Metric Compression
To minimize bundle size, metric names are compressed:
- Extract all words from metric names
- Sort by frequency
- Map to base52 codes (A-Z, a-z)
- Store compressed metric → index group mapping
Built On
brk_queryfor metric enumerationbrk_typesfor mining pool data