mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-30 01:20:00 -07:00
global: big snapshot
This commit is contained in:
@@ -3,7 +3,7 @@ use brk_indexer::Indexer;
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, ComputeIndexes};
|
||||
use crate::{ComputeIndexes, indexes};
|
||||
|
||||
impl Vecs {
|
||||
pub fn compute(
|
||||
@@ -13,19 +13,14 @@ impl Vecs {
|
||||
starting_indexes: &ComputeIndexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.indexes_to_block_size.derive_from(
|
||||
self.size.derive_from(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
&indexer.vecs.block.height_to_total_size,
|
||||
&indexer.vecs.blocks.total_size,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.indexes_to_block_vbytes.derive_from(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
&self.height_to_vbytes,
|
||||
exit,
|
||||
)?;
|
||||
self.vbytes.derive_from(indexes, starting_indexes, exit)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_types::{Height, StoredU64, Version};
|
||||
use vecdb::{Database, IterableCloneableVec, LazyVecFrom1, VecIndex};
|
||||
use vecdb::{Database, IterableCloneableVec, VecIndex};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::DerivedComputedBlockFull,
|
||||
};
|
||||
use crate::{indexes, internal::{DerivedComputedBlockFull, LazyComputedBlockFull}};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(
|
||||
@@ -16,33 +13,26 @@ impl Vecs {
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
let height_to_vbytes = LazyVecFrom1::init(
|
||||
"vbytes",
|
||||
version,
|
||||
indexer.vecs.block.height_to_weight.boxed_clone(),
|
||||
|height: Height, weight_iter| {
|
||||
weight_iter
|
||||
.get_at(height.to_usize())
|
||||
.map(|w| StoredU64::from(w.to_vbytes_floor()))
|
||||
},
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
indexes_to_block_size: DerivedComputedBlockFull::forced_import(
|
||||
db,
|
||||
"block_size",
|
||||
indexer.vecs.block.height_to_total_size.boxed_clone(),
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
indexes_to_block_vbytes: DerivedComputedBlockFull::forced_import(
|
||||
vbytes: LazyComputedBlockFull::forced_import_with_init(
|
||||
db,
|
||||
"block_vbytes",
|
||||
height_to_vbytes.boxed_clone(),
|
||||
version,
|
||||
indexer.vecs.blocks.weight.clone(),
|
||||
indexes,
|
||||
|height: Height, weight_iter| {
|
||||
weight_iter
|
||||
.get_at(height.to_usize())
|
||||
.map(|w| StoredU64::from(w.to_vbytes_floor()))
|
||||
},
|
||||
)?,
|
||||
size: DerivedComputedBlockFull::forced_import(
|
||||
db,
|
||||
"block_size",
|
||||
indexer.vecs.blocks.total_size.boxed_clone(),
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
height_to_vbytes,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, StoredU64, Weight};
|
||||
use vecdb::LazyVecFrom1;
|
||||
use brk_types::{StoredU64, Weight};
|
||||
|
||||
use crate::internal::DerivedComputedBlockFull;
|
||||
use crate::internal::{DerivedComputedBlockFull, LazyComputedBlockFull};
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub height_to_vbytes: LazyVecFrom1<Height, StoredU64, Height, Weight>,
|
||||
pub indexes_to_block_size: DerivedComputedBlockFull<StoredU64>,
|
||||
pub indexes_to_block_vbytes: DerivedComputedBlockFull<StoredU64>,
|
||||
pub vbytes: LazyComputedBlockFull<StoredU64, Weight>,
|
||||
pub size: DerivedComputedBlockFull<StoredU64>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user