mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-01 10:43:39 -07:00
37 lines
906 B
Rust
37 lines
906 B
Rust
use std::path::Path;
|
|
|
|
use brk_error::Result;
|
|
use brk_traversable::Traversable;
|
|
use brk_types::Version;
|
|
use vecdb::{Database, PAGE_SIZE};
|
|
|
|
use super::{CountVecs, SpentVecs, Vecs};
|
|
use crate::indexes;
|
|
|
|
impl Vecs {
|
|
pub fn forced_import(
|
|
parent_path: &Path,
|
|
parent_version: Version,
|
|
indexes: &indexes::Vecs,
|
|
) -> Result<Self> {
|
|
let db = Database::open(&parent_path.join(super::DB_NAME))?;
|
|
db.set_min_len(PAGE_SIZE * 50_000_000)?;
|
|
|
|
let version = parent_version;
|
|
|
|
let spent = SpentVecs::forced_import(&db, version)?;
|
|
let count = CountVecs::forced_import(&db, version, indexes)?;
|
|
|
|
let this = Self { db, spent, count };
|
|
|
|
this.db.retain_regions(
|
|
this.iter_any_exportable()
|
|
.flat_map(|v| v.region_names())
|
|
.collect(),
|
|
)?;
|
|
this.db.compact()?;
|
|
|
|
Ok(this)
|
|
}
|
|
}
|