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

34
Cargo.lock generated
View File

@@ -1376,9 +1376,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.46" version = "1.2.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"jobserver", "jobserver",
@@ -2419,7 +2419,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7ed2f2edad8a14c8186b847909a41fbb9c3eafa44f88bd891114ed5019da09" checksum = "0c7ed2f2edad8a14c8186b847909a41fbb9c3eafa44f88bd891114ed5019da09"
dependencies = [ dependencies = [
"hashbrown 0.16.0", "hashbrown 0.16.1",
] ]
[[package]] [[package]]
@@ -2439,9 +2439,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.16.0" version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [ dependencies = [
"allocator-api2", "allocator-api2",
"equivalent", "equivalent",
@@ -2706,12 +2706,12 @@ checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.12.0" version = "2.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.16.0", "hashbrown 0.16.1",
"serde", "serde",
"serde_core", "serde_core",
] ]
@@ -2859,9 +2859,9 @@ checksum = "a3c2a6c0b4b5637c41719973ef40c6a1cf564f9db6958350de6193fbee9c23f5"
[[package]] [[package]]
name = "json-strip-comments" name = "json-strip-comments"
version = "3.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4135b29c84322dbc3327272084360785665452213a576a991b3ac2f63148e82" checksum = "25376d12b2f6ae53f986f86e2a808a56af03d72284ae24fc35a2e290d09ee3c3"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -3364,7 +3364,7 @@ checksum = "674f1447d47e26970ff13d8da8140ffb0d7fde347ab9af3e5c00e67943d4bc9b"
dependencies = [ dependencies = [
"allocator-api2", "allocator-api2",
"bumpalo", "bumpalo",
"hashbrown 0.16.0", "hashbrown 0.16.1",
"oxc_data_structures", "oxc_data_structures",
"oxc_estree", "oxc_estree",
"rustc-hash", "rustc-hash",
@@ -4115,7 +4115,7 @@ checksum = "7ada44a88ef953a3294f6eb55d2007ba44646015e18613d2f213016379203ef3"
dependencies = [ dependencies = [
"ahash", "ahash",
"equivalent", "equivalent",
"hashbrown 0.16.0", "hashbrown 0.16.1",
"parking_lot", "parking_lot",
] ]
@@ -4336,7 +4336,7 @@ version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48" checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48"
dependencies = [ dependencies = [
"hashbrown 0.16.0", "hashbrown 0.16.1",
"memchr", "memchr",
] ]
@@ -5940,18 +5940,18 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.8.27" version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.8.27" version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -81,7 +81,7 @@ serde_json = { version = "1.0.145", features = ["float_roundtrip"] }
tokio = { version = "1.48.0", features = ["rt-multi-thread"] } tokio = { version = "1.48.0", features = ["rt-multi-thread"] }
vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json"] } vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json"] }
# vecdb = { version = "0.3.20", features = ["derive"] } # vecdb = { version = "0.3.20", features = ["derive"] }
zerocopy = { version = "0.8.27", features = ["derive"] } zerocopy = { version = "0.8.28", features = ["derive"] }
[workspace.metadata.release] [workspace.metadata.release]
shared-version = true shared-version = true

View File

