mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
global: snapshot
This commit is contained in:
@@ -27,7 +27,7 @@ impl Vecs {
|
||||
self.size
|
||||
.compute(indexer, &self.lookback, starting_indexes, exit)?;
|
||||
self.weight
|
||||
.compute(indexer, &self.lookback, starting_indexes, exit)?;
|
||||
.compute(indexer, starting_indexes, exit)?;
|
||||
self.difficulty
|
||||
.compute(indexer, indexes, starting_indexes, exit)?;
|
||||
self.halving.compute(indexes, starting_indexes, exit)?;
|
||||
|
||||
@@ -24,7 +24,7 @@ impl Vecs {
|
||||
total: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"block_count",
|
||||
version,
|
||||
version + Version::ONE,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
|
||||
@@ -29,7 +29,7 @@ impl Vecs {
|
||||
let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?;
|
||||
let interval = IntervalVecs::forced_import(&db, version, indexes, cached_starts)?;
|
||||
let size = SizeVecs::forced_import(&db, version, indexes, cached_starts)?;
|
||||
let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts)?;
|
||||
let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts, &size)?;
|
||||
let time = TimeVecs::forced_import(&db, version, indexes)?;
|
||||
let difficulty = DifficultyVecs::forced_import(&db, version, indexer, indexes)?;
|
||||
let halving = HalvingVecs::forced_import(&db, version, indexes)?;
|
||||
|
||||
@@ -4,25 +4,14 @@ use brk_types::{BasisPoints16, Indexes};
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::blocks;
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
lookback: &blocks::LookbackVecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = lookback.window_starts();
|
||||
|
||||
self.weight.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&indexer.vecs.blocks.weight,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.fullness
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_transform(
|
||||
|
||||
@@ -4,8 +4,9 @@ use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
blocks::SizeVecs,
|
||||
indexes,
|
||||
internal::{CachedWindowStarts, ResolutionsFull, PercentPerBlockRollingAverage},
|
||||
internal::{CachedWindowStarts, LazyResolutionsFull, PercentPerBlockRollingAverage, VBytesToWeight},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -14,9 +15,15 @@ impl Vecs {
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
size: &SizeVecs,
|
||||
) -> Result<Self> {
|
||||
let weight =
|
||||
ResolutionsFull::forced_import(db, "block_weight", version, indexes, cached_starts)?;
|
||||
let weight = LazyResolutionsFull::from_computed_per_block_full::<VBytesToWeight>(
|
||||
"block_weight",
|
||||
version,
|
||||
&size.vbytes,
|
||||
cached_starts,
|
||||
indexes,
|
||||
);
|
||||
|
||||
let fullness = PercentPerBlockRollingAverage::forced_import(
|
||||
db,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BasisPoints16, Weight};
|
||||
use brk_types::{BasisPoints16, StoredU64, Weight};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{ResolutionsFull, PercentPerBlockRollingAverage};
|
||||
use crate::internal::{LazyResolutionsFull, PercentPerBlockRollingAverage};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub weight: ResolutionsFull<Weight, M>,
|
||||
pub weight: LazyResolutionsFull<Weight, StoredU64>,
|
||||
pub fullness: PercentPerBlockRollingAverage<BasisPoints16, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user