global: multiple fixes

This commit is contained in:
nym21
2025-06-07 09:30:42 +02:00
parent cc0f9c42df
commit 51bcbeb48f
28 changed files with 591 additions and 560 deletions

115
Cargo.lock generated
View File

@@ -75,9 +75,9 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.6.18"
version = "0.6.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
dependencies = [
"anstyle",
"anstyle-parse",
@@ -90,33 +90,33 @@ dependencies = [
[[package]]
name = "anstyle"
version = "1.0.10"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.8"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
dependencies = [
"anstyle",
"once_cell_polyfill",
@@ -273,6 +273,26 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"
[[package]]
name = "bincode"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740"
dependencies = [
"bincode_derive",
"serde",
"unty",
]
[[package]]
name = "bincode_derive"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09"
dependencies = [
"virtue",
]
[[package]]
name = "bitcoin"
version = "0.32.6"
@@ -435,6 +455,7 @@ dependencies = [
name = "brk_core"
version = "0.0.40"
dependencies = [
"bincode",
"bitcoin",
"bitcoincore-rpc",
"byteview",
@@ -567,8 +588,10 @@ dependencies = [
name = "brk_state"
version = "0.0.40"
dependencies = [
"bincode",
"brk_core",
"brk_store",
"derive_deref",
"fjall",
"serde",
"zerocopy",
@@ -688,9 +711,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.25"
version = "1.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951"
checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac"
dependencies = [
"jobserver",
"libc",
@@ -800,9 +823,9 @@ dependencies = [
[[package]]
name = "colorchoice"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "compact_str"
@@ -1390,9 +1413,9 @@ dependencies = [
[[package]]
name = "hyper-util"
version = "0.1.13"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c293b6b3d21eca78250dc7dbebd6b9210ec5530e038cbfe0661b5c47ab06e8"
checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb"
dependencies = [
"bytes",
"futures-core",
@@ -1597,9 +1620,9 @@ dependencies = [
[[package]]
name = "liblzma-sys"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5839bad90c3cc2e0b8c4ed8296b80e86040240f81d46b9c0e9bc8dd51ddd3af1"
checksum = "01b9596486f6d60c3bbe644c0e1be1aa6ccc472ad630fe8927b456973d7cb736"
dependencies = [
"cc",
"libc",
@@ -1608,9 +1631,9 @@ dependencies = [
[[package]]
name = "libz-rs-sys"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a"
checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221"
dependencies = [
"zlib-rs",
]
@@ -2217,9 +2240,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "petgraph"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a98c6720655620a521dcc722d0ad66cd8afd5d86e34a89ef691c50b7b24de06"
checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca"
dependencies = [
"fixedbitset",
"hashbrown 0.15.3",
@@ -2289,9 +2312,9 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "portable-atomic"
version = "1.11.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
[[package]]
name = "portable-atomic-util"
@@ -2657,9 +2680,9 @@ dependencies = [
[[package]]
name = "serde_spanned"
version = "0.6.8"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
dependencies = [
"serde",
]
@@ -2977,9 +3000,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.8.22"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
"serde_spanned",
@@ -2989,18 +3012,18 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.6.9"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.22.26"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap 2.9.0",
"serde",
@@ -3012,9 +3035,9 @@ dependencies = [
[[package]]
name = "toml_write"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "tower"
@@ -3078,9 +3101,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.28"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662"
dependencies = [
"proc-macro2",
"quote",
@@ -3089,9 +3112,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.33"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
dependencies = [
"once_cell",
"valuable",
@@ -3154,6 +3177,12 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "unty"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
[[package]]
name = "utf8parse"
version = "0.2.2"
@@ -3195,6 +3224,12 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "virtue"
version = "0.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
[[package]]
name = "vsimd"
version = "0.8.0"
@@ -3513,9 +3548,9 @@ dependencies = [
[[package]]
name = "zlib-rs"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8"
checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a"
[[package]]
name = "zopfli"

View File

@@ -19,6 +19,7 @@ inherits = "release"
[workspace.dependencies]
arc-swap = "1.7.1"
axum = "0.8.4"
bincode = { version = "2.0.1", features = ["serde"] }
bitcoin = { version = "0.32.6", features = ["serde"] }
bitcoincore-rpc = "0.19.0"
brk_cli = { version = "0", path = "crates/brk_cli" }
@@ -45,6 +46,7 @@ log = { version = "0.4.27" }
minreq = { version = "2.13.4", features = ["https", "serde_json"] }
rayon = "1.10.0"
serde = { version = "1.0.219" }
serde_bytes = "0.11.17"
serde_derive = "1.0.219"
serde_json = { version = "1.0.140", features = ["float_roundtrip"] }
tabled = "0.20.0"

View File

@@ -26,7 +26,7 @@ log = { workspace = true }
serde = { workspace = true }
tabled = { workspace = true }
tokio = { workspace = true }
toml = "0.8.22"
toml = "0.8.23"
[[bin]]
name = "brk"

View File

@@ -54,7 +54,6 @@ impl Computer {
self.fetcher.is_some(),
computation,
self.format,
indexer.keyspace(),
)?);
Ok(())
}

View File

@@ -5,7 +5,6 @@ use brk_exit::Exit;
use brk_fetcher::Fetcher;
use brk_indexer::Indexer;
use brk_vec::{AnyCollectableVec, Computation, Format};
use fjall::TransactionalKeyspace;
pub mod blocks;
pub mod constants;
@@ -42,7 +41,6 @@ impl Vecs {
fetch: bool,
computation: Computation,
format: Format,
keyspace: &TransactionalKeyspace,
) -> color_eyre::Result<Self> {
fs::create_dir_all(path)?;
@@ -95,7 +93,6 @@ impl Vecs {
computation,
format,
fetched.as_ref(),
keyspace,
)?,
transactions: transactions::Vecs::forced_import(
path,

View File

@@ -11,7 +11,6 @@ use brk_vec::{
AnyCollectableVec, AnyIterableVec, AnyVec, Computation, EagerVec, Format, StoredIndex,
VecIterator,
};
use fjall::TransactionalKeyspace;
use crate::vecs::{
Indexes, fetched,
@@ -129,8 +128,7 @@ impl Vecs {
format: Format,
version: Version,
fetched: Option<&fetched::Vecs>,
keyspace: &TransactionalKeyspace,
stores_path: &Path,
states_path: &Path,
compute_relative_to_all: bool,
) -> color_eyre::Result<Self> {
let compute_dollars = fetched.is_some();
@@ -142,10 +140,8 @@ impl Vecs {
let suffix = |s: &str| cohort_name.map_or(s.to_string(), |name| format!("{name}_{s}"));
let state = CohortState::default_and_import(
keyspace,
stores_path,
states_path,
cohort_name.unwrap_or_default(),
version + VERSION + Version::ZERO,
compute_dollars,
)?;
@@ -671,7 +667,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("net_unrealized_profit_and_loss_relative_to_market_cap"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -683,7 +679,7 @@ impl Vecs {
path,
&suffix("net_unrealized_profit_and_loss_relative_to_market_cap"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -740,7 +736,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_even_relative_to_own_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -749,7 +745,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_in_loss_relative_to_own_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -758,7 +754,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_in_profit_relative_to_own_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -768,7 +764,7 @@ impl Vecs {
path,
&suffix("supply_even_relative_to_own_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -779,7 +775,7 @@ impl Vecs {
path,
&suffix("supply_in_loss_relative_to_own_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -790,7 +786,7 @@ impl Vecs {
path,
&suffix("supply_in_profit_relative_to_own_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -801,7 +797,7 @@ impl Vecs {
path,
&suffix("supply_relative_to_circulating_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -813,7 +809,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_even_relative_to_circulating_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -824,7 +820,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_in_loss_relative_to_circulating_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -835,7 +831,7 @@ impl Vecs {
EagerVec::forced_import(
path,
&suffix("supply_in_profit_relative_to_circulating_supply"),
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
)
.unwrap()
@@ -847,7 +843,7 @@ impl Vecs {
path,
&suffix("supply_even_relative_to_circulating_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -860,7 +856,7 @@ impl Vecs {
path,
&suffix("supply_in_loss_relative_to_circulating_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -873,7 +869,7 @@ impl Vecs {
path,
&suffix("supply_in_profit_relative_to_circulating_supply"),
true,
version + VERSION + Version::ZERO,
version + VERSION + Version::ONE,
format,
StorableVecGeneatorOptions::default().add_last(),
)
@@ -986,8 +982,6 @@ impl Vecs {
.into_iter()
.unwrap_get_inner(prev_height);
self.state.price_to_amount.copy_db_to_puts();
if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() {
self.state.realized.as_mut().unwrap().cap = height_to_realized_cap
.into_iter()
@@ -1300,7 +1294,7 @@ impl Vecs {
height,
self.state
.price_to_amount
.puts_first_key_value()
.first_key_value()
.map(|(&dollars, _)| dollars)
.unwrap_or(Dollars::NAN),
exit,
@@ -1312,7 +1306,7 @@ impl Vecs {
height,
self.state
.price_to_amount
.puts_last_key_value()
.last_key_value()
.map(|(&dollars, _)| dollars)
.unwrap_or(Dollars::NAN),
exit,
@@ -2339,8 +2333,8 @@ impl Vecs {
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_even.as_ref().unwrap(),
&self.height_to_supply,
&self.height_to_supply_even_value.as_ref().unwrap().bitcoin,
&self.height_to_supply_value.bitcoin,
exit,
)?;
self.height_to_supply_in_loss_relative_to_own_supply
@@ -2348,8 +2342,12 @@ impl Vecs {
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_in_loss.as_ref().unwrap(),
&self.height_to_supply,
&self
.height_to_supply_in_loss_value
.as_ref()
.unwrap()
.bitcoin,
&self.height_to_supply_value.bitcoin,
exit,
)?;
self.height_to_supply_in_profit_relative_to_own_supply
@@ -2357,8 +2355,12 @@ impl Vecs {
.unwrap()
.compute_percentage(
starting_indexes.height,
self.height_to_supply_even.as_ref().unwrap(),
&self.height_to_supply,
&self
.height_to_supply_in_profit_value
.as_ref()
.unwrap()
.bitcoin,
&self.height_to_supply_value.bitcoin,
exit,
)?;
self.indexes_to_supply_even_relative_to_own_supply
@@ -2372,8 +2374,14 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
self.indexes_to_supply_even
.as_ref()
.unwrap()
.bitcoin
.dateindex
.as_ref()
.unwrap(),
self.indexes_to_supply.bitcoin.dateindex.as_ref().unwrap(),
exit,
)
},
@@ -2389,8 +2397,14 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
self.indexes_to_supply_in_loss
.as_ref()
.unwrap()
.bitcoin
.dateindex
.as_ref()
.unwrap(),
self.indexes_to_supply.bitcoin.dateindex.as_ref().unwrap(),
exit,
)
},
@@ -2406,8 +2420,14 @@ impl Vecs {
|v, _, _, starting_indexes, exit| {
v.compute_percentage(
starting_indexes.dateindex,
self.dateindex_to_supply_even.as_ref().unwrap(),
self.indexes_to_supply.sats.dateindex.as_ref().unwrap(),
self.indexes_to_supply_in_profit
.as_ref()
.unwrap()
.bitcoin
.dateindex
.as_ref()
.unwrap(),
self.indexes_to_supply.bitcoin.dateindex.as_ref().unwrap(),
exit,
)
},

View File

@@ -7,7 +7,6 @@ use brk_vec::{
AnyCollectableVec, AnyVec, BaseVecIterator, CollectableVec, Computation, EagerVec, Format,
GenericStoredVec, StoredIndex, StoredVec, UnsafeSlice, VecIterator,
};
use fjall::TransactionalKeyspace;
use log::info;
use outputs::OutputCohorts;
use rayon::prelude::*;
@@ -29,7 +28,7 @@ use super::{
pub mod cohort;
mod outputs;
const VERSION: Version = Version::new(4);
const VERSION: Version = Version::new(5);
#[derive(Clone)]
pub struct Vecs {
@@ -50,15 +49,13 @@ impl Vecs {
_computation: Computation,
format: Format,
fetched: Option<&fetched::Vecs>,
keyspace: &TransactionalKeyspace,
) -> color_eyre::Result<Self> {
let compute_dollars = fetched.is_some();
let mut root_path = path.to_owned();
root_path.pop();
let states_path = root_path.join("states");
root_path.pop();
let stores_path = root_path.join("stores");
let states_path = root_path.join("states");
Ok(Self {
chain_state: StoredVec::forced_import(
@@ -107,8 +104,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
false,
)?,
by_term: OutputsByTerm {
@@ -119,8 +115,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
long: cohort::Vecs::forced_import(
@@ -130,8 +125,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -143,8 +137,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1w: cohort::Vecs::forced_import(
@@ -154,8 +147,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1m: cohort::Vecs::forced_import(
@@ -165,8 +157,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2m: cohort::Vecs::forced_import(
@@ -176,8 +167,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3m: cohort::Vecs::forced_import(
@@ -187,8 +177,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4m: cohort::Vecs::forced_import(
@@ -198,8 +187,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5m: cohort::Vecs::forced_import(
@@ -209,8 +197,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6m: cohort::Vecs::forced_import(
@@ -220,8 +207,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1y: cohort::Vecs::forced_import(
@@ -231,8 +217,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2y: cohort::Vecs::forced_import(
@@ -242,8 +227,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3y: cohort::Vecs::forced_import(
@@ -253,8 +237,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4y: cohort::Vecs::forced_import(
@@ -264,8 +247,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5y: cohort::Vecs::forced_import(
@@ -275,8 +257,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6y: cohort::Vecs::forced_import(
@@ -286,8 +267,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_7y: cohort::Vecs::forced_import(
@@ -297,8 +277,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_8y: cohort::Vecs::forced_import(
@@ -308,8 +287,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10y: cohort::Vecs::forced_import(
@@ -319,8 +297,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_15y: cohort::Vecs::forced_import(
@@ -330,8 +307,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -343,8 +319,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1w: cohort::Vecs::forced_import(
@@ -354,8 +329,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1m: cohort::Vecs::forced_import(
@@ -365,8 +339,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2m: cohort::Vecs::forced_import(
@@ -376,8 +349,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3m: cohort::Vecs::forced_import(
@@ -387,8 +359,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4m: cohort::Vecs::forced_import(
@@ -398,8 +369,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5m: cohort::Vecs::forced_import(
@@ -409,8 +379,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6m: cohort::Vecs::forced_import(
@@ -420,8 +389,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1y: cohort::Vecs::forced_import(
@@ -431,8 +399,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2y: cohort::Vecs::forced_import(
@@ -442,8 +409,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3y: cohort::Vecs::forced_import(
@@ -453,8 +419,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4y: cohort::Vecs::forced_import(
@@ -464,8 +429,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5y: cohort::Vecs::forced_import(
@@ -475,8 +439,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6y: cohort::Vecs::forced_import(
@@ -486,8 +449,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_7y: cohort::Vecs::forced_import(
@@ -497,8 +459,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_8y: cohort::Vecs::forced_import(
@@ -508,8 +469,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10y: cohort::Vecs::forced_import(
@@ -519,8 +479,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_15y: cohort::Vecs::forced_import(
@@ -530,8 +489,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -543,8 +501,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1d_to_1w: cohort::Vecs::forced_import(
@@ -554,8 +511,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1w_to_1m: cohort::Vecs::forced_import(
@@ -565,8 +521,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1m_to_2m: cohort::Vecs::forced_import(
@@ -576,8 +531,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2m_to_3m: cohort::Vecs::forced_import(
@@ -587,8 +541,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3m_to_4m: cohort::Vecs::forced_import(
@@ -598,8 +551,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4m_to_5m: cohort::Vecs::forced_import(
@@ -609,8 +561,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5m_to_6m: cohort::Vecs::forced_import(
@@ -620,8 +571,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6m_to_1y: cohort::Vecs::forced_import(
@@ -631,8 +581,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1y_to_2y: cohort::Vecs::forced_import(
@@ -642,8 +591,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2y_to_3y: cohort::Vecs::forced_import(
@@ -653,8 +601,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3y_to_4y: cohort::Vecs::forced_import(
@@ -664,8 +611,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4y_to_5y: cohort::Vecs::forced_import(
@@ -675,8 +621,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_5y_to_6y: cohort::Vecs::forced_import(
@@ -686,8 +631,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_6y_to_7y: cohort::Vecs::forced_import(
@@ -697,8 +641,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_7y_to_8y: cohort::Vecs::forced_import(
@@ -708,8 +651,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_8y_to_10y: cohort::Vecs::forced_import(
@@ -719,8 +661,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10y_to_15y: cohort::Vecs::forced_import(
@@ -730,8 +671,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_15y_to_end: cohort::Vecs::forced_import(
@@ -741,8 +681,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -754,8 +693,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1: cohort::Vecs::forced_import(
@@ -765,8 +703,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_2: cohort::Vecs::forced_import(
@@ -776,8 +713,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_3: cohort::Vecs::forced_import(
@@ -787,8 +723,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_4: cohort::Vecs::forced_import(
@@ -798,8 +733,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -811,8 +745,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_1sat_to_10sats: cohort::Vecs::forced_import(
@@ -822,8 +755,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_10sats_to_100sats: cohort::Vecs::forced_import(
@@ -833,8 +765,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_100sats_to_1_000sats: cohort::Vecs::forced_import(
@@ -844,8 +775,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_1_000sats_to_10_000sats: cohort::Vecs::forced_import(
@@ -855,8 +785,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_10_000sats_to_100_000sats: cohort::Vecs::forced_import(
@@ -866,8 +795,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_100_000sats_to_1_000_000sats: cohort::Vecs::forced_import(
@@ -877,8 +805,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_1_000_000sats_to_10_000_000sats: cohort::Vecs::forced_import(
@@ -888,8 +815,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_10_000_000sats_to_1btc: cohort::Vecs::forced_import(
@@ -899,8 +825,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_1btc_to_10btc: cohort::Vecs::forced_import(
@@ -910,8 +835,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_10btc_to_100btc: cohort::Vecs::forced_import(
@@ -921,8 +845,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_100btc_to_1_000btc: cohort::Vecs::forced_import(
@@ -932,8 +855,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_1_000btc_to_10_000btc: cohort::Vecs::forced_import(
@@ -943,8 +865,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_10_000btc_to_100_000btc: cohort::Vecs::forced_import(
@@ -954,8 +875,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
from_100_000btc: cohort::Vecs::forced_import(
@@ -965,8 +885,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -978,8 +897,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10_000sats: cohort::Vecs::forced_import(
@@ -989,8 +907,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1btc: cohort::Vecs::forced_import(
@@ -1000,8 +917,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10btc: cohort::Vecs::forced_import(
@@ -1011,8 +927,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_100btc: cohort::Vecs::forced_import(
@@ -1022,8 +937,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -1035,8 +949,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_1btc: cohort::Vecs::forced_import(
@@ -1046,8 +959,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_10btc: cohort::Vecs::forced_import(
@@ -1057,8 +969,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
_100btc: cohort::Vecs::forced_import(
@@ -1068,8 +979,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -1174,8 +1084,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2pk33: cohort::Vecs::forced_import(
@@ -1185,8 +1094,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2pkh: cohort::Vecs::forced_import(
@@ -1196,8 +1104,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2ms: cohort::Vecs::forced_import(
@@ -1207,8 +1114,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2sh: cohort::Vecs::forced_import(
@@ -1218,8 +1124,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2wpkh: cohort::Vecs::forced_import(
@@ -1229,8 +1134,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2wsh: cohort::Vecs::forced_import(
@@ -1240,8 +1144,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2tr: cohort::Vecs::forced_import(
@@ -1251,8 +1154,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
p2a: cohort::Vecs::forced_import(
@@ -1262,8 +1164,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
empty: cohort::Vecs::forced_import(
@@ -1273,8 +1174,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
unknown: cohort::Vecs::forced_import(
@@ -1284,8 +1184,7 @@ impl Vecs {
format,
version + VERSION + Version::ZERO,
fetched,
keyspace,
&stores_path,
&states_path,
true,
)?,
},
@@ -1434,7 +1333,7 @@ impl Vecs {
info!("Starting processing utxos from the start");
separate_utxo_vecs
.par_iter_mut()
.try_for_each(|(_, v)| v.state.price_to_amount.reset_partition())?;
.try_for_each(|(_, v)| v.state.price_to_amount.reset())?;
}
let starting_height = starting_indexes
.height

View File

@@ -109,12 +109,8 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
);
});
sent.by_type
.spendable
.as_typed_vec()
.into_iter()
.filter(|(_, suply_state)| suply_state.utxos > 0)
.for_each(|(output_type, supply_state)| {
sent.by_type.spendable.as_typed_vec().into_iter().for_each(
|(output_type, supply_state)| {
self.by_type.get_mut(output_type).1.state.send(
supply_state,
current_price,
@@ -123,7 +119,8 @@ impl OutputCohorts for Outputs<(OutputFilter, cohort::Vecs)> {
days_old_foat,
older_than_hour,
)
});
},
);
sent.by_size_group
.into_iter()

View File

@@ -8,6 +8,7 @@ homepage.workspace = true
repository.workspace = true
[dependencies]
bincode = { workspace = true }
bitcoin = { workspace = true }
bitcoincore-rpc = { workspace = true }
byteview = { workspace = true }
@@ -18,7 +19,7 @@ log = { workspace = true }
rapidhash = "1.4.0"
rlimit = "0.10.2"
serde = { workspace = true }
serde_bytes = "0.11.17"
serde_bytes = { workspace = true }
serde_json = { workspace = true }
zerocopy = { workspace = true }
zerocopy-derive = { workspace = true }

View File

@@ -15,6 +15,8 @@ pub enum Error {
Fjall(fjall::Error),
SystemTimeError(time::SystemTimeError),
ZeroCopyError,
BincodeEncodeError(bincode::error::EncodeError),
BincodeDecodeError(bincode::error::DecodeError),
WrongEndian,
DifferentVersion { found: Version, expected: Version },
@@ -77,6 +79,18 @@ impl From<serde_json::Error> for Error {
}
}
impl From<bincode::error::DecodeError> for Error {
fn from(error: bincode::error::DecodeError) -> Self {
Self::BincodeDecodeError(error)
}
}
impl From<bincode::error::EncodeError> for Error {
fn from(error: bincode::error::EncodeError) -> Self {
Self::BincodeEncodeError(error)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
@@ -85,6 +99,8 @@ impl fmt::Display for Error {
Error::SerdeJson(error) => Debug::fmt(&error, f),
Error::Jiff(error) => Debug::fmt(&error, f),
Error::Fjall(error) => Debug::fmt(&error, f),
Error::BincodeDecodeError(error) => Debug::fmt(&error, f),
Error::BincodeEncodeError(error) => Debug::fmt(&error, f),
Error::ZeroCopyError => write!(f, "ZeroCopy error"),
Error::WrongEndian => write!(f, "Wrong endian"),

View File

@@ -35,9 +35,10 @@ impl Mul<usize> for Bitcoin {
}
impl Div<Bitcoin> for Bitcoin {
type Output = Self;
type Output = StoredF64;
fn div(self, rhs: Bitcoin) -> Self::Output {
Self::from(Sats::from(self) / Sats::from(rhs))
StoredF64::from(self.0 / rhs.0)
// Self::from(Sats::from(self) / Sats::from(rhs))
}
}

View File

@@ -24,6 +24,12 @@ use super::Dollars;
)]
pub struct Cents(i64);
impl Cents {
pub const fn mint(value: i64) -> Self {
Self(value)
}
}
impl From<Dollars> for Cents {
fn from(value: Dollars) -> Self {
Self((*value * 100.0).round() as i64)
@@ -48,6 +54,15 @@ impl From<u64> for Cents {
}
}
impl From<Cents> for usize {
fn from(value: Cents) -> Self {
if value.0 < 0 {
panic!()
}
value.0 as usize
}
}
impl From<usize> for Cents {
fn from(value: usize) -> Self {
Self(value as i64)
@@ -76,6 +91,13 @@ impl Add for Cents {
}
}
impl Div<Cents> for Cents {
type Output = Self;
fn div(self, rhs: Self) -> Self::Output {
Self(self.0 / rhs.0)
}
}
impl Div<usize> for Cents {
type Output = Self;
fn div(self, rhs: usize) -> Self::Output {

View File

@@ -4,9 +4,10 @@ use std::{
ops::{Add, AddAssign, Div, Mul},
};
use bincode::{Decode, Encode};
use byteview::ByteView;
use derive_deref::Deref;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{CheckedSub, copy_first_8bytes};
@@ -14,7 +15,19 @@ use crate::{CheckedSub, copy_first_8bytes};
use super::{Bitcoin, Cents, Close, High, Sats, StoredF32, StoredF64};
#[derive(
Debug, Default, Clone, Copy, Deref, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize,
Debug,
Default,
Clone,
Copy,
Deref,
FromBytes,
Immutable,
IntoBytes,
KnownLayout,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct Dollars(f64);
@@ -85,10 +98,10 @@ impl Add for Dollars {
impl Div<Dollars> for Dollars {
type Output = StoredF64;
fn div(self, rhs: Dollars) -> Self::Output {
if self.is_nan() {
StoredF64::from(self.0)
if self.is_nan() || rhs == Dollars::ZERO {
StoredF64::NAN
} else {
StoredF64::from(self.0 / rhs.0)
StoredF64::from(f64::from(self) / f64::from(rhs))
}
}
}
@@ -96,10 +109,10 @@ impl Div<Dollars> for Dollars {
impl Div<Close<Dollars>> for Dollars {
type Output = StoredF64;
fn div(self, rhs: Close<Dollars>) -> Self::Output {
if self.is_nan() {
StoredF64::from(self.0)
if self.is_nan() || *rhs == Dollars::ZERO {
StoredF64::NAN
} else {
StoredF64::from(self.0 / rhs.0)
StoredF64::from(f64::from(self) / f64::from(*rhs))
}
}
}
@@ -107,10 +120,10 @@ impl Div<Close<Dollars>> for Dollars {
impl Div<Dollars> for Close<Dollars> {
type Output = StoredF64;
fn div(self, rhs: Dollars) -> Self::Output {
if self.is_nan() {
StoredF64::from(self.0)
if self.is_nan() || rhs == Dollars::ZERO {
StoredF64::NAN
} else {
StoredF64::from(self.0 / rhs.0)
StoredF64::from(f64::from(*self) / f64::from(rhs))
}
}
}
@@ -118,8 +131,8 @@ impl Div<Dollars> for Close<Dollars> {
impl Div<usize> for Dollars {
type Output = Self;
fn div(self, rhs: usize) -> Self::Output {
if self.is_nan() {
self
if self.is_nan() || rhs == 0 {
Dollars::NAN
} else {
Self::from(Cents::from(self) / rhs)
}
@@ -158,6 +171,13 @@ impl Mul<Dollars> for Close<Dollars> {
}
}
impl Mul<usize> for Close<Dollars> {
type Output = Dollars;
fn mul(self, rhs: usize) -> Self::Output {
Dollars::from(Cents::from(*self) * rhs)
}
}
impl Mul<Bitcoin> for Dollars {
type Output = Self;
fn mul(self, rhs: Bitcoin) -> Self::Output {

View File

@@ -3,9 +3,10 @@ use std::{
ops::{Add, AddAssign, Div, Mul, SubAssign},
};
use bincode::{Decode, Encode};
use bitcoin::Amount;
use byteview::ByteView;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{CheckedSub, copy_first_8bytes};
@@ -26,6 +27,9 @@ use super::{Bitcoin, Cents, Dollars, Height};
IntoBytes,
KnownLayout,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct Sats(u64);

View File

@@ -76,6 +76,12 @@ impl From<StoredF32> for f32 {
}
}
impl From<Dollars> for StoredF32 {
fn from(value: Dollars) -> Self {
StoredF32::from(f64::from(value))
}
}
impl Div<Dollars> for StoredF32 {
type Output = Self;
fn div(self, rhs: Dollars) -> Self::Output {

View File

@@ -1,5 +1,6 @@
use std::{
cmp::Ordering,
f64,
ops::{Add, Div, Mul},
};
@@ -7,13 +8,17 @@ use derive_deref::Deref;
use serde::Serialize;
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{Bitcoin, CheckedSub, Sats};
use crate::{Bitcoin, CheckedSub, Dollars};
#[derive(
Debug, Deref, Default, Clone, Copy, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize,
)]
pub struct StoredF64(f64);
impl StoredF64 {
pub const NAN: Self = Self(f64::NAN);
}
impl From<f64> for StoredF64 {
fn from(value: f64) -> Self {
Self(value)
@@ -59,6 +64,12 @@ impl From<StoredF64> for f64 {
}
}
impl From<Dollars> for StoredF64 {
fn from(value: Dollars) -> Self {
Self(f64::from(value))
}
}
impl CheckedSub<usize> for StoredF64 {
fn checked_sub(self, rhs: usize) -> Option<Self> {
Some(Self(self.0 - rhs as f64))
@@ -97,12 +108,6 @@ impl Ord for StoredF64 {
}
}
impl From<Sats> for StoredF64 {
fn from(value: Sats) -> Self {
Self(u64::from(value) as f64)
}
}
impl From<Bitcoin> for StoredF64 {
fn from(value: Bitcoin) -> Self {
Self(f64::from(value))

View File

@@ -17,7 +17,7 @@ use crate::{Close, Date, Dollars, Fetcher, High, Low, Open, fetchers::retry};
pub struct Binance {
path: Option<PathBuf>,
_1mn: Option<BTreeMap<Timestamp, OHLCCents>>,
_1d: Option<BTreeMap<Date, OHLCCents>>,
pub _1d: Option<BTreeMap<Date, OHLCCents>>,
har: Option<BTreeMap<Timestamp, OHLCCents>>,
}

View File

@@ -1,9 +1,9 @@
mod binance;
// mod kibo;
// mod kraken;
mod kraken;
mod retry;
pub use binance::*;
// pub use kibo::*;
// pub use kraken::*;
pub use kraken::*;
use retry::*;

View File

@@ -13,12 +13,12 @@ mod fetchers;
use fetchers::*;
use log::info;
const TRIES: usize = 12 * 60 * 2;
const TRIES: usize = 12 * 60;
#[derive(Clone)]
pub struct Fetcher {
binance: Binance,
// kraken: Kraken,
kraken: Kraken,
// kibo: Kibo,
}
@@ -30,7 +30,7 @@ impl Fetcher {
Ok(Self {
binance: Binance::init(hars_path),
// kraken: Kraken::default(),
kraken: Kraken::default(),
// kibo: Kibo::default(),
})
}
@@ -42,15 +42,16 @@ impl Fetcher {
fn get_date_(&mut self, date: Date, tries: usize) -> color_eyre::Result<OHLCCents> {
self.binance
.get_from_1d(&date)
// .or_else(|_| {
// // eprintln!("{e}");
// self.kibo.get_from_date(&date)
// })
.or_else(|_| {
// eprintln!("{e}");
self.kraken.get_from_1d(&date)
})
.or_else(|e| {
sleep(Duration::from_secs(30));
sleep(Duration::from_secs(60));
if tries < TRIES {
self.clear();
// dbg!(e, date, &self.binance._1d);
info!("Retrying to fetch date price...");
self.get_date_(date, tries + 1)
} else {
@@ -89,32 +90,32 @@ impl Fetcher {
.get_from_1mn(timestamp, previous_timestamp)
.unwrap_or_else(|_report| {
// eprintln!("{_report}");
// self.kraken
// .get_from_1mn(timestamp, previous_timestamp)
// .unwrap_or_else(|_report| {
// // eprintln!("{_report}");
// self.kibo.get_from_height(height).unwrap_or_else(|_report| {
// eprintln!("{_report}");
self.kraken
.get_from_1mn(timestamp, previous_timestamp)
.unwrap_or_else(|_report| {
// // eprintln!("{_report}");
// self.kibo.get_from_height(height).unwrap_or_else(|_report| {
// eprintln!("{_report}");
sleep(Duration::from_secs(30));
sleep(Duration::from_secs(60));
if tries < TRIES {
self.clear();
if tries < TRIES {
self.clear();
info!("Retrying to fetch height prices...");
// dbg!((height, timestamp, previous_timestamp));
info!("Retrying to fetch height prices...");
// dbg!((height, timestamp, previous_timestamp));
return self
.get_height_(height, timestamp, previous_timestamp, tries + 1)
.unwrap();
}
return self
.get_height_(height, timestamp, previous_timestamp, tries + 1)
.unwrap();
}
info!("Failed to fetch height prices");
info!("Failed to fetch height prices");
let date = Date::from(timestamp);
// eprintln!("{e}");
panic!(
"
let date = Date::from(timestamp);
// eprintln!("{e}");
panic!(
"
Can't find the price for: height: {height} - date: {date}
1mn APIs are limited to the last 16 hours for Binance's and the last 10 hours for Kraken's
How to fix this:
@@ -129,9 +130,9 @@ How to fix this:
8. Export to a har file (if there is no explicit button, click on the cog button)
9. Move the file to 'parser/imports/binance.har'
"
)
// })
// })
)
// })
})
});
Ok(ohlc)
@@ -182,6 +183,6 @@ How to fix this:
pub fn clear(&mut self) {
self.binance.clear();
// self.kibo.clear();
// self.kraken.clear();
self.kraken.clear();
}
}

View File

@@ -8,8 +8,10 @@ homepage.workspace = true
repository.workspace = true
[dependencies]
bincode = { workspace = true }
brk_core = { workspace = true }
brk_store = { workspace = true }
derive_deref = { workspace = true }
fjall = { workspace = true }
serde = { workspace = true }
zerocopy = { workspace = true }

View File

@@ -1,10 +1,8 @@
use std::{cmp::Ordering, path::Path};
use brk_core::{CheckedSub, Dollars, Height, Result, Sats, Version};
use brk_store::Store;
use fjall::TransactionalKeyspace;
use brk_core::{CheckedSub, Dollars, Height, Result, Sats};
use crate::UnrealizedState;
use crate::{PriceToAmount, UnrealizedState};
use super::{RealizedState, SupplyState};
@@ -14,29 +12,17 @@ pub struct CohortState {
pub realized: Option<RealizedState>,
pub satblocks_destroyed: Sats,
pub satdays_destroyed: Sats,
pub price_to_amount: Store<Dollars, Sats>,
pub price_to_amount: PriceToAmount,
}
impl CohortState {
pub fn default_and_import(
keyspace: &TransactionalKeyspace,
path: &Path,
name: &str,
version: Version,
compute_dollars: bool,
) -> Result<Self> {
pub fn default_and_import(path: &Path, name: &str, compute_dollars: bool) -> Result<Self> {
Ok(Self {
supply: SupplyState::default(),
realized: compute_dollars.then_some(RealizedState::NAN),
satblocks_destroyed: Sats::ZERO,
satdays_destroyed: Sats::ZERO,
price_to_amount: Store::import(
keyspace,
path,
&format!("{name}_price_to_amount"),
version + Version::new(3),
Some(None),
)?,
price_to_amount: PriceToAmount::forced_import(path, name),
})
}
@@ -50,41 +36,45 @@ impl CohortState {
pub fn increment(&mut self, supply_state: &SupplyState, price: Option<Dollars>) {
self.supply += supply_state;
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.increment(supply_state, price);
*self.price_to_amount.puts_entry_or_default(&price) += supply_state.value;
if supply_state.value > Sats::ZERO {
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.increment(supply_state, price);
*self.price_to_amount.entry(price).or_default() += supply_state.value;
}
}
}
pub fn decrement(&mut self, supply_state: &SupplyState, price: Option<Dollars>) {
self.supply -= supply_state;
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.decrement(supply_state, price);
self.decrement_price_to_amount(supply_state, price);
if supply_state.value > Sats::ZERO {
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.decrement(supply_state, price);
self.decrement_price_to_amount(supply_state, price);
}
}
}
fn decrement_price_to_amount(&mut self, supply_state: &SupplyState, price: Dollars) {
let amount = self.price_to_amount.puts_entry_or_default(&price);
let amount = self.price_to_amount.get_mut(&price).unwrap();
*amount -= supply_state.value;
if *amount == Sats::ZERO {
if self.price_to_amount.puts_remove(&price).is_none() {
unreachable!()
}
if !self.price_to_amount.dels_insert(price) {
unreachable!()
}
self.price_to_amount.remove(&price);
}
}
pub fn receive(&mut self, supply_state: &SupplyState, price: Option<Dollars>) {
self.supply += supply_state;
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.receive(supply_state, price);
*self.price_to_amount.puts_entry_or_default(&price) += supply_state.value;
if supply_state.value > Sats::ZERO {
if let Some(realized) = self.realized.as_mut() {
let price = price.unwrap();
realized.receive(supply_state, price);
*self.price_to_amount.entry(price).or_default() += supply_state.value;
}
}
}
@@ -99,16 +89,18 @@ impl CohortState {
) {
self.supply -= supply_state;
self.satblocks_destroyed += supply_state.value * blocks_old;
if supply_state.value > Sats::ZERO {
self.satblocks_destroyed += supply_state.value * blocks_old;
self.satdays_destroyed +=
Sats::from((u64::from(supply_state.value) as f64 * days_old).floor() as u64);
self.satdays_destroyed +=
Sats::from((u64::from(supply_state.value) as f64 * days_old).floor() as u64);
if let Some(realized) = self.realized.as_mut() {
let current_price = current_price.unwrap();
let prev_price = prev_price.unwrap();
realized.send(supply_state, current_price, prev_price, older_than_hour);
self.decrement_price_to_amount(supply_state, prev_price);
if let Some(realized) = self.realized.as_mut() {
let current_price = current_price.unwrap();
let prev_price = prev_price.unwrap();
realized.send(supply_state, current_price, prev_price, older_than_hour);
self.decrement_price_to_amount(supply_state, prev_price);
}
}
}
@@ -158,30 +150,23 @@ impl CohortState {
}
};
self.price_to_amount
.puts_iter()
.for_each(|(&price, &sats)| {
update_state(price, height_price, sats, &mut height_unrealized_state);
self.price_to_amount.iter().for_each(|(&price, &sats)| {
update_state(price, height_price, sats, &mut height_unrealized_state);
if let Some(date_price) = date_price {
update_state(
price,
date_price,
sats,
date_unrealized_state.as_mut().unwrap(),
)
}
});
if let Some(date_price) = date_price {
update_state(
price,
date_price,
sats,
date_unrealized_state.as_mut().unwrap(),
)
}
});
(height_unrealized_state, date_unrealized_state)
}
pub fn commit(&mut self, height: Height) -> Result<()> {
// self.price_to_amount
// .retain_or_del(|_, sats| *sats > Sats::ZERO);
let price_to_amount_puts = self.price_to_amount.clone_puts();
self.price_to_amount.commit(height)?;
self.price_to_amount.append_puts(price_to_amount_puts);
Ok(())
self.price_to_amount.flush(height)
}
}

View File

@@ -3,6 +3,7 @@ mod cohort;
mod outputs;
mod realized;
// mod hot;
mod price_to_amount;
mod supply;
mod transacted;
mod unrealized;
@@ -13,5 +14,6 @@ pub use outputs::*;
pub use realized::*;
pub use unrealized::*;
// pub use hot::*;
pub use price_to_amount::*;
pub use supply::*;
pub use transacted::*;

View File

@@ -0,0 +1,104 @@
use std::{
collections::BTreeMap,
fs::{self, File},
io::{BufReader, BufWriter},
ops::{Deref, DerefMut},
path::{Path, PathBuf},
};
use bincode::{Decode, Encode, config, decode_from_std_read, encode_into_std_write};
use brk_core::{Dollars, Height, Result, Sats};
use derive_deref::{Deref, DerefMut};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug)]
pub struct PriceToAmount {
pathbuf: PathBuf,
height: Option<Height>,
state: State,
}
#[derive(Clone, Default, Debug, Deref, DerefMut, Serialize, Deserialize, Encode, Decode)]
struct State(BTreeMap<Dollars, Sats>);
impl PriceToAmount {
pub fn forced_import(path: &Path, name: &str) -> Self {
Self::import(path, name).unwrap_or_else(|_| Self {
pathbuf: Self::path_(path, name),
height: None,
state: State::default(),
})
}
pub fn import(path: &Path, name: &str) -> Result<Self> {
let path = Self::path_(path, name);
fs::create_dir_all(&path)?;
let config = config::standard();
let file = File::open(Self::path_state_(&path))?;
let mut reader = BufReader::new(file);
let state = decode_from_std_read(&mut reader, config)?;
Ok(Self {
height: Height::try_from(Self::path_height_(&path).as_path()).ok(),
pathbuf: path,
state,
})
}
pub fn reset(&mut self) -> Result<()> {
self.clear();
self.height = None;
fs::remove_dir_all(&self.pathbuf)?;
fs::create_dir_all(&self.pathbuf)?;
Ok(())
}
pub fn flush(&mut self, height: Height) -> Result<()> {
self.height = Some(height);
height.write(&self.path_height())?;
let config = config::standard();
let file = File::create(self.path_state()).inspect_err(|_| {
dbg!(self.path_state());
})?;
let mut writer = BufWriter::new(file);
encode_into_std_write(&self.state, &mut writer, config)?;
Ok(())
}
pub fn height(&self) -> Option<Height> {
self.height
}
fn path_(path: &Path, name: &str) -> PathBuf {
path.join(format!("{name}_price_to_amount"))
}
fn path_state(&self) -> PathBuf {
Self::path_state_(&self.pathbuf)
}
fn path_state_(path: &Path) -> PathBuf {
path.join("state")
}
fn path_height(&self) -> PathBuf {
Self::path_height_(&self.pathbuf)
}
fn path_height_(path: &Path) -> PathBuf {
path.join("height")
}
}
impl Deref for PriceToAmount {
type Target = BTreeMap<Dollars, Sats>;
fn deref(&self) -> &Self::Target {
&self.state
}
}
impl DerefMut for PriceToAmount {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.state
}
}

View File

@@ -11,33 +11,9 @@ fn main() -> Result<()> {
let mut store: Store<Dollars, Sats> =
brk_store::Store::import(&keyspace, p, "n", Version::ZERO, None)?;
store.copy_db_to_puts();
*store.puts_entry_or_default(&Dollars::from(10.0)) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::from(1.0)) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::ZERO) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::ZERO) += Sats::ONE_BTC;
dbg!(store.tx_iter().collect::<Vec<_>>());
store.insert_if_needed(Dollars::from(10.0), Sats::FIFTY_BTC, Height::ZERO);
store.commit(Height::ZERO)?;
store.copy_db_to_puts();
dbg!(store.tx_iter().collect::<Vec<_>>());
*store.puts_entry_or_default(&Dollars::from(10.0)) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::from(1.0)) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::ZERO) += Sats::ONE_BTC;
*store.puts_entry_or_default(&Dollars::ZERO) += Sats::ONE_BTC;
dbg!(store.tx_iter().collect::<Vec<_>>());
store.commit(Height::from(1_u32))?;
store.copy_db_to_puts();
dbg!(store.tx_iter().collect::<Vec<_>>());
Ok(())
}

View File

@@ -31,7 +31,6 @@ pub struct Store<Key, Value> {
puts: BTreeMap<Key, Value>,
dels: BTreeSet<Key>,
bloom_filter_bits: Option<Option<u8>>,
override_partition: bool,
}
/// Use default if will read
@@ -81,7 +80,6 @@ where
puts: BTreeMap::new(),
dels: BTreeSet::new(),
bloom_filter_bits,
override_partition: false,
})
}
@@ -95,79 +93,33 @@ where
}
}
pub fn puts_first_key_value(&self) -> Option<(&K, &V)> {
self.puts.first_key_value()
}
// pub fn puts_first_key_value(&self) -> Option<(&K, &V)> {
// self.puts.first_key_value()
// }
pub fn puts_last_key_value(&self) -> Option<(&K, &V)> {
self.puts.last_key_value()
}
// pub fn puts_last_key_value(&self) -> Option<(&K, &V)> {
// self.puts.last_key_value()
// }
pub fn rtx_first_key_value(&self) -> Result<Option<(K, V)>> {
Ok(self
.rtx
.first_key_value(&self.partition.load())?
.map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v)))))
}
// pub fn rtx_first_key_value(&self) -> Result<Option<(K, V)>> {
// Ok(self
// .rtx
// .first_key_value(&self.partition.load())?
// .map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v)))))
// }
pub fn rtx_last_key_value(&self) -> Result<Option<(K, V)>> {
Ok(self
.rtx
.last_key_value(&self.partition.load())?
.map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v)))))
}
// pub fn rtx_last_key_value(&self) -> Result<Option<(K, V)>> {
// Ok(self
// .rtx
// .last_key_value(&self.partition.load())?
// .map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v)))))
// }
pub fn puts_entry_or_default(&mut self, key: &'a K) -> &mut V
where
V: Default,
{
if !self.dels.is_empty() {
self.dels.remove(key);
}
self.puts.entry(key.clone()).or_default()
}
pub fn puts_remove(&mut self, key: &K) -> Option<V> {
self.puts.remove(key)
}
pub fn dels_insert(&mut self, key: K) -> bool {
self.dels.insert(key)
}
pub fn tx_iter(&self) -> impl Iterator<Item = (K, V)> {
self.rtx
.iter(&self.partition.load())
.map(|res| res.unwrap())
.map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v))))
}
pub fn puts_iter(&self) -> impl Iterator<Item = (&K, &V)> {
self.puts.iter()
}
pub fn clone_puts(&self) -> BTreeMap<K, V> {
self.puts.clone()
}
pub fn append_puts(&mut self, mut other: BTreeMap<K, V>) {
self.puts.append(&mut other);
}
pub fn copy_db_to_puts(&mut self) {
self.override_partition = true;
self.append_puts(self.tx_iter().collect());
self.meta.reset_len();
}
// pub fn unordered_clone_iter(&self) -> impl Iterator<Item = (K, V)> {
// pub fn tx_iter(&self) -> impl Iterator<Item = (K, V)> {
// self.rtx
// .keys(&self.partition.load())
// .iter(&self.partition.load())
// .map(|res| res.unwrap())
// .map(|k| K::from(ByteView::from(k)))
// .filter(|k| !self.puts.contains_key(k) && !self.dels.contains(k))
// .map(|k| (k, self.rtx.get(partition, key) V::from(ByteView::from(v))))
// .chain(self.puts.iter().map(|(k, v)| (k.clone(), v.clone())))
// .map(|(k, v)| (K::from(ByteView::from(k)), V::from(ByteView::from(v))))
// }
pub fn insert_if_needed(&mut self, key: K, value: V, height: Height) {
@@ -215,10 +167,6 @@ where
self.meta.export(self.len(), height)?;
if self.override_partition {
self.reset_partition()?;
}
let mut wtx = self.keyspace.write_tx();
let partition = &self.partition.load();
@@ -338,7 +286,6 @@ where
puts: self.puts.clone(),
dels: self.dels.clone(),
bloom_filter_bits: self.bloom_filter_bits,
override_partition: self.override_partition,
}
}
}

View File

@@ -36,10 +36,7 @@ impl StoreMeta {
let mut partition = open_partition_handle()?;
let mut did_reset = false;
if !is_same_version {
did_reset = true;
Self::reset_(path)?;
keyspace.delete_partition(partition)?;
keyspace.persist(fjall::PersistMode::SyncAll)?;
@@ -48,11 +45,6 @@ impl StoreMeta {
let len = Self::read_length_(path);
if did_reset && len != 0 {
dbg!(&path);
unreachable!();
}
let slf = Self {
pathbuf: path.to_owned(),
version,
@@ -69,9 +61,6 @@ impl StoreMeta {
self.len
}
pub fn reset_len(&mut self) {
self.len = 0
}
// pub fn is_empty(&self) -> bool {
// self.len() == 0
// }

View File

@@ -344,7 +344,7 @@ where
self.safe_flush(exit)
}
pub fn compute_divide<T2, T3, T4>(
pub fn compute_divide<T2, T3, T4, T5>(
&mut self,
max_from: I,
divided: &impl AnyIterableVec<I, T2>,
@@ -352,15 +352,16 @@ where
exit: &Exit,
) -> Result<()>
where
T2: StoredType + Div<T3, Output = T4>,
T2: StoredType + Mul<usize, Output = T4>,
T3: StoredType,
T4: Mul<usize, Output = T4> + CheckedSub<usize>,
T: From<T4>,
T4: Div<T3, Output = T5> + From<T2>,
T5: CheckedSub<usize>,
T: From<T5>,
{
self.compute_divide_(max_from, divided, divider, exit, false, false)
}
pub fn compute_percentage<T2, T3, T4>(
pub fn compute_percentage<T2, T3, T4, T5>(
&mut self,
max_from: I,
divided: &impl AnyIterableVec<I, T2>,
@@ -368,15 +369,16 @@ where
exit: &Exit,
) -> Result<()>
where
T2: StoredType + Div<T3, Output = T4>,
T2: StoredType + Mul<usize, Output = T4>,
T3: StoredType,
T4: Mul<usize, Output = T4> + CheckedSub<usize>,
T: From<T4>,
T4: Div<T3, Output = T5> + From<T2>,
T5: CheckedSub<usize>,
T: From<T5>,
{
self.compute_divide_(max_from, divided, divider, exit, true, false)
}
pub fn compute_percentage_difference<T2, T3, T4>(
pub fn compute_percentage_difference<T2, T3, T4, T5>(
&mut self,
max_from: I,
divided: &impl AnyIterableVec<I, T2>,
@@ -384,15 +386,16 @@ where
exit: &Exit,
) -> Result<()>
where
T2: StoredType + Div<T3, Output = T4>,
T2: StoredType + Mul<usize, Output = T4>,
T3: StoredType,
T4: Mul<usize, Output = T4> + CheckedSub<usize>,
T: From<T4>,
T4: Div<T3, Output = T5> + From<T2>,
T5: CheckedSub<usize>,
T: From<T5>,
{
self.compute_divide_(max_from, divided, divider, exit, true, true)
}
pub fn compute_divide_<T2, T3, T4>(
pub fn compute_divide_<T2, T3, T4, T5>(
&mut self,
max_from: I,
divided: &impl AnyIterableVec<I, T2>,
@@ -402,10 +405,11 @@ where
as_difference: bool,
) -> Result<()>
where
T2: StoredType + Div<T3, Output = T4>,
T2: StoredType + Mul<usize, Output = T4>,
T3: StoredType,
T4: Mul<usize, Output = T4> + CheckedSub<usize>,
T: From<T4>,
T4: Div<T3, Output = T5> + From<T2>,
T5: CheckedSub<usize>,
T: From<T5>,
{
self.validate_computed_version_or_reset_file(
Version::ONE + self.inner.version() + divided.version() + divider.version(),
@@ -418,10 +422,13 @@ where
divided.iter_at(index).try_for_each(|(i, divided)| {
let divided = divided.into_inner();
let divider = divider_iter.unwrap_get_inner(i);
let mut v = divided / divider;
if as_percentage {
v = v * multiplier;
}
let v = if as_percentage {
divided * multiplier
} else {
T4::from(divided)
};
let mut v = v / divider;
if as_difference {
v = v.checked_sub(multiplier).unwrap();
}

View File

@@ -1256,6 +1256,15 @@ function createPartialOptions(colors) {
name: useGroupName ? name : "Supply",
color: "list" in args ? color : colors.default,
}),
...(key
? [
createBaseSeries({
key: `${key}supply-relative-to-circulating-supply`,
name: useGroupName ? name : "Supply",
color: "list" in args ? color : colors.default,
}),
]
: []),
...(!("list" in args)
? [
createBaseSeries({
@@ -1329,11 +1338,6 @@ function createPartialOptions(colors) {
}),
...(key
? [
createBaseSeries({
key: `${key}supply-relative-to-circulating-supply`,
name: useGroupName ? name : "Supply",
color: colors.default,
}),
createBaseSeries({
key: `${key}supply-in-profit-relative-to-circulating-supply`,
name: useGroupName ? name : "In Profit",
@@ -1791,16 +1795,6 @@ function createPartialOptions(colors) {
name: useGroupName ? name : "destroyed",
color,
}),
createBaseSeries({
key: `${key}coinblocks-destroyed`,
name: useGroupName ? name : "destroyed",
color,
}),
createBaseSeries({
key: `${key}coindays-destroyed`,
name: useGroupName ? name : "destroyed",
color,
}),
]);
}),
},