mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-19 15:08:12 -07:00
global: renames and fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_core::{GroupedBySizeRange, GroupedByType, OutputType, Sats};
|
||||
use brk_core::{ByAmountRange, GroupedByType, OutputType, Sats};
|
||||
|
||||
use super::SupplyState;
|
||||
|
||||
@@ -8,7 +8,7 @@ use super::SupplyState;
|
||||
pub struct Transacted {
|
||||
pub spendable_supply: SupplyState,
|
||||
pub by_type: GroupedByType<SupplyState>,
|
||||
pub by_size_group: GroupedBySizeRange<SupplyState>,
|
||||
pub by_size_group: ByAmountRange<SupplyState>,
|
||||
}
|
||||
|
||||
impl Transacted {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{path::Path, thread};
|
||||
|
||||
use brk_core::{
|
||||
AddressData, EmptyAddressData, GroupedByAddressType, Height, OutputType, P2AAddressIndex,
|
||||
AddressData, ByAddressType, EmptyAddressData, Height, OutputType, P2AAddressIndex,
|
||||
P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex,
|
||||
P2WPKHAddressIndex, P2WSHAddressIndex, Result, TypeIndex, Version,
|
||||
};
|
||||
@@ -375,7 +375,7 @@ impl Stores {
|
||||
WithAddressDataSource<EmptyAddressData>,
|
||||
>,
|
||||
) -> Result<()> {
|
||||
let GroupedByAddressType {
|
||||
let ByAddressType {
|
||||
p2pk65,
|
||||
p2pk33,
|
||||
p2pkh,
|
||||
@@ -386,7 +386,7 @@ impl Stores {
|
||||
p2a,
|
||||
} = addresstype_to_typeindex_to_addressdata.unwrap();
|
||||
|
||||
let GroupedByAddressType {
|
||||
let ByAddressType {
|
||||
p2pk65: empty_p2pk65,
|
||||
p2pk33: empty_p2pk33,
|
||||
p2pkh: empty_p2pkh,
|
||||
|
||||
@@ -7,7 +7,9 @@ use brk_core::{
|
||||
use brk_exit::Exit;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{AnyCollectableVec, AnyIterableVec, Computation, EagerVec, Format, StoredIndex};
|
||||
use brk_vec::{
|
||||
AnyCollectableVec, AnyIterableVec, AnyVec, Computation, EagerVec, Format, StoredIndex,
|
||||
};
|
||||
|
||||
use super::{
|
||||
Indexes,
|
||||
@@ -426,7 +428,13 @@ impl Vecs {
|
||||
starting_indexes.dateindex,
|
||||
&indexes.dateindex_to_date,
|
||||
|(di, d, this)| {
|
||||
let mut ohlc = fetcher.get_date(d).unwrap();
|
||||
let mut ohlc = fetcher.get_date(d).unwrap_or_else(|_| {
|
||||
this.get_or_read(di, &this.mmap().load())
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_owned()
|
||||
});
|
||||
|
||||
if let Some(prev) = di.decremented() {
|
||||
let prev_open = *this
|
||||
.get_or_read(prev, &this.mmap().load())
|
||||
|
||||
@@ -45,16 +45,6 @@ where
|
||||
) -> color_eyre::Result<Self> {
|
||||
let only_one_active = options.is_only_one_active();
|
||||
|
||||
let prefix = |s: &str| format!("{s}_{name}");
|
||||
|
||||
let maybe_prefix = |s: &str| {
|
||||
if only_one_active {
|
||||
name.to_string()
|
||||
} else {
|
||||
prefix(s)
|
||||
}
|
||||
};
|
||||
|
||||
let suffix = |s: &str| format!("{name}_{s}");
|
||||
|
||||
let maybe_suffix = |s: &str| {
|
||||
@@ -70,7 +60,7 @@ where
|
||||
Box::new(
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&maybe_prefix("first"),
|
||||
&maybe_suffix("first"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
@@ -130,7 +120,7 @@ where
|
||||
Box::new(
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&(if !options.last {
|
||||
&(if !options.last && !options.average && !options.min && !options.max {
|
||||
name.to_string()
|
||||
} else {
|
||||
maybe_suffix("sum")
|
||||
@@ -145,7 +135,7 @@ where
|
||||
Box::new(
|
||||
EagerVec::forced_import(
|
||||
path,
|
||||
&prefix("cumulative"),
|
||||
&suffix("cumulative"),
|
||||
version + VERSION + Version::ZERO,
|
||||
format,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_core::{
|
||||
AddressGroups, GroupFilter, GroupedByFromSize, GroupedBySizeRange, GroupedByUpToSize, Height,
|
||||
AddressGroups, ByAmountRange, ByGreatEqualAmount, ByLowerThanAmount, GroupFilter, Height,
|
||||
Result, Version,
|
||||
};
|
||||
use brk_exit::Exit;
|
||||
@@ -33,10 +33,10 @@ impl Vecs {
|
||||
) -> color_eyre::Result<Self> {
|
||||
Ok(Self(
|
||||
AddressGroups {
|
||||
by_size_range: GroupedBySizeRange {
|
||||
amount_range: ByAmountRange {
|
||||
_0sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_0sats"),
|
||||
Some("addrs_with_0sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -44,9 +44,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_1sat_to_10sats: address_cohort::Vecs::forced_import(
|
||||
_1sat_to_10sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1sat_to_10sats"),
|
||||
Some("addrs_above_1sat_under_10sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -54,9 +54,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_10sats_to_100sats: address_cohort::Vecs::forced_import(
|
||||
_10sats_to_100sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10sats_to_100sats"),
|
||||
Some("addrs_above_10sats_under_100sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -64,9 +64,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_100sats_to_1_000sats: address_cohort::Vecs::forced_import(
|
||||
_100sats_to_1k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100sats_to_1_000sats"),
|
||||
Some("addrs_above_100sats_under_1k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -74,9 +74,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_1_000sats_to_10_000sats: address_cohort::Vecs::forced_import(
|
||||
_1k_sats_to_10k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1_000sats_to_10_000sats"),
|
||||
Some("addrs_above_1k_sats_under_10k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -84,9 +84,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_10_000sats_to_100_000sats: address_cohort::Vecs::forced_import(
|
||||
_10k_sats_to_100k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10_000sats_to_100_000sats"),
|
||||
Some("addrs_above_10k_sats_under_100k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -94,9 +94,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_100_000sats_to_1_000_000sats: address_cohort::Vecs::forced_import(
|
||||
_100k_sats_to_1m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100_000sats_to_1_000_000sats"),
|
||||
Some("addrs_above_100k_sats_under_1m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -104,9 +104,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_1_000_000sats_to_10_000_000sats: address_cohort::Vecs::forced_import(
|
||||
_1m_sats_to_10m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1_000_000sats_to_10_000_000sats"),
|
||||
Some("addrs_above_1m_sats_under_10m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -114,9 +114,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_10_000_000sats_to_1btc: address_cohort::Vecs::forced_import(
|
||||
_10m_sats_to_1btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10_000_000sats_to_1btc"),
|
||||
Some("addrs_above_10m_sats_under_1btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -124,9 +124,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_1btc_to_10btc: address_cohort::Vecs::forced_import(
|
||||
_1btc_to_10btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1btc_to_10btc"),
|
||||
Some("addrs_above_1btc_under_10btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -134,9 +134,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_10btc_to_100btc: address_cohort::Vecs::forced_import(
|
||||
_10btc_to_100btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10btc_to_100btc"),
|
||||
Some("addrs_above_10btc_under_100btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -144,9 +144,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_100btc_to_1_000btc: address_cohort::Vecs::forced_import(
|
||||
_100btc_to_1k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100btc_to_1_000btc"),
|
||||
Some("addrs_above_100btc_under_1k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -154,9 +154,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_1_000btc_to_10_000btc: address_cohort::Vecs::forced_import(
|
||||
_1k_btc_to_10k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1_000btc_to_10_000btc"),
|
||||
Some("addrs_above_1k_btc_under_10k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -164,9 +164,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_10_000btc_to_100_000btc: address_cohort::Vecs::forced_import(
|
||||
_10k_btc_to_100k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10_000btc_to_100_000btc"),
|
||||
Some("addrs_above_10k_btc_under_100k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -174,9 +174,9 @@ impl Vecs {
|
||||
states_path,
|
||||
true,
|
||||
)?,
|
||||
from_100_000btc: address_cohort::Vecs::forced_import(
|
||||
_100k_btc_or_more: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100_000btc"),
|
||||
Some("addrs_above_100k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -185,10 +185,10 @@ impl Vecs {
|
||||
true,
|
||||
)?,
|
||||
},
|
||||
by_up_to_size: GroupedByUpToSize {
|
||||
lt_amount: ByLowerThanAmount {
|
||||
_10sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_10sats"),
|
||||
Some("addrs_under_10sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -198,7 +198,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_100sats"),
|
||||
Some("addrs_under_100sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -208,7 +208,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_1k_sats"),
|
||||
Some("addrs_under_1k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -218,7 +218,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_10k_sats"),
|
||||
Some("addrs_under_10k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -228,7 +228,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_100k_sats"),
|
||||
Some("addrs_under_100k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -238,7 +238,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_1m_sats"),
|
||||
Some("addrs_under_1m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -248,7 +248,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_10m_sats"),
|
||||
Some("addrs_under_10m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -258,7 +258,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_1btc"),
|
||||
Some("addrs_under_1btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -268,7 +268,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_10btc"),
|
||||
Some("addrs_under_10btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -278,7 +278,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_100btc"),
|
||||
Some("addrs_under_100btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -288,7 +288,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_1k_btc"),
|
||||
Some("addrs_under_1k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -298,7 +298,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_10k_btc"),
|
||||
Some("addrs_under_10k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -308,7 +308,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_up_to_100k_btc"),
|
||||
Some("addrs_under_100k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -317,10 +317,10 @@ impl Vecs {
|
||||
true,
|
||||
)?,
|
||||
},
|
||||
by_from_size: GroupedByFromSize {
|
||||
ge_amount: ByGreatEqualAmount {
|
||||
_1sat: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1sat"),
|
||||
Some("addrs_above_1sat"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -330,7 +330,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10sats"),
|
||||
Some("addrs_above_10sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -340,7 +340,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100sats"),
|
||||
Some("addrs_above_100sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -350,7 +350,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1k_sats"),
|
||||
Some("addrs_above_1k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -360,7 +360,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10k_sats"),
|
||||
Some("addrs_above_10k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -370,7 +370,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100k_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100k_sats"),
|
||||
Some("addrs_above_100k_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -380,7 +380,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1m_sats"),
|
||||
Some("addrs_above_1m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -390,7 +390,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10m_sats: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10m_sats"),
|
||||
Some("addrs_above_10m_sats"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -400,7 +400,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1btc"),
|
||||
Some("addrs_above_1btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -410,7 +410,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10btc"),
|
||||
Some("addrs_above_10btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -420,7 +420,7 @@ impl Vecs {
|
||||
)?,
|
||||
_100btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_100btc"),
|
||||
Some("addrs_above_100btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -430,7 +430,7 @@ impl Vecs {
|
||||
)?,
|
||||
_1k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_1k_btc"),
|
||||
Some("addrs_above_1k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -440,7 +440,7 @@ impl Vecs {
|
||||
)?,
|
||||
_10k_btc: address_cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("addresses_from_10k_btc"),
|
||||
Some("addrs_above_10k_btc"),
|
||||
_computation,
|
||||
format,
|
||||
version + VERSION + Version::ZERO,
|
||||
@@ -459,11 +459,11 @@ impl Vecs {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let by_size_range = self.0.by_size_range.as_vec();
|
||||
let by_size_range = self.0.amount_range.as_vec();
|
||||
|
||||
[
|
||||
self.0
|
||||
.by_from_size
|
||||
.ge_amount
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
@@ -478,7 +478,7 @@ impl Vecs {
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
self.0
|
||||
.by_up_to_size
|
||||
.lt_amount
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.map(|(filter, vecs)| {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
use brk_core::{GroupedByAddressType, Height};
|
||||
use brk_core::{ByAddressType, Height};
|
||||
use brk_vec::VecIterator;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
|
||||
use crate::vecs::stateful::addresstype_to_height_to_addresscount::AddressTypeToHeightToAddressCount;
|
||||
|
||||
#[derive(Debug, Default, Deref, DerefMut)]
|
||||
pub struct AddressTypeToAddressCount(GroupedByAddressType<usize>);
|
||||
pub struct AddressTypeToAddressCount(ByAddressType<usize>);
|
||||
|
||||
impl From<(&AddressTypeToHeightToAddressCount, Height)> for AddressTypeToAddressCount {
|
||||
fn from((groups, starting_height): (&AddressTypeToHeightToAddressCount, Height)) -> Self {
|
||||
if let Some(prev_height) = starting_height.decremented() {
|
||||
Self(GroupedByAddressType {
|
||||
Self(ByAddressType {
|
||||
p2pk65: groups
|
||||
.p2pk65
|
||||
.into_iter()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_core::{GroupedByAddressType, Height, Result, StoredUsize};
|
||||
use brk_core::{ByAddressType, Height, Result, StoredUsize};
|
||||
use brk_exit::Exit;
|
||||
use brk_vec::EagerVec;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
@@ -6,12 +6,10 @@ use derive_deref::{Deref, DerefMut};
|
||||
use crate::vecs::stateful::addresstype_to_addresscount::AddressTypeToAddressCount;
|
||||
|
||||
#[derive(Debug, Clone, Deref, DerefMut)]
|
||||
pub struct AddressTypeToHeightToAddressCount(GroupedByAddressType<EagerVec<Height, StoredUsize>>);
|
||||
pub struct AddressTypeToHeightToAddressCount(ByAddressType<EagerVec<Height, StoredUsize>>);
|
||||
|
||||
impl From<GroupedByAddressType<EagerVec<Height, StoredUsize>>>
|
||||
for AddressTypeToHeightToAddressCount
|
||||
{
|
||||
fn from(value: GroupedByAddressType<EagerVec<Height, StoredUsize>>) -> Self {
|
||||
impl From<ByAddressType<EagerVec<Height, StoredUsize>>> for AddressTypeToHeightToAddressCount {
|
||||
fn from(value: ByAddressType<EagerVec<Height, StoredUsize>>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_core::{GroupedByAddressType, StoredUsize};
|
||||
use brk_core::{ByAddressType, StoredUsize};
|
||||
use brk_exit::Exit;
|
||||
use brk_vec::AnyCollectableVec;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
@@ -9,14 +9,12 @@ use crate::vecs::{
|
||||
};
|
||||
|
||||
#[derive(Clone, Deref, DerefMut)]
|
||||
pub struct AddressTypeToIndexesToAddressCount(
|
||||
GroupedByAddressType<ComputedVecsFromHeight<StoredUsize>>,
|
||||
);
|
||||
pub struct AddressTypeToIndexesToAddressCount(ByAddressType<ComputedVecsFromHeight<StoredUsize>>);
|
||||
|
||||
impl From<GroupedByAddressType<ComputedVecsFromHeight<StoredUsize>>>
|
||||
impl From<ByAddressType<ComputedVecsFromHeight<StoredUsize>>>
|
||||
for AddressTypeToIndexesToAddressCount
|
||||
{
|
||||
fn from(value: GroupedByAddressType<ComputedVecsFromHeight<StoredUsize>>) -> Self {
|
||||
fn from(value: ByAddressType<ComputedVecsFromHeight<StoredUsize>>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ use std::{collections::BTreeMap, mem};
|
||||
use brk_core::TypeIndex;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
|
||||
use super::GroupedByAddressType;
|
||||
use super::ByAddressType;
|
||||
|
||||
#[derive(Debug, Deref, DerefMut)]
|
||||
pub struct AddressTypeToTypeIndexTree<T>(GroupedByAddressType<BTreeMap<TypeIndex, T>>);
|
||||
pub struct AddressTypeToTypeIndexTree<T>(ByAddressType<BTreeMap<TypeIndex, T>>);
|
||||
|
||||
impl<T> AddressTypeToTypeIndexTree<T> {
|
||||
pub fn merge(&mut self, mut other: Self) {
|
||||
@@ -29,14 +29,14 @@ impl<T> AddressTypeToTypeIndexTree<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unwrap(self) -> GroupedByAddressType<BTreeMap<TypeIndex, T>> {
|
||||
pub fn unwrap(self) -> ByAddressType<BTreeMap<TypeIndex, T>> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for AddressTypeToTypeIndexTree<T> {
|
||||
fn default() -> Self {
|
||||
Self(GroupedByAddressType {
|
||||
Self(ByAddressType {
|
||||
p2pk65: BTreeMap::default(),
|
||||
p2pk33: BTreeMap::default(),
|
||||
p2pkh: BTreeMap::default(),
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::mem;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
|
||||
use super::GroupedByAddressType;
|
||||
use super::ByAddressType;
|
||||
|
||||
#[derive(Debug, Default, Deref, DerefMut)]
|
||||
pub struct AddressTypeToVec<T>(GroupedByAddressType<Vec<T>>);
|
||||
pub struct AddressTypeToVec<T>(ByAddressType<Vec<T>>);
|
||||
|
||||
impl<T> AddressTypeToVec<T> {
|
||||
pub fn merge(&mut self, mut other: Self) {
|
||||
|
||||
@@ -119,11 +119,11 @@ pub struct Vecs {
|
||||
Option<ComputedVecsFromDateIndex<StoredF64>>,
|
||||
pub indexes_to_supply_in_profit_relative_to_circulating_supply:
|
||||
Option<ComputedVecsFromDateIndex<StoredF64>>,
|
||||
pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change:
|
||||
pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change:
|
||||
Option<ComputedVecsFromDateIndex<Dollars>>,
|
||||
pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap:
|
||||
pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap:
|
||||
pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap:
|
||||
Option<ComputedVecsFromDateIndex<StoredF32>>,
|
||||
}
|
||||
|
||||
@@ -929,10 +929,10 @@ impl Vecs {
|
||||
format,
|
||||
StorableVecGeneatorOptions::default().add_sum().add_cumulative(),
|
||||
)?,
|
||||
indexes_to_cumulative_net_realized_profit_and_loss_30d_change: compute_dollars.then(|| {
|
||||
indexes_to_net_realized_profit_and_loss_cumulative_30d_change: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change")),
|
||||
&suffix("net_realized_profit_and_loss_cumulative_30d_change"),
|
||||
true,
|
||||
version + VERSION + Version::new(3),
|
||||
format,
|
||||
@@ -940,10 +940,10 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap: compute_dollars.then(|| {
|
||||
indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change_relative_to_realized_cap")),
|
||||
&suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap"),
|
||||
true,
|
||||
version + VERSION + Version::new(3),
|
||||
format,
|
||||
@@ -951,10 +951,10 @@ impl Vecs {
|
||||
)
|
||||
.unwrap()
|
||||
}),
|
||||
indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap: compute_dollars.then(|| {
|
||||
indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap: compute_dollars.then(|| {
|
||||
ComputedVecsFromDateIndex::forced_import(
|
||||
path,
|
||||
&format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change_relative_to_market_cap")),
|
||||
&suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap"),
|
||||
true,
|
||||
version + VERSION + Version::new(3),
|
||||
format,
|
||||
@@ -2530,7 +2530,7 @@ impl Vecs {
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.compute_all(
|
||||
@@ -2552,7 +2552,7 @@ impl Vecs {
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap.
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap.
|
||||
as_mut()
|
||||
.unwrap()
|
||||
.compute_all(
|
||||
@@ -2563,14 +2563,14 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(),
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(),
|
||||
*dateindex_to_realized_cap.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap.
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap.
|
||||
as_mut()
|
||||
.unwrap()
|
||||
.compute_all(
|
||||
@@ -2581,7 +2581,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_percentage(
|
||||
starting_indexes.dateindex,
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(),
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(),
|
||||
market.indexes_to_marketcap.dateindex.as_ref().unwrap(),
|
||||
exit,
|
||||
)
|
||||
@@ -2915,11 +2915,11 @@ impl Vecs {
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_coinblocks_destroyed.vecs(),
|
||||
self.indexes_to_coindays_destroyed.vecs(),
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref()
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap.as_ref()
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap.as_ref()
|
||||
self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap.as_ref()
|
||||
.map_or(vec![], |v| v.vecs()),
|
||||
]
|
||||
.into_iter()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{cmp::Ordering, collections::BTreeMap, mem, path::Path, thread};
|
||||
|
||||
use brk_core::{
|
||||
AddressData, CheckedSub, DateIndex, Dollars, EmptyAddressData, GroupedByAddressType, Height,
|
||||
AddressData, ByAddressType, CheckedSub, DateIndex, Dollars, EmptyAddressData, Height,
|
||||
InputIndex, OutputIndex, OutputType, Result, Sats, StoredUsize, TypeIndex, Version,
|
||||
};
|
||||
use brk_exit::Exit;
|
||||
@@ -143,7 +143,7 @@ impl Vecs {
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)?,
|
||||
addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount::from(
|
||||
GroupedByAddressType {
|
||||
ByAddressType {
|
||||
p2pk65: EagerVec::forced_import(
|
||||
path,
|
||||
"p2pk65_address_count",
|
||||
@@ -195,7 +195,7 @@ impl Vecs {
|
||||
},
|
||||
),
|
||||
addresstype_to_height_to_empty_address_count: AddressTypeToHeightToAddressCount::from(
|
||||
GroupedByAddressType {
|
||||
ByAddressType {
|
||||
p2pk65: EagerVec::forced_import(
|
||||
path,
|
||||
"p2pk65_empty_address_count",
|
||||
@@ -247,7 +247,7 @@ impl Vecs {
|
||||
},
|
||||
),
|
||||
addresstype_to_indexes_to_address_count: AddressTypeToIndexesToAddressCount::from(
|
||||
GroupedByAddressType {
|
||||
ByAddressType {
|
||||
p2pk65: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk65_address_count",
|
||||
@@ -315,7 +315,7 @@ impl Vecs {
|
||||
},
|
||||
),
|
||||
addresstype_to_indexes_to_empty_address_count: AddressTypeToIndexesToAddressCount::from(
|
||||
GroupedByAddressType {
|
||||
ByAddressType {
|
||||
p2pk65: ComputedVecsFromHeight::forced_import(
|
||||
path,
|
||||
"p2pk65_empty_address_count",
|
||||
@@ -679,8 +679,8 @@ impl Vecs {
|
||||
let output_count = height_to_output_count_iter.unwrap_get_inner(height);
|
||||
let input_count = height_to_input_count_iter.unwrap_get_inner(height);
|
||||
|
||||
let first_addressindexes: GroupedByAddressType<TypeIndex> =
|
||||
GroupedByAddressType {
|
||||
let first_addressindexes: ByAddressType<TypeIndex> =
|
||||
ByAddressType {
|
||||
p2a: height_to_first_p2aaddressindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
.into(),
|
||||
@@ -1429,8 +1429,8 @@ impl AddressTypeToVec<(TypeIndex, Sats, Option<WithAddressDataSource<AddressData
|
||||
WithAddressDataSource<EmptyAddressData>,
|
||||
>,
|
||||
price: Option<Dollars>,
|
||||
addresstype_to_address_count: &mut GroupedByAddressType<usize>,
|
||||
addresstype_to_empty_address_count: &mut GroupedByAddressType<usize>,
|
||||
addresstype_to_address_count: &mut ByAddressType<usize>,
|
||||
addresstype_to_empty_address_count: &mut ByAddressType<usize>,
|
||||
) {
|
||||
self.into_typed_vec().into_iter().for_each(|(_type, vec)| {
|
||||
vec.into_iter()
|
||||
@@ -1474,22 +1474,22 @@ impl AddressTypeToVec<(TypeIndex, Sats, Option<WithAddressDataSource<AddressData
|
||||
|
||||
if is_new
|
||||
|| from_any_empty
|
||||
|| vecs.by_size_range.get_mut(amount).0.clone()
|
||||
!= vecs.by_size_range.get_mut(prev_amount).0.clone()
|
||||
|| vecs.amount_range.get_mut(amount).0.clone()
|
||||
!= vecs.amount_range.get_mut(prev_amount).0.clone()
|
||||
{
|
||||
// dbg!((prev_amount, amount, is_new));
|
||||
|
||||
if !is_new && !from_any_empty {
|
||||
let state = &mut vecs.by_size_range.get_mut(prev_amount).1.state;
|
||||
let state = &mut vecs.amount_range.get_mut(prev_amount).1.state;
|
||||
// dbg!((prev_amount, &state.address_count, &addressdata));
|
||||
state.subtract(addressdata);
|
||||
}
|
||||
|
||||
addressdata.receive(value, price);
|
||||
|
||||
vecs.by_size_range.get_mut(amount).1.state.add(addressdata);
|
||||
vecs.amount_range.get_mut(amount).1.state.add(addressdata);
|
||||
} else {
|
||||
vecs.by_size_range.get_mut(amount).1.state.receive(
|
||||
vecs.amount_range.get_mut(amount).1.state.receive(
|
||||
addressdata,
|
||||
value,
|
||||
price,
|
||||
@@ -1521,8 +1521,8 @@ impl
|
||||
WithAddressDataSource<EmptyAddressData>,
|
||||
>,
|
||||
price: Option<Dollars>,
|
||||
addresstype_to_address_count: &mut GroupedByAddressType<usize>,
|
||||
addresstype_to_empty_address_count: &mut GroupedByAddressType<usize>,
|
||||
addresstype_to_address_count: &mut ByAddressType<usize>,
|
||||
addresstype_to_empty_address_count: &mut ByAddressType<usize>,
|
||||
) -> Result<()> {
|
||||
self.into_typed_vec()
|
||||
.into_iter()
|
||||
@@ -1556,10 +1556,10 @@ impl
|
||||
// dbg!((prev_amount, amount, will_be_empty));
|
||||
|
||||
if will_be_empty
|
||||
|| vecs.by_size_range.get_mut(amount).0.clone()
|
||||
!= vecs.by_size_range.get_mut(prev_amount).0.clone()
|
||||
|| vecs.amount_range.get_mut(amount).0.clone()
|
||||
!= vecs.amount_range.get_mut(prev_amount).0.clone()
|
||||
{
|
||||
vecs.by_size_range
|
||||
vecs.amount_range
|
||||
.get_mut(prev_amount)
|
||||
.1
|
||||
.state
|
||||
@@ -1583,10 +1583,10 @@ impl
|
||||
.unwrap()
|
||||
.insert(type_index, addressdata.into());
|
||||
} else {
|
||||
vecs.by_size_range.get_mut(amount).1.state.add(addressdata);
|
||||
vecs.amount_range.get_mut(amount).1.state.add(addressdata);
|
||||
}
|
||||
} else {
|
||||
vecs.by_size_range.get_mut(amount).1.state.send(
|
||||
vecs.amount_range.get_mut(amount).1.state.send(
|
||||
addressdata,
|
||||
value,
|
||||
price,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user