global: wip

This commit is contained in:
nym21
2025-06-06 12:23:45 +02:00
parent 1921c3d901
commit a11bf5523b
134 changed files with 333 additions and 708 deletions

22
.gitignore vendored
View File

@@ -14,27 +14,5 @@ _*
.vscode .vscode
.zed .zed
# Flamegraph
flamegraph/
flamegraph.svg
# Benchmarks
benches
# Snapshots
snapshots*/
# Docker
docker/kibo
# Types
paths.d.ts
# Outputs
_outputs
# Logs # Logs
.log .log
# Cloudflare
cloudflared

View File

@@ -5,6 +5,7 @@ package.description = "The Bitcoin Research Kit is a suite of tools designed to
package.license = "MIT" package.license = "MIT"
package.edition = "2024" package.edition = "2024"
package.version = "0.0.40" package.version = "0.0.40"
package.homepage = "https://bitcoinresearchkit.org"
package.repository = "https://github.com/bitcoinresearchkit/brk" package.repository = "https://github.com/bitcoinresearchkit/brk"
[profile.release] [profile.release]

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2025 bitcoinresearchkit, kibo.money Copyright (c) 2025 bitcoinresearchkit, kibo.money, satonomics
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -3,6 +3,7 @@ name = "brk"
description.workspace = true description.workspace = true
license.workspace = true license.workspace = true
readme.workspace = true readme.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
edition.workspace = true edition.workspace = true
version.workspace = true version.workspace = true

View File

