mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 07:39:59 -07:00
global: snapshot
This commit is contained in:
@@ -5,27 +5,27 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedBlockLast, ComputedBlockSumCum},
|
||||
internal::{ComputedFromHeightLast, ComputedFromHeightSumCum},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
coinblocks_created: ComputedBlockSumCum::forced_import(
|
||||
coinblocks_created: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"coinblocks_created",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
coinblocks_stored: ComputedBlockSumCum::forced_import(
|
||||
coinblocks_stored: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"coinblocks_stored",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
liveliness: ComputedBlockLast::forced_import(db, "liveliness", version, indexes)?,
|
||||
vaultedness: ComputedBlockLast::forced_import(db, "vaultedness", version, indexes)?,
|
||||
activity_to_vaultedness_ratio: ComputedBlockLast::forced_import(
|
||||
liveliness: ComputedFromHeightLast::forced_import(db, "liveliness", version, indexes)?,
|
||||
vaultedness: ComputedFromHeightLast::forced_import(db, "vaultedness", version, indexes)?,
|
||||
activity_to_vaultedness_ratio: ComputedFromHeightLast::forced_import(
|
||||
db,
|
||||
"activity_to_vaultedness_ratio",
|
||||
version,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::StoredF64;
|
||||
|
||||
use crate::internal::{ComputedBlockLast, ComputedBlockSumCum};
|
||||
use crate::internal::{ComputedFromHeightLast, ComputedFromHeightSumCum};
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub coinblocks_created: ComputedBlockSumCum<StoredF64>,
|
||||
pub coinblocks_stored: ComputedBlockSumCum<StoredF64>,
|
||||
pub liveliness: ComputedBlockLast<StoredF64>,
|
||||
pub vaultedness: ComputedBlockLast<StoredF64>,
|
||||
pub activity_to_vaultedness_ratio: ComputedBlockLast<StoredF64>,
|
||||
pub coinblocks_created: ComputedFromHeightSumCum<StoredF64>,
|
||||
pub coinblocks_stored: ComputedFromHeightSumCum<StoredF64>,
|
||||
pub liveliness: ComputedFromHeightLast<StoredF64>,
|
||||
pub vaultedness: ComputedFromHeightLast<StoredF64>,
|
||||
pub activity_to_vaultedness_ratio: ComputedFromHeightLast<StoredF64>,
|
||||
}
|
||||
|
||||
@@ -3,24 +3,24 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedDateLast};
|
||||
use crate::{indexes, internal::ComputedFromDateLast};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_adj_inflation_rate: ComputedDateLast::forced_import(
|
||||
cointime_adj_inflation_rate: ComputedFromDateLast::forced_import(
|
||||
db,
|
||||
"cointime_adj_inflation_rate",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_btc_velocity: ComputedDateLast::forced_import(
|
||||
cointime_adj_tx_btc_velocity: ComputedFromDateLast::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_btc_velocity",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_usd_velocity: ComputedDateLast::forced_import(
|
||||
cointime_adj_tx_usd_velocity: ComputedFromDateLast::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_usd_velocity",
|
||||
version,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
|
||||
use crate::internal::ComputedDateLast;
|
||||
use crate::internal::ComputedFromDateLast;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub cointime_adj_inflation_rate: ComputedDateLast<StoredF32>,
|
||||
pub cointime_adj_tx_btc_velocity: ComputedDateLast<StoredF64>,
|
||||
pub cointime_adj_tx_usd_velocity: ComputedDateLast<StoredF64>,
|
||||
pub cointime_adj_inflation_rate: ComputedFromDateLast<StoredF32>,
|
||||
pub cointime_adj_tx_btc_velocity: ComputedFromDateLast<StoredF64>,
|
||||
pub cointime_adj_tx_usd_velocity: ComputedFromDateLast<StoredF64>,
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedBlockLast};
|
||||
use crate::{indexes, internal::ComputedFromHeightLast};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
thermo_cap: ComputedBlockLast::forced_import(db, "thermo_cap", version, indexes)?,
|
||||
investor_cap: ComputedBlockLast::forced_import(db, "investor_cap", version, indexes)?,
|
||||
vaulted_cap: ComputedBlockLast::forced_import(db, "vaulted_cap", version, indexes)?,
|
||||
active_cap: ComputedBlockLast::forced_import(db, "active_cap", version, indexes)?,
|
||||
cointime_cap: ComputedBlockLast::forced_import(db, "cointime_cap", version, indexes)?,
|
||||
thermo_cap: ComputedFromHeightLast::forced_import(db, "thermo_cap", version, indexes)?,
|
||||
investor_cap: ComputedFromHeightLast::forced_import(db, "investor_cap", version, indexes)?,
|
||||
vaulted_cap: ComputedFromHeightLast::forced_import(db, "vaulted_cap", version, indexes)?,
|
||||
active_cap: ComputedFromHeightLast::forced_import(db, "active_cap", version, indexes)?,
|
||||
cointime_cap: ComputedFromHeightLast::forced_import(db, "cointime_cap", version, indexes)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Dollars;
|
||||
|
||||
use crate::internal::ComputedBlockLast;
|
||||
use crate::internal::ComputedFromHeightLast;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub thermo_cap: ComputedBlockLast<Dollars>,
|
||||
pub investor_cap: ComputedBlockLast<Dollars>,
|
||||
pub vaulted_cap: ComputedBlockLast<Dollars>,
|
||||
pub active_cap: ComputedBlockLast<Dollars>,
|
||||
pub cointime_cap: ComputedBlockLast<Dollars>,
|
||||
pub thermo_cap: ComputedFromHeightLast<Dollars>,
|
||||
pub investor_cap: ComputedFromHeightLast<Dollars>,
|
||||
pub vaulted_cap: ComputedFromHeightLast<Dollars>,
|
||||
pub active_cap: ComputedFromHeightLast<Dollars>,
|
||||
pub cointime_cap: ComputedFromHeightLast<Dollars>,
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ impl Vecs {
|
||||
self.supply.compute(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
price,
|
||||
distribution,
|
||||
&self.activity,
|
||||
exit,
|
||||
|
||||
@@ -20,12 +20,11 @@ impl Vecs {
|
||||
let db = Database::open(&parent_path.join(DB_NAME))?;
|
||||
db.set_min_len(PAGE_SIZE * 1_000_000)?;
|
||||
|
||||
let compute_dollars = price.is_some();
|
||||
let version = parent_version + VERSION;
|
||||
let v1 = version + Version::ONE;
|
||||
|
||||
let activity = ActivityVecs::forced_import(&db, version, indexes)?;
|
||||
let supply = SupplyVecs::forced_import(&db, v1, indexes, compute_dollars)?;
|
||||
let supply = SupplyVecs::forced_import(&db, v1, indexes, price)?;
|
||||
let value = ValueVecs::forced_import(&db, v1, indexes)?;
|
||||
let cap = CapVecs::forced_import(&db, v1, indexes)?;
|
||||
let pricing = PricingVecs::forced_import(&db, version, indexes, price)?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedBlockLast, ComputedRatioVecsDate},
|
||||
internal::{ComputedFromHeightLast, ComputedFromDateRatio},
|
||||
price,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ impl Vecs {
|
||||
) -> Result<Self> {
|
||||
macro_rules! computed_h {
|
||||
($name:expr) => {
|
||||
ComputedBlockLast::forced_import(db, $name, version, indexes)?
|
||||
ComputedFromHeightLast::forced_import(db, $name, version, indexes)?
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Vecs {
|
||||
|
||||
macro_rules! ratio_di {
|
||||
($name:expr, $source:expr) => {
|
||||
ComputedRatioVecsDate::forced_import(
|
||||
ComputedFromDateRatio::forced_import(
|
||||
db,
|
||||
$name,
|
||||
Some($source),
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Dollars;
|
||||
|
||||
use crate::internal::{ComputedBlockLast, ComputedRatioVecsDate};
|
||||
use crate::internal::{ComputedFromHeightLast, ComputedFromDateRatio};
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub vaulted_price: ComputedBlockLast<Dollars>,
|
||||
pub vaulted_price_ratio: ComputedRatioVecsDate,
|
||||
pub active_price: ComputedBlockLast<Dollars>,
|
||||
pub active_price_ratio: ComputedRatioVecsDate,
|
||||
pub true_market_mean: ComputedBlockLast<Dollars>,
|
||||
pub true_market_mean_ratio: ComputedRatioVecsDate,
|
||||
pub cointime_price: ComputedBlockLast<Dollars>,
|
||||
pub cointime_price_ratio: ComputedRatioVecsDate,
|
||||
pub vaulted_price: ComputedFromHeightLast<Dollars>,
|
||||
pub vaulted_price_ratio: ComputedFromDateRatio,
|
||||
pub active_price: ComputedFromHeightLast<Dollars>,
|
||||
pub active_price_ratio: ComputedFromDateRatio,
|
||||
pub true_market_mean: ComputedFromHeightLast<Dollars>,
|
||||
pub true_market_mean_ratio: ComputedFromDateRatio,
|
||||
pub cointime_price: ComputedFromHeightLast<Dollars>,
|
||||
pub cointime_price_ratio: ComputedFromDateRatio,
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@ use vecdb::Exit;
|
||||
|
||||
use super::super::activity;
|
||||
use super::Vecs;
|
||||
use crate::{ComputeIndexes, distribution, indexes, price};
|
||||
use crate::{ComputeIndexes, distribution, indexes};
|
||||
|
||||
impl Vecs {
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &ComputeIndexes,
|
||||
price: Option<&price::Vecs>,
|
||||
distribution: &distribution::Vecs,
|
||||
activity: &activity::Vecs,
|
||||
exit: &Exit,
|
||||
@@ -25,7 +24,7 @@ impl Vecs {
|
||||
.height;
|
||||
|
||||
self.vaulted_supply
|
||||
.compute_all(indexes, price, starting_indexes, exit, |vec| {
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
circulating_supply,
|
||||
@@ -36,7 +35,7 @@ impl Vecs {
|
||||
})?;
|
||||
|
||||
self.active_supply
|
||||
.compute_all(indexes, price, starting_indexes, exit, |vec| {
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
circulating_supply,
|
||||
|
||||
@@ -3,29 +3,29 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ValueBlockLast};
|
||||
use crate::{indexes, internal::ValueFromHeightLast, price};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
compute_dollars: bool,
|
||||
price: Option<&price::Vecs>,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
vaulted_supply: ValueBlockLast::forced_import(
|
||||
vaulted_supply: ValueFromHeightLast::forced_import(
|
||||
db,
|
||||
"vaulted_supply",
|
||||
version,
|
||||
indexes,
|
||||
compute_dollars,
|
||||
price,
|
||||
)?,
|
||||
active_supply: ValueBlockLast::forced_import(
|
||||
active_supply: ValueFromHeightLast::forced_import(
|
||||
db,
|
||||
"active_supply",
|
||||
version,
|
||||
indexes,
|
||||
compute_dollars,
|
||||
price,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use brk_traversable::Traversable;
|
||||
|
||||
use crate::internal::ValueBlockLast;
|
||||
use crate::internal::ValueFromHeightLast;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub vaulted_supply: ValueBlockLast,
|
||||
pub active_supply: ValueBlockLast,
|
||||
pub vaulted_supply: ValueFromHeightLast,
|
||||
pub active_supply: ValueFromHeightLast,
|
||||
}
|
||||
|
||||
@@ -3,24 +3,24 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedBlockSumCum};
|
||||
use crate::{indexes, internal::ComputedFromHeightSumCum};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_value_destroyed: ComputedBlockSumCum::forced_import(
|
||||
cointime_value_destroyed: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"cointime_value_destroyed",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_value_created: ComputedBlockSumCum::forced_import(
|
||||
cointime_value_created: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"cointime_value_created",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_value_stored: ComputedBlockSumCum::forced_import(
|
||||
cointime_value_stored: ComputedFromHeightSumCum::forced_import(
|
||||
db,
|
||||
"cointime_value_stored",
|
||||
version,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::StoredF64;
|
||||
|
||||
use crate::internal::ComputedBlockSumCum;
|
||||
use crate::internal::ComputedFromHeightSumCum;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub cointime_value_destroyed: ComputedBlockSumCum<StoredF64>,
|
||||
pub cointime_value_created: ComputedBlockSumCum<StoredF64>,
|
||||
pub cointime_value_stored: ComputedBlockSumCum<StoredF64>,
|
||||
pub cointime_value_destroyed: ComputedFromHeightSumCum<StoredF64>,
|
||||
pub cointime_value_created: ComputedFromHeightSumCum<StoredF64>,
|
||||
pub cointime_value_stored: ComputedFromHeightSumCum<StoredF64>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user