@@ -17,7 +17,7 @@ use vecdb::Exit;
pub fn main() -> Result<()> { pub fn main() -> Result<()> {
// Can't increase main thread's stack size, thus we need to use another thread // Can't increase main thread's stack size, thus we need to use another thread
thread::Builder::new() thread::Builder::new()
.stack_size(512 * 1024 * 1024) .stack_size(1024 * 1024 * 1024)
.spawn(run)? .spawn(run)?
.join() .join()
.unwrap() .unwrap()

View File

@@ -1,6 +1,6 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
use std::{path::Path, thread}; use std::{path::Path, thread, time::Instant};
use brk_error::Result; use brk_error::Result;
use brk_fetcher::Fetcher; use brk_fetcher::Fetcher;
@@ -151,61 +151,79 @@ impl Computer {
&mut self, &mut self,
indexer: &Indexer, indexer: &Indexer,
starting_indexes: brk_indexer::Indexes, starting_indexes: brk_indexer::Indexes,
parser: &Reader, reader: &Reader,
exit: &Exit, exit: &Exit,
) -> Result<()> { ) -> Result<()> {
info!("Computing indexes..."); info!("Computing indexes...");
let i = Instant::now();
let mut starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?; 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() { if let Some(fetched) = self.fetched.as_mut() {
info!("Computing fetched..."); info!("Computing fetched...");
let i = Instant::now();
fetched.compute(indexer, &self.indexes, &starting_indexes, exit)?; fetched.compute(indexer, &self.indexes, &starting_indexes, exit)?;
info!("Computed fetched in {:?}", i.elapsed());
info!("Computing prices..."); info!("Computing prices...");
let i = Instant::now();
self.price.as_mut().unwrap().compute( self.price.as_mut().unwrap().compute(
&self.indexes, &self.indexes,
&starting_indexes, &starting_indexes,
fetched, fetched,
exit, exit,
)?; )?;
info!("Computed prices in {:?}", i.elapsed());
} }
info!("Computing BLKs metadata..."); std::thread::scope(|scope| -> Result<()> {
self.blks let blks = scope.spawn(|| -> Result<()> {
.compute(indexer, &starting_indexes, parser, exit)?; 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<()> {
// let constants = scope.spawn(|| -> Result<()> { info!("Computing constants...");
info!("Computing constants..."); let i = Instant::now();
self.constants self.constants
.compute(&self.indexes, &starting_indexes, exit)?; .compute(&self.indexes, &starting_indexes, exit)?;
// Ok(()) info!("Computed constants in {:?}", i.elapsed());
// }); Ok(())
});
// let chain = scope.spawn(|| -> Result<()> { let chain = scope.spawn(|| -> Result<()> {
info!("Computing chain..."); info!("Computing chain...");
self.chain.compute( let i = Instant::now();
indexer, self.chain.compute(
&self.indexes, indexer,
&starting_indexes, &self.indexes,
self.price.as_ref(), &starting_indexes,
exit, self.price.as_ref(),
)?; exit,
// Ok(()) )?;
// }); info!("Computed chain in {:?}", i.elapsed());
Ok(())
});
if let Some(price) = self.price.as_ref() { if let Some(price) = self.price.as_ref() {
info!("Computing market..."); info!("Computing market...");
self.market.compute(price, &starting_indexes, exit)?; let i = Instant::now();
} self.market.compute(price, &starting_indexes, exit)?;
info!("Computed market in {:?}", i.elapsed());
}
return Ok(()); blks.join().unwrap()?;
constants.join().unwrap()?;
// constants.join().unwrap()?; chain.join().unwrap()?;
// chain.join().unwrap()?; Ok(())
// Ok(()) })?;
// })?;
info!("Computing pools...");
let i = Instant::now();
self.pools.compute( self.pools.compute(
indexer, indexer,
&self.indexes, &self.indexes,
@@ -214,6 +232,7 @@ impl Computer {
self.price.as_ref(), self.price.as_ref(),
exit, exit,
)?; )?;
info!("Computed pools in {:?}", i.elapsed());
info!("Computing stateful..."); info!("Computing stateful...");
self.stateful.compute( 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_p2wpkhaddressindex = &indexer.vecs.height_to_first_p2wpkhaddressindex;
let height_to_first_p2wshaddressindex = &indexer.vecs.height_to_first_p2wshaddressindex; 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_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_txinindex = &indexer.vecs.height_to_first_txinindex;
let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex; let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex;
let height_to_input_count = chain.indexes_to_input_count.height.unwrap_sum(); 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_p2wpkhaddressindex.version()
+ height_to_first_p2wshaddressindex.version() + height_to_first_p2wshaddressindex.version()
+ height_to_first_txindex.version() + height_to_first_txindex.version()
+ height_to_txindex_count.version()
+ height_to_first_txinindex.version() + height_to_first_txinindex.version()
+ height_to_first_txoutindex.version() + height_to_first_txoutindex.version()
+ height_to_input_count.version() + height_to_input_count.version()
@@ -778,6 +780,7 @@ impl Vecs {
let mut height_to_first_p2wshaddressindex_iter = let mut height_to_first_p2wshaddressindex_iter =
height_to_first_p2wshaddressindex.into_iter(); height_to_first_p2wshaddressindex.into_iter();
let mut height_to_first_txindex_iter = height_to_first_txindex.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_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_first_txoutindex_iter = height_to_first_txoutindex.into_iter();
let mut height_to_input_count_iter = height_to_input_count.into_iter(); let mut height_to_input_count_iter = height_to_input_count.into_iter();

View File

@@ -33,14 +33,20 @@ impl From<String> for Address {
impl TryFrom<&ScriptBuf> for Address { impl TryFrom<&ScriptBuf> for Address {
type Error = Error; type Error = Error;
fn try_from(script: &ScriptBuf) -> Result<Self, Self::Error> { fn try_from(script: &ScriptBuf) -> Result<Self, Self::Error> {
Self::try_from(&AddressBytes::try_from(script)?) Self::try_from((script, OutputType::from(script)))
} }
} }
impl TryFrom<(&ScriptBuf, OutputType)> for Address { impl TryFrom<(&ScriptBuf, OutputType)> for Address {
type Error = Error; type Error = Error;
fn try_from(tuple: (&ScriptBuf, OutputType)) -> Result<Self, Self::Error> { fn try_from((script, outputtype): (&ScriptBuf, OutputType)) -> Result<Self, Self::Error> {
Self::try_from(&AddressBytes::try_from(tuple)?) if outputtype.is_address() {
Ok(Self {
address: script.to_hex_string(),
})
} else {
Err(Error::InvalidAddress)
}
} }
} }