general: snapshot

This commit is contained in:
nym21
2025-02-19 21:43:18 +01:00
parent 2cb4d65f3d
commit 5e39510f21
150 changed files with 188 additions and 972 deletions
+5 -5
View File
@@ -10,7 +10,7 @@ pub use iterator::*;
use bitcoin::{Transaction, TxIn, TxOut};
use color_eyre::eyre::{eyre, ContextCompat};
use exit::Exit;
use hodor::Exit;
use logger::info;
use rayon::prelude::*;
use storable_vec::CACHED_GETS;
@@ -31,14 +31,14 @@ pub struct Indexer<const MODE: u8> {
impl<const MODE: u8> Indexer<MODE> {
pub fn import(indexes_dir: &Path) -> color_eyre::Result<Self> {
info!("Importing indexes...");
// info!("Increasing limit of opened files to 210_000...");
rlimit::setrlimit(
rlimit::Resource::NOFILE,
210_000,
rlimit::getrlimit(rlimit::Resource::NOFILE).unwrap().1,
)?;
info!("Importing indexes...");
let vecs = StorableVecs::import(&indexes_dir.join("vecs"))?;
let trees = Fjalls::import(&indexes_dir.join("fjall"))?;
@@ -47,12 +47,12 @@ impl<const MODE: u8> Indexer<MODE> {
}
impl Indexer<CACHED_GETS> {
pub fn index(&mut self, bitcoin_dir: &Path, rpc: rpc::Client, exit: &Exit) -> color_eyre::Result<()> {
pub fn index(&mut self, bitcoin_dir: &Path, rpc: &'static rpc::Client, exit: &Exit) -> color_eyre::Result<()> {
info!("Started indexing...");
let check_collisions = true;
let starting_indexes = Indexes::try_from((&mut self.vecs, &self.trees, &rpc)).unwrap_or_else(|_| {
let starting_indexes = Indexes::try_from((&mut self.vecs, &self.trees, rpc)).unwrap_or_else(|_| {
let indexes = Indexes::default();
indexes.push_if_needed(&mut self.vecs).unwrap();
indexes
+21 -10
View File
@@ -1,8 +1,9 @@
use std::path::Path;
use std::{path::Path, thread::sleep, time::Duration};
use bindex::Indexer;
use exit::Exit;
use bindexer::{rpc::RpcApi, Indexer};
use hodor::Exit;
use iterator::rpc;
use logger::info;
use storable_vec::CACHED_GETS;
fn main() -> color_eyre::Result<()> {
@@ -11,19 +12,29 @@ fn main() -> color_eyre::Result<()> {
logger::init_log(None);
let data_dir = Path::new("../../bitcoin");
let rpc = rpc::Client::new(
let rpc = Box::leak(Box::new(rpc::Client::new(
"http://localhost:8332",
rpc::Auth::CookieFile(Path::new(data_dir).join(".cookie")),
)?;
)?));
let exit = Exit::new();
let i = std::time::Instant::now();
loop {
let block_count = rpc.get_blockchain_info().unwrap().blocks as usize;
let mut indexer: Indexer<CACHED_GETS> = Indexer::import(Path::new("../_outputs/indexes"))?;
info!("{block_count} blocks found.");
indexer.index(data_dir, rpc, &exit)?;
let i = std::time::Instant::now();
dbg!(i.elapsed());
let mut indexer: Indexer<CACHED_GETS> = Indexer::import(Path::new("../_outputs/indexes"))?;
Ok(())
indexer.index(data_dir, rpc, &exit)?;
dbg!(i.elapsed());
info!("Waiting for a new block...");
while block_count == rpc.get_blockchain_info().unwrap().blocks as usize {
sleep(Duration::from_secs(1))
}
}
}