global: snapshot

This commit is contained in:
nym21
2025-03-02 12:45:33 +01:00
parent 0453b6903a
commit ceefc8ffc6
14 changed files with 113 additions and 94 deletions

4
Cargo.lock generated
View File

@@ -343,7 +343,6 @@ name = "brk_cli"
version = "0.0.3"
dependencies = [
"brk_computer",
"brk_core",
"brk_exit",
"brk_indexer",
"brk_logger",
@@ -361,7 +360,6 @@ version = "0.0.3"
dependencies = [
"brk_core",
"brk_exit",
"brk_fetcher",
"brk_indexer",
"brk_logger",
"brk_parser",
@@ -478,11 +476,9 @@ dependencies = [
"brk_query",
"brk_vec",
"color-eyre",
"derive_deref",
"jiff",
"log",
"oxc",
"serde",
"serde_json",
"tokio",
"tower-http",

View File

@@ -1,8 +1,5 @@
# Bitcoin Research Kit
> ⚠️ In the middle of a massive rewrite, use very carefully ⚠️
> Everything is still a work in progress
## Description
The Bitcoin Research Kit is a suite of tools designed to extract, compute and display data stored on a Bitcoin Core node.
@@ -30,54 +27,7 @@ Feel free to open an issue if you want to add another instance
## Setup
### Hardware
#### Recommended
- [Latest base model Mac mini](https://www.apple.com/mac-mini/)
- [Thunderbolt 4 SSD enclosure](https://satechi.net/products/usb4-nvme-ssd-pro-enclosure/Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC80MDE4ODQ3MDA2NzI4OA==?queryID=7961465089021ee203a60db7e62e90d2)
- [2 TB NVMe SSD](https://shop.sandisk.com/products/ssd/internal-ssd/wd-black-sn850x-nvme-ssd?sku=WDS200T2X0E-00BCA0)
#### Minimum
To be determined
### Requirements
- Unix based operating system (Mac OS or Linux)
- Ubuntu users need to install `open-ssl` via `sudo apt install libssl-dev pkg-config`
- [Bitcoin](https://bitcoin.org/en/full-node)
- Example: `bitcoind -datadir="$HOME/.bitcoin" -blocksonly`
- [Rust](https://www.rust-lang.org/tools/install)
- Install: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Update: `rustup update`
### Build
Then you need to choose a path where the project will reside and then clone it
```bash
cd ???
git clone https://github.com/kibo-money/kibo.git
cd kibo
```
If it's your first time running kibo, it will need several information such as:
- `--bitcoindir PATH`: path to bitcoin core data directory, `???/bitcoin`
- `--kibodir PATH`: path to kibo outputs, if you have enough space on your main disk `~/.kibo` is fine
Everything will be saved at `~/.kibo/config.toml`, which will allow you to simply run `cargo run -r` next time
If you need more options please run `cargo run -r --help` to see what parameters are available.
Here's an example
```bash
cargo run -r -- --bitcoindir=~/Developer/bitcoin --kibodir=~/.kibo
```
Then the easiest to let others access your server is to use `cloudflared` which will also cache requests. For more information go to: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/
[Guide](https://crates.io/crates/brk_cli)
## Donate

View File

@@ -1,4 +1,4 @@
#![doc = include_str!("../../../README.md")]
#![doc = include_str!(concat!("../", env!("CARGO_PKG_README")))]
#[cfg(feature = "core")]
pub mod core {

View File

@@ -7,7 +7,6 @@ license.workspace = true
repository.workspace = true
[dependencies]
brk_core = { workspace = true }
brk_computer = { workspace = true }
brk_exit = { workspace = true }
brk_indexer = { workspace = true }
@@ -15,7 +14,7 @@ brk_logger = { workspace = true }
brk_parser = { workspace = true }
brk_query = { workspace = true }
brk_server = { workspace = true }
clap = { workspace = true }
clap = { workspace = true , features = ["string"] }
color-eyre = { workspace = true }
log = { workspace = true }

View File

@@ -1 +1,61 @@
# BRK Cli
## Setup
### Hardware
#### Recommended
- [Latest base model Mac mini](https://www.apple.com/mac-mini/)
- [Thunderbolt 4 SSD enclosure](https://satechi.net/products/usb4-nvme-ssd-pro-enclosure/Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC80MDE4ODQ3MDA2NzI4OA==?queryID=7961465089021ee203a60db7e62e90d2)
- [2 TB NVMe SSD](https://shop.sandisk.com/products/ssd/internal-ssd/wd-black-sn850x-nvme-ssd?sku=WDS200T2X0E-00BCA0)
#### Minimum
To be determined
### Software
- Unix based operating system (Mac OS or Linux)
- Ubuntu users need to install `open-ssl` via `sudo apt install libssl-dev pkg-config`
- [Bitcoin](https://bitcoin.org/en/full-node)
- Example: `bitcoind -datadir="$HOME/.bitcoin" -blocksonly`
- [Rust](https://www.rust-lang.org/tools/install)
- Install: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Update: `rustup update`
### Install
```bash
cargo install brk_cli
```
If it's your first time running `brk`, it will need several information such as:
- `--bitcoindir PATH`: path to bitcoin core data directory, `???/bitcoin`
- `--outputdir PATH`: path to various outputs, if you have enough space on your main disk `~/.brk` is fine
Everything will be saved at `~/.brk/config.toml`, which will allow you to simply run `brk run` next time
If you need more options please run `brk -h` to see what parameters are available.
Here's an example
```bash
brk run --bitcoindir=~/Developer/bitcoin --outputdir=~/.brk
```
Then the easiest to let others access your server is to use `cloudflared` which will also cache requests. For more information go to: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/
### Update
```bash
cargo install brk_cli
```
or
```bash
cargo install cargo-update
cargo install-update -a
```

View File

@@ -42,7 +42,7 @@ fn main() -> color_eyre::Result<()> {
let mut computer = Computer::import(&outputs_dir.join("computed"))?;
match &cli.command {
Commands::Run(args) => {
Commands::Run(_) => {
let data_dir = Path::new("../../../bitcoin");
let rpc = Box::leak(Box::new(rpc::Client::new(
"http://localhost:8332",

View File

@@ -9,7 +9,6 @@ repository.workspace = true
[dependencies]
brk_core = { workspace = true }
brk_exit = { workspace = true }
brk_fetcher = { workspace = true }
brk_indexer = { workspace = true }
brk_logger = { workspace = true }
brk_parser = { workspace = true }

View File

@@ -72,10 +72,17 @@ impl Computer {
// exit,
// )?;
self.vecs.height_to_height.compute_transform(
starting_indexes.height,
&mut indexer.vecs.height_to_timestamp,
|_, height| height,
exit,
)?;
self.vecs.height_to_date.compute_transform(
starting_indexes.height,
&mut indexer.vecs.height_to_timestamp,
|timestamp| Date::from(*timestamp),
|timestamp, _| Date::from(*timestamp),
exit,
)?;

View File

@@ -25,6 +25,7 @@ pub struct Vecs {
pub dateindex_to_open_in_dollars: StorableVec<Dateindex, Open<Dollars>>,
pub height_to_close_in_cents: StorableVec<Height, Close<Cents>>,
pub height_to_close_in_dollars: StorableVec<Height, Close<Dollars>>,
pub height_to_height: StorableVec<Height, Height>,
pub height_to_high_in_cents: StorableVec<Height, High<Cents>>,
pub height_to_high_in_dollars: StorableVec<Height, High<Dollars>>,
pub height_to_low_in_cents: StorableVec<Height, Low<Cents>>,
@@ -101,6 +102,7 @@ impl Vecs {
&path.join("height_to_close_in_dollars"),
Version::from(1),
)?,
height_to_height: StorableVec::import(&path.join("height_to_height"), Version::from(1))?,
height_to_high_in_cents: StorableVec::import(&path.join("height_to_high_in_cents"), Version::from(1))?,
height_to_high_in_dollars: StorableVec::import(&path.join("height_to_high_in_dollars"), Version::from(1))?,
height_to_low_in_cents: StorableVec::import(&path.join("height_to_low_in_cents"), Version::from(1))?,
@@ -152,6 +154,7 @@ impl Vecs {
pub fn as_any_vecs(&self) -> Vec<&dyn AnyStorableVec> {
vec![
&self.height_to_date as &dyn AnyStorableVec,
&self.height_to_height,
// &self.dateindex_to_close_in_dollars,
// &self.dateindex_to_high_in_cents,
// &self.dateindex_to_high_in_dollars,

View File

@@ -38,7 +38,7 @@ impl Index {
]
}
pub fn ids(&self) -> &[&str] {
pub fn self_to_ids(&self) -> &[&str] {
match self {
Self::Dateindex => &["d", "date", "dateindex"],
Self::Height => &["h", "height"],
@@ -55,25 +55,32 @@ impl Index {
Self::P2WSHindex => &["p2wshi", "p2wshindex"],
}
}
pub fn ids() -> Vec<String> {
Self::all()
.iter()
.flat_map(|i| i.self_to_ids().iter().map(|s| s.to_string()))
.collect::<Vec<_>>()
}
}
impl TryFrom<&str> for Index {
type Error = color_eyre::Report;
fn try_from(value: &str) -> Result<Self, Self::Error> {
Ok(match value {
v if (Self::Dateindex).ids().contains(&v) => Self::Dateindex,
v if (Self::Height).ids().contains(&v) => Self::Height,
v if (Self::Txindex).ids().contains(&v) => Self::Txindex,
v if (Self::Txinindex).ids().contains(&v) => Self::Txinindex,
v if (Self::Txoutindex).ids().contains(&v) => Self::Txoutindex,
v if (Self::Addressindex).ids().contains(&v) => Self::Addressindex,
v if (Self::P2PK33index).ids().contains(&v) => Self::P2PK33index,
v if (Self::P2PK65index).ids().contains(&v) => Self::P2PK65index,
v if (Self::P2PKHindex).ids().contains(&v) => Self::P2PKHindex,
v if (Self::P2SHindex).ids().contains(&v) => Self::P2SHindex,
v if (Self::P2TRindex).ids().contains(&v) => Self::P2TRindex,
v if (Self::P2WPKHindex).ids().contains(&v) => Self::P2WPKHindex,
v if (Self::P2WSHindex).ids().contains(&v) => Self::P2WSHindex,
v if (Self::Dateindex).self_to_ids().contains(&v) => Self::Dateindex,
v if (Self::Height).self_to_ids().contains(&v) => Self::Height,
v if (Self::Txindex).self_to_ids().contains(&v) => Self::Txindex,
v if (Self::Txinindex).self_to_ids().contains(&v) => Self::Txinindex,
v if (Self::Txoutindex).self_to_ids().contains(&v) => Self::Txoutindex,
v if (Self::Addressindex).self_to_ids().contains(&v) => Self::Addressindex,
v if (Self::P2PK33index).self_to_ids().contains(&v) => Self::P2PK33index,
v if (Self::P2PK65index).self_to_ids().contains(&v) => Self::P2PK65index,
v if (Self::P2PKHindex).self_to_ids().contains(&v) => Self::P2PKHindex,
v if (Self::P2SHindex).self_to_ids().contains(&v) => Self::P2SHindex,
v if (Self::P2TRindex).self_to_ids().contains(&v) => Self::P2TRindex,
v if (Self::P2WPKHindex).self_to_ids().contains(&v) => Self::P2WPKHindex,
v if (Self::P2WSHindex).self_to_ids().contains(&v) => Self::P2WSHindex,
_ => return Err(eyre!("Bad index")),
})
}

View File

@@ -1,11 +1,11 @@
use clap::Parser;
use clap::{Parser, builder::PossibleValuesParser};
use serde::Deserialize;
use crate::Format;
use crate::{Format, Index};
#[derive(Debug, Deserialize, Parser)]
pub struct Params {
#[clap(short, long)]
#[clap(short, long, value_parser = PossibleValuesParser::new(Index::ids()))]
pub index: String,
#[clap(short, long, value_delimiter = ' ', num_args = 1..)]
pub values: Vec<String>,

View File

@@ -16,11 +16,9 @@ brk_parser = { workspace = true }
brk_query = { workspace = true }
brk_vec = { workspace = true }
color-eyre = { workspace = true }
derive_deref = { workspace = true }
jiff = { workspace = true }
log = { workspace = true }
oxc = { version = "0.53.0", features = ["codegen", "minifier"] }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { version = "1.43.0", features = ["full"] }
tower-http = { version = "0.6.2", features = ["compression-full"] }

View File

@@ -565,12 +565,12 @@ where
) -> Result<()>
where
A: StoredType,
F: Fn(&A) -> T,
F: Fn(&A, I) -> T,
{
self.validate_computed_version_or_reset_file(Version::from(0) + self.version + other.version)?;
let index = max_from.min(I::from(self.len()));
other.iter_from(index, |(i, a)| self.push_and_flush_if_needed(i, t(a), exit))?;
other.iter_from(index, |(i, a)| self.push_and_flush_if_needed(i, t(a, i), exit))?;
Ok(self.safe_flush(exit)?)
}

View File

@@ -3,39 +3,39 @@
cd crates/brk
cd ../brk_core
cargo publish
cargo publish --allow-dirty
cd ../brk_exit
cargo publish
cargo publish --allow-dirty
cd ../brk_vec
cargo publish
cargo publish --allow-dirty
cd ../brk_logger
cargo publish
cargo publish --allow-dirty
cd ../brk_indexer
cargo publish
cargo publish --allow-dirty
cd ../brk_parser
cargo publish
cargo publish --allow-dirty
cd ../brk_fetcher
cargo publish
cargo publish --allow-dirty
cd ../brk_computer
cargo publish
cargo publish --allow-dirty
cd ../brk_query
cargo publish
cargo publish --allow-dirty
cd ../brk_server
cargo publish
cargo publish --allow-dirty
cd ../brk_cli
cargo publish
cargo publish --allow-dirty
cd ../brk
cargo publish
cargo publish --allow-dirty
cd ../..