computer: rollback part 1

This commit is contained in:
nym21
2025-08-12 22:37:16 +02:00
parent ee5dc8fc41
commit 5f8de8e756
29 changed files with 487 additions and 504 deletions

View File

@@ -1,4 +1,4 @@
use brk_error::Result;
use brk_error::{Error, Result};
use brk_indexer::Indexer;
use brk_structs::{
Bitcoin, DateIndex, Dollars, Height, Sats, StoredF32, StoredF64, StoredU64, Version,
@@ -1111,7 +1111,11 @@ impl Vecs {
.unwrap()
}
pub fn init(&mut self, starting_height: &mut Height, state: &mut CohortState) {
pub fn import_state_at(
&mut self,
starting_height: &mut Height,
state: &mut CohortState,
) -> Result<()> {
if let Some(prev_height) = starting_height.decremented() {
state.supply.value = self
.height_to_supply
@@ -1126,7 +1130,12 @@ impl Vecs {
state.realized.as_mut().unwrap().cap = height_to_realized_cap
.into_iter()
.unwrap_get_inner(prev_height);
state.import_at(prev_height)?;
}
Ok(())
} else {
Err(Error::Str("Unset"))
}
}