global: BIG snapshot

This commit is contained in:
nym21
2026-01-04 01:47:03 +01:00
parent c33444a92e
commit 3cae817915
127 changed files with 4750 additions and 9474 deletions

View File

@@ -14,68 +14,59 @@ use crate::{
};
impl Vecs {
pub fn forced_import(
db: &Database,
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let v0 = Version::ZERO;
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
let last = || VecBuilderOptions::default().add_last();
let sum_cum = || VecBuilderOptions::default().add_sum().add_cumulative();
Ok(Self {
dateindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.dateindex_to_dateindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_DAY)),
),
weekindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.weekindex_to_weekindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_WEEK)),
),
monthindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.monthindex_to_monthindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_MONTH)),
),
quarterindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.quarterindex_to_quarterindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_QUARTER)),
),
semesterindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.semesterindex_to_semesterindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_SEMESTER)),
),
yearindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.yearindex_to_yearindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_YEAR)),
),
decadeindex_to_block_count_target: LazyVecFrom1::init(
"block_count_target",
version + v0,
version,
indexes.time.decadeindex_to_decadeindex.boxed_clone(),
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_DECADE)),
),
height_to_24h_block_count: EagerVec::forced_import(
db,
"24h_block_count",
version + v0,
)?,
height_to_24h_block_count: EagerVec::forced_import(db, "24h_block_count", version)?,
indexes_to_block_count: ComputedVecsFromHeight::forced_import(
db,
"block_count",
Source::Compute,
version + v0,
version,
indexes,
sum_cum(),
)?,
@@ -83,7 +74,7 @@ impl Vecs {
db,
"1w_block_count",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -91,7 +82,7 @@ impl Vecs {
db,
"1m_block_count",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -99,7 +90,7 @@ impl Vecs {
db,
"1y_block_count",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,

View File

@@ -10,7 +10,6 @@ use crate::{
impl Vecs {
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
let v0 = Version::ZERO;
let v2 = Version::TWO;
let last = || VecBuilderOptions::default().add_last();
@@ -19,7 +18,7 @@ impl Vecs {
db,
"difficultyepoch",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,

View File

@@ -10,7 +10,6 @@ use crate::{
impl Vecs {
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
let v0 = Version::ZERO;
let v2 = Version::TWO;
let last = || VecBuilderOptions::default().add_last();
@@ -19,7 +18,7 @@ impl Vecs {
db,
"halvingepoch",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,

View File

@@ -9,8 +9,8 @@ use vecdb::{Database, PAGE_SIZE};
use crate::{indexes, price};
use super::{
CountVecs, DifficultyVecs, HalvingVecs, IntervalVecs, MiningVecs,
RewardsVecs, SizeVecs, TimeVecs, Vecs, WeightVecs,
CountVecs, DifficultyVecs, HalvingVecs, IntervalVecs, MiningVecs, RewardsVecs, SizeVecs,
TimeVecs, Vecs, WeightVecs,
};
impl Vecs {
@@ -24,7 +24,7 @@ impl Vecs {
let db = Database::open(&parent_path.join(super::DB_NAME))?;
db.set_min_len(PAGE_SIZE * 50_000_000)?;
let version = parent_version + Version::ZERO;
let version = parent_version;
let compute_dollars = price.is_some();
let count = CountVecs::forced_import(&db, version, indexes)?;

View File

@@ -16,7 +16,6 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let v0 = Version::ZERO;
let stats = || {
VecBuilderOptions::default()
.add_average()
@@ -26,7 +25,7 @@ impl Vecs {
let height_to_interval = LazyVecFrom1::init(
"interval",
version + v0,
version,
indexer.vecs.block.height_to_timestamp.boxed_clone(),
|height: Height, timestamp_iter| {
let timestamp = timestamp_iter.get(height)?;
@@ -46,7 +45,7 @@ impl Vecs {
db,
"block_interval",
Source::Vec(height_to_interval.boxed_clone()),
version + v0,
version,
indexes,
stats(),
)?,

View File

@@ -5,8 +5,8 @@ use vecdb::{Database, IterableCloneableVec};
use super::Vecs;
use crate::{
internal::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, Source, VecBuilderOptions},
indexes,
internal::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, Source, VecBuilderOptions},
};
impl Vecs {
@@ -16,7 +16,6 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let v0 = Version::ZERO;
let v4 = Version::new(4);
let v5 = Version::new(5);
@@ -36,7 +35,7 @@ impl Vecs {
db,
"hash_rate_1w_sma",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -44,7 +43,7 @@ impl Vecs {
db,
"hash_rate_1m_sma",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -52,7 +51,7 @@ impl Vecs {
db,
"hash_rate_2m_sma",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -60,7 +59,7 @@ impl Vecs {
db,
"hash_rate_1y_sma",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -148,7 +147,7 @@ impl Vecs {
db,
"difficulty",
Source::Vec(indexer.vecs.block.height_to_difficulty.boxed_clone()),
version + v0,
version,
indexes,
last(),
)?,
@@ -156,7 +155,7 @@ impl Vecs {
db,
"difficulty_as_hash",
Source::Compute,
version + v0,
version,
indexes,
last(),
)?,
@@ -164,7 +163,7 @@ impl Vecs {
db,
"difficulty_adjustment",
Source::Compute,
version + v0,
version,
indexes,
sum(),
)?,

View File

@@ -4,8 +4,8 @@ use vecdb::{Database, EagerVec, ImportableVec};
use super::Vecs;
use crate::{
internal::{ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, Source, VecBuilderOptions},
indexes,
internal::{ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, Source, VecBuilderOptions},
};
impl Vecs {
@@ -15,25 +15,20 @@ impl Vecs {
indexes: &indexes::Vecs,
compute_dollars: bool,
) -> Result<Self> {
let v0 = Version::ZERO;
let last = || VecBuilderOptions::default().add_last();
Ok(Self {
height_to_24h_coinbase_sum: EagerVec::forced_import(
db,
"24h_coinbase_sum",
version + v0,
)?,
height_to_24h_coinbase_sum: EagerVec::forced_import(db, "24h_coinbase_sum", version)?,
height_to_24h_coinbase_usd_sum: EagerVec::forced_import(
db,
"24h_coinbase_usd_sum",
version + v0,
version,
)?,
indexes_to_coinbase: ComputedValueVecsFromHeight::forced_import(
db,
"coinbase",
Source::Compute,
version + v0,
version,
VecBuilderOptions::default()
.add_sum()
.add_cumulative()
@@ -47,7 +42,7 @@ impl Vecs {
db,
"subsidy",
Source::Compute,
version + v0,
version,
VecBuilderOptions::default()
.add_percentiles()
.add_sum()
@@ -61,16 +56,16 @@ impl Vecs {
db,
"unclaimed_rewards",
Source::Compute,
version + v0,
version,
VecBuilderOptions::default().add_sum().add_cumulative(),
compute_dollars,
indexes,
)?,
dateindex_to_fee_dominance: EagerVec::forced_import(db, "fee_dominance", version + v0)?,
dateindex_to_fee_dominance: EagerVec::forced_import(db, "fee_dominance", version)?,
dateindex_to_subsidy_dominance: EagerVec::forced_import(
db,
"subsidy_dominance",
version + v0,
version,
)?,
indexes_to_subsidy_usd_1y_sma: compute_dollars
.then(|| {
@@ -78,7 +73,7 @@ impl Vecs {
db,
"subsidy_usd_1y_sma",
Source::Compute,
version + v0,
version,
indexes,
last(),
)

View File

@@ -16,7 +16,6 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let v0 = Version::ZERO;
let full_stats = || {
VecBuilderOptions::default()
.add_average()
@@ -28,7 +27,7 @@ impl Vecs {
let height_to_vbytes = LazyVecFrom1::init(
"vbytes",
version + v0,
version,
indexer.vecs.block.height_to_weight.boxed_clone(),
|height: Height, weight_iter| {
weight_iter
@@ -42,7 +41,7 @@ impl Vecs {
db,
"block_size",
Source::Vec(indexer.vecs.block.height_to_total_size.boxed_clone()),
version + v0,
version,
indexes,
full_stats(),
)?,
@@ -50,7 +49,7 @@ impl Vecs {
db,
"block_vbytes",
Source::Vec(height_to_vbytes.boxed_clone()),
version + v0,
version,
indexes,
full_stats(),
)?,

View File

@@ -18,13 +18,12 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let height_to_timestamp_fixed =
EagerVec::forced_import(db, "timestamp_fixed", version + Version::ZERO)?;
let height_to_timestamp_fixed = EagerVec::forced_import(db, "timestamp_fixed", version)?;
Ok(Self {
height_to_date: LazyVecFrom1::init(
"date",
version + Version::ZERO,
version,
indexer.vecs.block.height_to_timestamp.boxed_clone(),
|height: Height, timestamp_iter| {
timestamp_iter.get_at(height.to_usize()).map(Date::from)
@@ -32,14 +31,14 @@ impl Vecs {
),
height_to_date_fixed: LazyVecFrom1::init(
"date_fixed",
version + Version::ZERO,
version,
height_to_timestamp_fixed.boxed_clone(),
|height: Height, timestamp_iter| timestamp_iter.get(height).map(Date::from),
),
height_to_timestamp_fixed,
difficultyepoch_to_timestamp: LazyVecFrom2::init(
"timestamp",
version + Version::ZERO,
version,
indexes.block.difficultyepoch_to_first_height.boxed_clone(),
indexer.vecs.block.height_to_timestamp.boxed_clone(),
|di: DifficultyEpoch, first_height_iter, timestamp_iter| {
@@ -52,7 +51,7 @@ impl Vecs {
db,
"timestamp",
Source::Compute,
version + Version::ZERO,
version,
indexes,
VecBuilderOptions::default().add_first(),
)?,

View File

@@ -6,7 +6,9 @@ use vecdb::{Database, IterableCloneableVec};
use super::Vecs;
use crate::{
indexes,
internal::{ComputedVecsFromHeight, LazyVecsFromHeight, Source, VecBuilderOptions, WeightToFullness},
internal::{
ComputedVecsFromHeight, LazyVecsFromHeight, Source, VecBuilderOptions, WeightToFullness,
},
};
impl Vecs {
@@ -16,7 +18,6 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let v0 = Version::ZERO;
let full_stats = || {
VecBuilderOptions::default()
.add_average()
@@ -30,14 +31,14 @@ impl Vecs {
db,
"block_weight",
Source::Vec(indexer.vecs.block.height_to_weight.boxed_clone()),
version + v0,
version,
indexes,
full_stats(),
)?;
let indexes_to_block_fullness = LazyVecsFromHeight::from_computed::<WeightToFullness>(
"block_fullness",
version + v0,
version,
indexer.vecs.block.height_to_weight.boxed_clone(),
&indexes_to_block_weight,
);