This commit is contained in:
nym21
2025-11-21 16:16:36 +01:00
parent c8c62b504b
commit eedc0dd075
6 changed files with 83 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
#![doc = include_str!("../README.md")]
use std::{path::Path, thread};
use std::{path::Path, thread, time::Instant};
use brk_error::Result;
use brk_fetcher::Fetcher;
@@ -151,61 +151,79 @@ impl Computer {
&mut self,
indexer: &Indexer,
starting_indexes: brk_indexer::Indexes,
parser: &Reader,
reader: &Reader,
exit: &Exit,
) -> Result<()> {
info!("Computing indexes...");
let i = Instant::now();
let mut starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?;
info!("Computed indexes in {:?}", i.elapsed());
if let Some(fetched) = self.fetched.as_mut() {
info!("Computing fetched...");
let i = Instant::now();
fetched.compute(indexer, &self.indexes, &starting_indexes, exit)?;
info!("Computed fetched in {:?}", i.elapsed());
info!("Computing prices...");
let i = Instant::now();
self.price.as_mut().unwrap().compute(
&self.indexes,
&starting_indexes,
fetched,
exit,
)?;
info!("Computed prices in {:?}", i.elapsed());
}
info!("Computing BLKs metadata...");
self.blks
.compute(indexer, &starting_indexes, parser, exit)?;
std::thread::scope(|scope| -> Result<()> {
let blks = scope.spawn(|| -> Result<()> {
info!("Computing BLKs metadata...");
let i = Instant::now();
self.blks
.compute(indexer, &starting_indexes, reader, exit)?;
info!("Computed blk in {:?}", i.elapsed());
Ok(())
});
// std::thread::scope(|scope| -> Result<()> {
// let constants = scope.spawn(|| -> Result<()> {
info!("Computing constants...");
self.constants
.compute(&self.indexes, &starting_indexes, exit)?;
// Ok(())
// });
let constants = scope.spawn(|| -> Result<()> {
info!("Computing constants...");
let i = Instant::now();
self.constants
.compute(&self.indexes, &starting_indexes, exit)?;
info!("Computed constants in {:?}", i.elapsed());
Ok(())
});
// let chain = scope.spawn(|| -> Result<()> {
info!("Computing chain...");
self.chain.compute(
indexer,
&self.indexes,
&starting_indexes,
self.price.as_ref(),
exit,
)?;
// Ok(())
// });
let chain = scope.spawn(|| -> Result<()> {
info!("Computing chain...");
let i = Instant::now();
self.chain.compute(
indexer,
&self.indexes,
&starting_indexes,
self.price.as_ref(),
exit,
)?;
info!("Computed chain in {:?}", i.elapsed());
Ok(())
});
if let Some(price) = self.price.as_ref() {
info!("Computing market...");
self.market.compute(price, &starting_indexes, exit)?;
}
if let Some(price) = self.price.as_ref() {
info!("Computing market...");
let i = Instant::now();
self.market.compute(price, &starting_indexes, exit)?;
info!("Computed market in {:?}", i.elapsed());
}
return Ok(());
// constants.join().unwrap()?;
// chain.join().unwrap()?;
// Ok(())
// })?;
blks.join().unwrap()?;
constants.join().unwrap()?;
chain.join().unwrap()?;
Ok(())
})?;
info!("Computing pools...");
let i = Instant::now();
self.pools.compute(
indexer,
&self.indexes,
@@ -214,6 +232,7 @@ impl Computer {
self.price.as_ref(),
exit,
)?;
info!("Computed pools in {:?}", i.elapsed());
info!("Computing stateful...");
self.stateful.compute(

View File

@@ -534,6 +534,7 @@ impl Vecs {
let height_to_first_p2wpkhaddressindex = &indexer.vecs.height_to_first_p2wpkhaddressindex;
let height_to_first_p2wshaddressindex = &indexer.vecs.height_to_first_p2wshaddressindex;
let height_to_first_txindex = &indexer.vecs.height_to_first_txindex;
let height_to_txindex_count = chain.indexes_to_tx_count.height.as_ref().unwrap();
let height_to_first_txinindex = &indexer.vecs.height_to_first_txinindex;
let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex;
let height_to_input_count = chain.indexes_to_input_count.height.unwrap_sum();
@@ -578,6 +579,7 @@ impl Vecs {
+ height_to_first_p2wpkhaddressindex.version()
+ height_to_first_p2wshaddressindex.version()
+ height_to_first_txindex.version()
+ height_to_txindex_count.version()
+ height_to_first_txinindex.version()
+ height_to_first_txoutindex.version()
+ height_to_input_count.version()
@@ -778,6 +780,7 @@ impl Vecs {
let mut height_to_first_p2wshaddressindex_iter =
height_to_first_p2wshaddressindex.into_iter();
let mut height_to_first_txindex_iter = height_to_first_txindex.into_iter();
let mut height_to_txindex_count_iter = height_to_txindex_count.into_iter();
let mut height_to_first_txinindex_iter = height_to_first_txinindex.into_iter();
let mut height_to_first_txoutindex_iter = height_to_first_txoutindex.into_iter();
let mut height_to_input_count_iter = height_to_input_count.into_iter();