@@ -4,6 +4,7 @@ description = "A command line interface to interact with the full Bitcoin Resear
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -144,7 +144,7 @@ pub struct RunConfig {
#[arg(short = 'F', long, value_name = "BOOL")] #[arg(short = 'F', long, value_name = "BOOL")]
fetch: Option<bool>, fetch: Option<bool>,
/// Website served by the server (if active), default: kibo.money, saved /// Website served by the server (if active), default: default, saved
#[arg(short, long)] #[arg(short, long)]
website: Option<Website>, website: Option<Website>,
@@ -418,7 +418,7 @@ impl RunConfig {
} }
pub fn website(&self) -> Website { pub fn website(&self) -> Website {
self.website.unwrap_or(Website::KiboMoney) self.website.unwrap_or(Website::Default)
} }
pub fn fetch(&self) -> bool { pub fn fetch(&self) -> bool {

View File

@@ -4,6 +4,7 @@ description = "A Bitcoin dataset computer, built on top of brk_indexer"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -18,6 +18,7 @@ pub mod stateful;
pub mod transactions; pub mod transactions;
pub use indexes::Indexes; pub use indexes::Indexes;
use log::info;
const VERSION: Version = Version::ONE; const VERSION: Version = Version::ONE;
@@ -119,16 +120,20 @@ impl Vecs {
) -> color_eyre::Result<()> { ) -> color_eyre::Result<()> {
let starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?; let starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?;
info!("Computing constants...");
self.constants self.constants
.compute(indexer, &self.indexes, &starting_indexes, exit)?; .compute(indexer, &self.indexes, &starting_indexes, exit)?;
info!("Computing blocks...");
self.blocks self.blocks
.compute(indexer, &self.indexes, &starting_indexes, exit)?; .compute(indexer, &self.indexes, &starting_indexes, exit)?;
info!("Computing mining...");
self.mining self.mining
.compute(indexer, &self.indexes, &starting_indexes, exit)?; .compute(indexer, &self.indexes, &starting_indexes, exit)?;
if let Some(fetched) = self.fetched.as_mut() { if let Some(fetched) = self.fetched.as_mut() {
info!("Computing fetched...");
fetched.compute( fetched.compute(
indexer, indexer,
&self.indexes, &self.indexes,
@@ -138,6 +143,7 @@ impl Vecs {
)?; )?;
} }
info!("Computing transactions...");
self.transactions.compute( self.transactions.compute(
indexer, indexer,
&self.indexes, &self.indexes,
@@ -147,6 +153,7 @@ impl Vecs {
)?; )?;
if let Some(fetched) = self.fetched.as_ref() { if let Some(fetched) = self.fetched.as_ref() {
info!("Computing market...");
self.market.compute( self.market.compute(
indexer, indexer,
&self.indexes, &self.indexes,
@@ -157,6 +164,7 @@ impl Vecs {
)?; )?;
} }
info!("Computing stateful...");
self.stateful.compute( self.stateful.compute(
indexer, indexer,
&self.indexes, &self.indexes,

View File

@@ -895,21 +895,17 @@ impl Vecs {
path, path,
&suffix("coinblocks_destroyed"), &suffix("coinblocks_destroyed"),
true, true,
version + VERSION + Version::ZERO, version + VERSION + Version::ONE,
format, format,
StorableVecGeneatorOptions::default() StorableVecGeneatorOptions::default().add_sum(),
.add_sum()
.add_cumulative(),
)?, )?,
indexes_to_coindays_destroyed: ComputedVecsFromHeight::forced_import( indexes_to_coindays_destroyed: ComputedVecsFromHeight::forced_import(
path, path,
&suffix("coindays_destroyed"), &suffix("coindays_destroyed"),
true, true,
version + VERSION + Version::ZERO, version + VERSION + Version::ONE,
format, format,
StorableVecGeneatorOptions::default() StorableVecGeneatorOptions::default().add_sum(),
.add_sum()
.add_cumulative(),
)?, )?,
}) })
} }

View File

@@ -1388,7 +1388,7 @@ impl Vecs {
+ dateindex_to_height_count.version(); + dateindex_to_height_count.version();
separate_utxo_vecs separate_utxo_vecs
.iter_mut() .par_iter_mut()
.try_for_each(|(_, v)| v.validate_computed_versions(base_version))?; .try_for_each(|(_, v)| v.validate_computed_versions(base_version))?;
self.height_to_unspendable_supply self.height_to_unspendable_supply
.validate_computed_version_or_reset_file( .validate_computed_version_or_reset_file(
@@ -1403,7 +1403,7 @@ impl Vecs {
let mut chain_state_starting_height = Height::from(self.chain_state.len()); let mut chain_state_starting_height = Height::from(self.chain_state.len());
let stateful_starting_height = match separate_utxo_vecs let stateful_starting_height = match separate_utxo_vecs
.iter_mut() .par_iter_mut()
.map(|(_, v)| v.starting_height()) .map(|(_, v)| v.starting_height())
.min() .min()
.unwrap_or_default() .unwrap_or_default()
@@ -1442,7 +1442,7 @@ impl Vecs {
if stateful_starting_height.is_zero() { if stateful_starting_height.is_zero() {
info!("Starting processing utxos from the start"); info!("Starting processing utxos from the start");
separate_utxo_vecs separate_utxo_vecs
.iter_mut() .par_iter_mut()
.try_for_each(|(_, v)| v.state.price_to_amount.reset_partition())?; .try_for_each(|(_, v)| v.state.price_to_amount.reset_partition())?;
} }
let starting_height = starting_indexes let starting_height = starting_indexes
@@ -1451,12 +1451,16 @@ impl Vecs {
.min(Height::from(self.height_to_unspendable_supply.len())) .min(Height::from(self.height_to_unspendable_supply.len()))
.min(Height::from(self.height_to_opreturn_supply.len())); .min(Height::from(self.height_to_opreturn_supply.len()));
if starting_height == Height::from(height_to_date_fixed.len()) {
return Ok(());
}
// --- // ---
// INIT // INIT
// --- // ---
separate_utxo_vecs separate_utxo_vecs
.iter_mut() .par_iter_mut()
.for_each(|(_, v)| v.init(starting_height)); .for_each(|(_, v)| v.init(starting_height));
let mut unspendable_supply = if let Some(prev_height) = starting_height.decremented() { let mut unspendable_supply = if let Some(prev_height) = starting_height.decremented() {
@@ -1703,10 +1707,12 @@ impl Vecs {
self.flush_states(height, &chain_state, exit)?; self.flush_states(height, &chain_state, exit)?;
info!("Computing overlaping...");
self.utxos_vecs self.utxos_vecs
.compute_overlaping_vecs(&starting_indexes, exit)?; .compute_overlaping_vecs(&starting_indexes, exit)?;
info!("Computing rest..."); info!("Computing rest part 1...");
self.utxos_vecs self.utxos_vecs
.as_mut_vecs() .as_mut_vecs()
@@ -1714,6 +1720,9 @@ impl Vecs {
.try_for_each(|(_, v)| { .try_for_each(|(_, v)| {
v.compute_rest_part1(indexer, indexes, fetched, &starting_indexes, exit) v.compute_rest_part1(indexer, indexes, fetched, &starting_indexes, exit)
})?; })?;
info!("Computing rest part 2...");
let height_to_supply = self.utxos_vecs.all.1.height_to_supply_value.bitcoin.clone(); let height_to_supply = self.utxos_vecs.all.1.height_to_supply_value.bitcoin.clone();
let dateindex_to_supply = self let dateindex_to_supply = self
.utxos_vecs .utxos_vecs
@@ -1724,6 +1733,7 @@ impl Vecs {
.dateindex .dateindex
.clone(); .clone();
let height_to_realized_cap = self.utxos_vecs.all.1.height_to_realized_cap.clone(); let height_to_realized_cap = self.utxos_vecs.all.1.height_to_realized_cap.clone();
self.utxos_vecs self.utxos_vecs
.as_mut_vecs() .as_mut_vecs()
.par_iter_mut() .par_iter_mut()

View File

@@ -4,6 +4,7 @@ description = "The Core (Structs and Errors) of the Bitcoin Research Kit"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -4,6 +4,7 @@ description = "An exit blocker built on top of ctrlc"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -4,6 +4,7 @@ description = "A Bitcoin price fetcher"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>
@@ -34,4 +31,4 @@
</a> </a>
</p> </p>
A crate that can fetch the Bitcoin price, either by date or height, from multiple APIs such Kraken, Binance and Kibo.money. A crate that can fetch the Bitcoin price, either by date or height, from Binance and Kibo.

View File

@@ -1,9 +1,9 @@
mod binance; mod binance;
mod kibo; // mod kibo;
// mod kraken; // mod kraken;
mod retry; mod retry;
pub use binance::*; pub use binance::*;
pub use kibo::*; // pub use kibo::*;
// pub use kraken::*; // pub use kraken::*;
use retry::*; use retry::*;

View File

@@ -5,7 +5,7 @@
use std::{collections::BTreeMap, fs, path::Path, thread::sleep, time::Duration}; use std::{collections::BTreeMap, fs, path::Path, thread::sleep, time::Duration};
use brk_core::{Cents, Close, Date, Dollars, Height, High, Low, OHLCCents, Open, Timestamp}; use brk_core::{Close, Date, Dollars, Height, High, Low, OHLCCents, Open, Timestamp};
use color_eyre::eyre::Error; use color_eyre::eyre::Error;
mod fetchers; mod fetchers;
@@ -19,7 +19,7 @@ const TRIES: usize = 12 * 60 * 2;
pub struct Fetcher { pub struct Fetcher {
binance: Binance, binance: Binance,
// kraken: Kraken, // kraken: Kraken,
kibo: Kibo, // kibo: Kibo,
} }
impl Fetcher { impl Fetcher {
@@ -31,7 +31,7 @@ impl Fetcher {
Ok(Self { Ok(Self {
binance: Binance::init(hars_path), binance: Binance::init(hars_path),
// kraken: Kraken::default(), // kraken: Kraken::default(),
kibo: Kibo::default(), // kibo: Kibo::default(),
}) })
} }
@@ -42,10 +42,10 @@ impl Fetcher {
fn get_date_(&mut self, date: Date, tries: usize) -> color_eyre::Result<OHLCCents> { fn get_date_(&mut self, date: Date, tries: usize) -> color_eyre::Result<OHLCCents> {
self.binance self.binance
.get_from_1d(&date) .get_from_1d(&date)
.or_else(|_| { // .or_else(|_| {
// eprintln!("{e}"); // // eprintln!("{e}");
self.kibo.get_from_date(&date) // self.kibo.get_from_date(&date)
}) // })
.or_else(|e| { .or_else(|e| {
sleep(Duration::from_secs(30)); sleep(Duration::from_secs(30));
@@ -93,28 +93,28 @@ impl Fetcher {
// .get_from_1mn(timestamp, previous_timestamp) // .get_from_1mn(timestamp, previous_timestamp)
// .unwrap_or_else(|_report| { // .unwrap_or_else(|_report| {
// // eprintln!("{_report}"); // // eprintln!("{_report}");
self.kibo.get_from_height(height).unwrap_or_else(|_report| { // self.kibo.get_from_height(height).unwrap_or_else(|_report| {
// eprintln!("{_report}"); // eprintln!("{_report}");
sleep(Duration::from_secs(30)); sleep(Duration::from_secs(30));
if tries < TRIES { if tries < TRIES {
self.clear(); self.clear();
info!("Retrying to fetch height prices..."); info!("Retrying to fetch height prices...");
// dbg!((height, timestamp, previous_timestamp)); // dbg!((height, timestamp, previous_timestamp));
return self return self
.get_height_(height, timestamp, previous_timestamp, tries + 1) .get_height_(height, timestamp, previous_timestamp, tries + 1)
.unwrap(); .unwrap();
} }
info!("Failed to fetch height prices"); info!("Failed to fetch height prices");
let date = Date::from(timestamp); let date = Date::from(timestamp);
// eprintln!("{e}"); // eprintln!("{e}");
panic!( panic!(
" "
Can't find the price for: height: {height} - date: {date} Can't find the price for: height: {height} - date: {date}
1mn APIs are limited to the last 16 hours for Binance's and the last 10 hours for Kraken's 1mn APIs are limited to the last 16 hours for Binance's and the last 10 hours for Kraken's
How to fix this: How to fix this:
@@ -129,8 +129,8 @@ How to fix this:
8. Export to a har file (if there is no explicit button, click on the cog button) 8. Export to a har file (if there is no explicit button, click on the cog button)
9. Move the file to 'parser/imports/binance.har' 9. Move the file to 'parser/imports/binance.har'
" "
) )
}) // })
// }) // })
}); });
@@ -181,7 +181,7 @@ How to fix this:
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.binance.clear(); self.binance.clear();
self.kibo.clear(); // self.kibo.clear();
// self.kraken.clear(); // self.kraken.clear();
} }
} }

View File

@@ -4,6 +4,7 @@ description = "A Bitcoin Core indexer built on top of brk_parser"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -4,6 +4,7 @@ description = "A clean logger used in the Bitcoin Research Kit"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -6,6 +6,7 @@ categories = ["cryptography::cryptocurrencies", "encoding"]
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -4,6 +4,7 @@ description = "A library that finds requested datasets"
license.workspace = true license.workspace = true
edition.workspace = true edition.workspace = true
version.workspace = true version.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -4,6 +4,7 @@ description = "A crate that serves Bitcoin data and swappable front-ends, built
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>
@@ -36,7 +33,7 @@
A crate that serves Bitcoin data and swappable front-ends, built on top of `brk_indexer`, `brk_computer` and `brk_query`. A crate that serves Bitcoin data and swappable front-ends, built on top of `brk_indexer`, `brk_computer` and `brk_query`.
The file handler, will serve the website specified by the user if any, which can be *no website*, *kibo.money* or *custom* (which is a blank folder for people to experiment). If a website is specified and the server is ran outside of the brk project and thus can't find the requested website, it will download the whole project with the correct version from Github and store it in `.brk` to be able to serve to website. This is due to the crate size limit on [crates.io](https://crates.io) and the various shenanigans that need to be done to have a website in a crate. The file handler, will serve the website specified by the user if any, which can be *no website*, *default* or *custom* (which is a blank folder for people to experiment). If a website is specified and the server is ran outside of the brk project and thus can't find the requested website, it will download the whole project with the correct version from Github and store it in `.brk` to be able to serve to website. This is due to the crate size limit on [crates.io](https://crates.io) and the various shenanigans that need to be done to have a website in a crate.
The API uses `brk_query` and so inherites all of its features including formats. The API uses `brk_query` and so inherites all of its features including formats.

View File

@@ -48,7 +48,7 @@ pub fn main() -> color_eyre::Result<()> {
let served_indexer = indexer.clone(); let served_indexer = indexer.clone();
let served_computer = computer.clone(); let served_computer = computer.clone();
let server = Server::new(served_indexer, served_computer, Website::KiboMoney)?; let server = Server::new(served_indexer, served_computer, Website::Default)?;
let server = tokio::spawn(async move { let server = tokio::spawn(async move {
server.serve().await.unwrap(); server.serve().await.unwrap();

View File

@@ -1,14 +1,10 @@
use clap_derive::ValueEnum; use clap_derive::ValueEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive( #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, ValueEnum)]
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, ValueEnum,
)]
pub enum Website { pub enum Website {
#[default]
None, None,
#[value(name = "kibo.money")] Default,
KiboMoney,
Custom, Custom,
} }
@@ -24,7 +20,7 @@ impl Website {
pub fn to_folder_name(&self) -> &str { pub fn to_folder_name(&self) -> &str {
match self { match self {
Self::Custom => "custom", Self::Custom => "custom",
Self::KiboMoney => "kibo.money", Self::Default => "default",
Self::None => unreachable!(), Self::None => unreachable!(),
} }
} }

View File

@@ -4,6 +4,7 @@ description = "Various states used mainly by the computer"
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -6,6 +6,7 @@ categories = ["database"]
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -6,6 +6,7 @@ categories = ["database"]
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
homepage.workspace = true
repository.workspace = true repository.workspace = true
[dependencies] [dependencies]

View File

@@ -4,9 +4,6 @@
<a href="https://github.com/bitcoinresearchkit/brk"> <a href="https://github.com/bitcoinresearchkit/brk">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/bitcoinresearchkit/brk?style=social">
</a> </a>
<a href="https://kibo.money">
<img alt="kibo.money" src="https://img.shields.io/badge/showcase-kib%C5%8D.money-orange">
</a>
<a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md"> <a href="https://github.com/bitcoinresearchkit/brk/blob/main/LICENSE.md">
<img src="https://img.shields.io/crates/l/brk" alt="License" /> <img src="https://img.shields.io/crates/l/brk" alt="License" />
</a> </a>

View File

@@ -1,4 +1,4 @@
use std::iter::Skip; use std::{iter::Skip, path::Path};
use brk_core::Value; use brk_core::Value;
@@ -20,6 +20,8 @@ pub trait BaseVecIterator: Iterator {
fn len(&self) -> usize; fn len(&self) -> usize;
fn path(&self) -> &Path;
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.len() == 0 self.len() == 0
} }
@@ -58,7 +60,12 @@ pub trait VecIterator<'a>: BaseVecIterator<Item = (Self::I, Value<'a, Self::T>)>
#[inline] #[inline]
fn unwrap_get_inner_(&mut self, i: usize) -> Self::T { fn unwrap_get_inner_(&mut self, i: usize) -> Self::T {
self.get_(i).unwrap().into_inner() self.get_(i)
.unwrap_or_else(|| {
dbg!(self.path(), i, self.len());
panic!("unwrap_get_inner_")
})
.into_inner()
} }
#[inline] #[inline]

View File

@@ -406,6 +406,11 @@ where
fn len(&self) -> usize { fn len(&self) -> usize {
self.vec.len() self.vec.len()
} }
#[inline]
fn path(&self) -> &Path {
self.vec.path()
}
} }
impl<'a, I, T> Iterator for CompressedVecIterator<'a, I, T> impl<'a, I, T> Iterator for CompressedVecIterator<'a, I, T>

View File

@@ -317,6 +317,16 @@ where
Self::LazyFrom3(i) => i.len(), Self::LazyFrom3(i) => i.len(),
} }
} }
#[inline]
fn path(&self) -> &Path {
match self {
Self::Eager(i) => i.path(),
Self::LazyFrom1(i) => i.path(),
Self::LazyFrom2(i) => i.path(),
Self::LazyFrom3(i) => i.path(),
}
}
} }
impl<'a, I, T, S1I, S1T, S2I, S2T, S3I, S3T> IntoIterator impl<'a, I, T, S1I, S1T, S2I, S2T, S3I, S3T> IntoIterator

View File

@@ -1,4 +1,4 @@
use std::marker::PhantomData; use std::{marker::PhantomData, path::Path};
use brk_core::{Result, Value, Version}; use brk_core::{Result, Value, Version};
@@ -94,6 +94,11 @@ where
fn len(&self) -> usize { fn len(&self) -> usize {
self.source.len() self.source.len()
} }
#[inline]
fn path(&self) -> &Path {
self.source.path()
}
} }
impl<'a, I, T, S1I, S1T> IntoIterator for &'a LazyVecFrom1<I, T, S1I, S1T> impl<'a, I, T, S1I, S1T> IntoIterator for &'a LazyVecFrom1<I, T, S1I, S1T>

View File

@@ -1,4 +1,4 @@
use std::marker::PhantomData; use std::{marker::PhantomData, path::Path};
use brk_core::{Result, Value, Version}; use brk_core::{Result, Value, Version};
@@ -124,6 +124,11 @@ where
}; };
len1.min(len2) len1.min(len2)
} }
#[inline]
fn path(&self) -> &Path {
self.source1.path()
}
} }
impl<'a, I, T, S1I, S1T, S2I, S2T> IntoIterator for &'a LazyVecFrom2<I, T, S1I, S1T, S2I, S2T> impl<'a, I, T, S1I, S1T, S2I, S2T> IntoIterator for &'a LazyVecFrom2<I, T, S1I, S1T, S2I, S2T>

View File

@@ -1,4 +1,4 @@
use std::marker::PhantomData; use std::{marker::PhantomData, path::Path};
use brk_core::{Result, Value, Version}; use brk_core::{Result, Value, Version};
@@ -147,6 +147,11 @@ where
}; };
len1.min(len2).min(len3) len1.min(len2).min(len3)
} }
#[inline]
fn path(&self) -> &Path {
self.source1.path()
}
} }
impl<'a, I, T, S1I, S1T, S2I, S2T, S3I, S3T> IntoIterator impl<'a, I, T, S1I, S1T, S2I, S2T, S3I, S3T> IntoIterator

View File

@@ -230,6 +230,11 @@ where
fn len(&self) -> usize { fn len(&self) -> usize {
self.vec.len() self.vec.len()
} }
#[inline]
fn path(&self) -> &Path {
self.vec.path()
}
} }
impl<'a, I, T> Iterator for RawVecIterator<'a, I, T> impl<'a, I, T> Iterator for RawVecIterator<'a, I, T>

View File

@@ -190,6 +190,14 @@ where
Self::Raw(i) => i.len(), Self::Raw(i) => i.len(),
} }
} }
#[inline]
fn path(&self) -> &Path {
match self {
Self::Compressed(i) => i.path(),
Self::Raw(i) => i.path(),
}
}
} }
impl<'a, I, T> IntoIterator for &'a StoredVec<I, T> impl<'a, I, T> IntoIterator for &'a StoredVec<I, T>

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Some files were not shown because too many files have changed in this diff Show More