computer: add positions

This commit is contained in:
nym21
2025-09-18 19:45:16 +02:00
parent cc5701ea62
commit 43117825d7
27 changed files with 458 additions and 300 deletions
+2
View File
@@ -10,9 +10,11 @@ rust-version.workspace = true
build = "build.rs"
[dependencies]
bitcoincore-rpc = { workspace = true }
brk_computer = { workspace = true }
brk_error = { workspace = true }
brk_indexer = { workspace = true }
brk_parser = { workspace = true }
brk_structs = { workspace = true }
vecdb = { workspace = true }
derive_deref = { workspace = true }
+27 -5
View File
@@ -1,18 +1,40 @@
use std::path::Path;
use std::{fs, path::Path};
use brk_computer::Computer;
use brk_error::Result;
use brk_indexer::Indexer;
use brk_interface::{Index, Interface, Params, ParamsOpt};
use brk_parser::Parser;
use vecdb::Exit;
pub fn main() -> Result<()> {
let outputs_dir = Path::new("../../_outputs");
let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
.join("Library")
.join("Application Support")
.join("Bitcoin");
// let bitcoin_dir = Path::new("/Volumes/WD_BLACK1/bitcoin");
let indexer = Indexer::forced_import(outputs_dir)?;
let blocks_dir = bitcoin_dir.join("blocks");
let computer = Computer::forced_import(outputs_dir, &indexer, None)?;
let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
fs::create_dir_all(&outputs_dir)?;
// let outputs_dir = Path::new("/Volumes/WD_BLACK1/brk");
let interface = Interface::build(&indexer, &computer);
let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
"http://localhost:8332",
bitcoincore_rpc::Auth::CookieFile(bitcoin_dir.join(".cookie")),
)?));
let exit = Exit::new();
exit.set_ctrlc_handler();
let parser = Parser::new(blocks_dir, rpc);
let indexer = Indexer::forced_import(&outputs_dir)?;
let computer = Computer::forced_import(&outputs_dir, &indexer, None)?;
let interface = Interface::build(&parser, &indexer, &computer);
dbg!(interface.search_and_format(Params {
index: Index::Height,
+9 -1
View File
@@ -5,6 +5,7 @@ use std::{collections::BTreeMap, sync::OnceLock};
use brk_computer::Computer;
use brk_error::{Error, Result};
use brk_indexer::Indexer;
use brk_parser::Parser;
use brk_structs::Height;
use nucleo_matcher::{
Config, Matcher,
@@ -42,18 +43,21 @@ pub fn cached_errors() -> &'static Cache<String, String> {
#[allow(dead_code)]
pub struct Interface<'a> {
vecs: Vecs<'a>,
parser: &'a Parser,
indexer: &'a Indexer,
computer: &'a Computer,
}
impl<'a> Interface<'a> {
pub fn build(indexer: &Indexer, computer: &Computer) -> Self {
pub fn build(parser: &Parser, indexer: &Indexer, computer: &Computer) -> Self {
let parser = parser.static_clone();
let indexer = indexer.static_clone();
let computer = computer.static_clone();
let vecs = Vecs::build(indexer, computer);
Self {
vecs,
parser,
indexer,
computer,
}
@@ -262,6 +266,10 @@ impl<'a> Interface<'a> {
self.vecs.id_to_indexes(id)
}
pub fn parser(&self) -> &Parser {
self.parser
}
pub fn indexer(&self) -> &Indexer {
self.indexer
}
+1 -5
View File
@@ -27,11 +27,7 @@ impl<'a> Vecs<'a> {
pub fn build(indexer: &'a Indexer, computer: &'a Computer) -> Self {
let mut this = Vecs::default();
indexer
.vecs
.vecs()
.into_iter()
.for_each(|vec| this.insert(vec));
indexer.vecs.iter().for_each(|vec| this.insert(vec));
computer
.iter_any_collectable()