global: init readmes

This commit is contained in:
nym21
2025-02-26 10:07:05 +01:00
parent 01ecae8979
commit bb61b3dc22
19 changed files with 75 additions and 44 deletions

3
.gitignore vendored
View File

@@ -36,3 +36,6 @@ _outputs
# Python
.ropeproject
# Logs
.log

20
Cargo.lock generated
View File

@@ -324,7 +324,7 @@ checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
[[package]]
name = "brk"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"brk_computer",
"brk_core",
@@ -337,11 +337,11 @@ dependencies = [
[[package]]
name = "brk_cli"
version = "0.0.0"
version = "0.0.1"
[[package]]
name = "brk_computer"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"brk_core",
"brk_indexer",
@@ -353,7 +353,7 @@ dependencies = [
[[package]]
name = "brk_core"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"bitcoin",
"bitcoincore-rpc",
@@ -368,7 +368,7 @@ dependencies = [
[[package]]
name = "brk_fetcher"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"brk_core",
"brk_indexer",
@@ -383,7 +383,7 @@ dependencies = [
[[package]]
name = "brk_indexer"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"bitcoin",
"bitcoincore-rpc",
@@ -403,7 +403,7 @@ dependencies = [
[[package]]
name = "brk_logger"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"color-eyre",
"env_logger",
@@ -412,7 +412,7 @@ dependencies = [
[[package]]
name = "brk_parser"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"bitcoin",
"bitcoincore-rpc",
@@ -427,7 +427,7 @@ dependencies = [
[[package]]
name = "brk_server"
version = "0.0.0"
version = "0.0.1"
dependencies = [
"axum",
"brk_computer",
@@ -927,7 +927,7 @@ checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
[[package]]
name = "hodor"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"ctrlc",
"log",

View File

@@ -1,9 +1,11 @@
[workspace]
members = ["crates/*"]
resolver = "2"
members = ["crates/*"]
package.description = "The Bitcoin Research Kit is a suite of tools designed to help you extract, explore and analyze the data stored from your Bitcoin Core node"
package.license = "MIT"
package.edition = "2024"
package.version = "0.0.0"
package.version = "0.0.1"
package.repository = "https://github.com/bitcoinresearchkit/brk"
[workspace.dependencies]
bitcoin = { version = "0.32.5", features = ["serde"] }

View File

@@ -1,7 +1,9 @@
[package]
name = "brk"
description = "The Bitcoin Research Kit is a suite of tools designed to help you extract, explore and analyze the data stored from your node"
description.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
edition.workspace = true
version.workspace = true

1
crates/brk_cli/README.md Normal file
View File

@@ -0,0 +1 @@
# BRK Cli

View File

@@ -0,0 +1 @@
# BRK Computer

View File

@@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use brk_indexer::Indexer;
pub use brk_parser::rpc;
use hodor::Exit;
use hodor::Hodor;
mod storage;
@@ -29,7 +29,7 @@ impl<const MODE: u8> Computer<MODE> {
}
impl Computer<SINGLE_THREAD> {
pub fn compute(&mut self, mut indexer: Indexer<SINGLE_THREAD>, exit: &Exit) -> color_eyre::Result<()> {
pub fn compute(&mut self, mut indexer: Indexer<SINGLE_THREAD>, hodor: &Hodor) -> color_eyre::Result<()> {
let height_count = indexer.vecs.height_to_size.len();
let txindexes_count = indexer.vecs.txindex_to_txid.len();
let txinindexes_count = indexer.vecs.txinindex_to_txoutindex.len();

View File

@@ -2,18 +2,22 @@ use std::path::Path;
use brk_computer::Computer;
use brk_indexer::Indexer;
use hodor::Exit;
use hodor::Hodor;
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
let exit = Exit::new();
let hodor = Hodor::new();
let i = std::time::Instant::now();
let outputs_dir = Path::new("../_outputs");
let outputs_dir = Path::new("../../_outputs");
Computer::import(&outputs_dir.join("computed"))?.compute(Indexer::import(&outputs_dir.join("indexes"))?, &exit)?;
let indexer = Indexer::import(&outputs_dir.join("indexes"))?;
let mut computer = Computer::import(&outputs_dir.join("computed"))?;
computer.compute(indexer, &hodor)?;
dbg!(i.elapsed());

View File

@@ -0,0 +1 @@
# BRK Core

View File

@@ -88,6 +88,11 @@ impl From<TxidPrefix> for ByteView {
Self::from(&value)
}
}
impl From<[u8; 8]> for TxidPrefix {
fn from(value: [u8; 8]) -> Self {
Self(value)
}
}
fn copy_first_8bytes(slice: &[u8]) -> Result<[u8; 8], ()> {
let mut buf: [u8; 8] = [0; 8];

View File

@@ -1,6 +1,8 @@
use byteview::ByteView;
#[derive(Debug)]
pub struct Unit();
impl From<ByteView> for Unit {
fn from(_: ByteView) -> Self {
Self()

View File

@@ -0,0 +1 @@
# BRK Fetcher

View File

@@ -1,4 +1,4 @@
# Indexer
# BRK Indexer
A [Bitcoin Core](https://bitcoincore.org/en/about/) node indexer which iterates over the chain (via `../iterator`) and creates a database of the vecs (`../storable_vec`) and key/value stores ([`fjall`](https://crates.io/crates/fjall)) that can be used in your Rust code.

View File

@@ -1,9 +1,9 @@
# biter
# BRK Parser
Biter (Bitcoin Block Iterator) is a very fast and simple Rust library which reads raw block files (*blkXXXXX.dat*) from Bitcoin Core Node and creates an iterator over all the requested blocks in sequential order (0, 1, 2, ...).
A very fast and simple Rust library which reads raw block files (*blkXXXXX.dat*) from Bitcoin Core node and creates an iterator over all the requested blocks in sequential order (0, 1, 2, ...).
The element returned by the iterator is a tuple which includes the:
- Height: `usize`
- Height: `Height`
- Block: `Block` (from `bitcoin-rust`)
- Block's Hash: `BlockHash` (also from `bitcoin-rust`)

View File

@@ -54,6 +54,10 @@ impl Parser {
}
}
pub fn get(&self, height: Height) -> Block {
self.parse(Some(height), Some(height)).iter().next().unwrap().1
}
///
/// Returns a crossbeam channel receiver that receives `(Height, Block, BlockHash)` tuples from an **inclusive** range (`start` and `end`)
///

View File

@@ -1,6 +1,7 @@
use std::path::Path;
use bitcoincore_rpc::{Auth, Client};
use brk_core::Height;
use brk_parser::Parser;
fn main() {
@@ -24,5 +25,8 @@ fn main() {
println!("{height}: {hash}");
});
parser.get(Height::new(0));
parser.get(Height::new(840_000));
dbg!(i.elapsed());
}

View File

@@ -0,0 +1 @@
# BRK Server

View File

@@ -1,7 +1,7 @@
[package]
name = "hodor"
description = "Hold the door, an exit blocker that can wait until a task is completed"
version = "0.1.0"
version = "0.1.1"
edition = { workspace = true }
license = { workspace = true }

View File

@@ -1,8 +1,8 @@
use std::{
process::exit,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
thread::sleep,
time::Duration,
@@ -11,32 +11,32 @@ use std::{
use log::info;
#[derive(Default, Clone)]
pub struct Exit {
blocked: Arc<AtomicBool>,
active: Arc<AtomicBool>,
pub struct Hodor {
holding: Arc<AtomicBool>,
triggered: Arc<AtomicBool>,
}
impl Exit {
impl Hodor {
pub fn new() -> Self {
let s = Self {
active: Arc::new(AtomicBool::new(false)),
blocked: Arc::new(AtomicBool::new(false)),
triggered: Arc::new(AtomicBool::new(false)),
holding: Arc::new(AtomicBool::new(false)),
};
let active = s.active.clone();
let triggered = s.triggered.clone();
let _blocked = s.blocked.clone();
let blocked = move || _blocked.load(Ordering::SeqCst);
let holding = s.holding.clone();
let is_holding = move || holding.load(Ordering::SeqCst);
ctrlc::set_handler(move || {
info!("Exitting...");
active.store(true, Ordering::SeqCst);
triggered.store(true, Ordering::SeqCst);
if blocked() {
info!("Waiting to exit safely");
if is_holding() {
info!("Waiting to exit safely...");
while blocked() {
while is_holding() {
sleep(Duration::from_millis(50));
}
}
@@ -48,15 +48,15 @@ impl Exit {
s
}
pub fn block(&self) {
self.blocked.store(true, Ordering::SeqCst);
pub fn hold(&self) {
self.holding.store(true, Ordering::SeqCst);
}
pub fn unblock(&self) {
self.blocked.store(false, Ordering::SeqCst);
pub fn release(&self) {
self.holding.store(false, Ordering::SeqCst);
}
pub fn blocked(&self) -> bool {
self.active.load(Ordering::SeqCst)
pub fn triggered(&self) -> bool {
self.triggered.load(Ordering::SeqCst)
}
}