mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-31 12:43:06 -07:00
parser: fix utxo panic after soft reset
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{
|
||||
bitcoin::{check_if_height_safe, BitcoinDB, NUMBER_OF_UNSAFE_BLOCKS},
|
||||
databases::Databases,
|
||||
datasets::{AllDatasets, ComputeData},
|
||||
states::States,
|
||||
states::{AddressCohortsDurableStates, States, UTXOCohortsDurableStates},
|
||||
structs::{DateData, WNaiveDate},
|
||||
utils::{generate_allocation_files, log, time},
|
||||
};
|
||||
@@ -33,8 +33,7 @@ pub fn iter_blocks(bitcoin_db: &BitcoinDB, block_count: usize) -> color_eyre::Re
|
||||
|
||||
log("Imported databases");
|
||||
|
||||
let mut states =
|
||||
States::import(&mut databases.address_index_to_address_data, &datasets).unwrap_or_default();
|
||||
let mut states = States::import().unwrap_or_default();
|
||||
|
||||
log("Imported states");
|
||||
|
||||
@@ -74,6 +73,26 @@ pub fn iter_blocks(bitcoin_db: &BitcoinDB, block_count: usize) -> color_eyre::Re
|
||||
let current_block_date = WNaiveDate::from_timestamp(timestamp);
|
||||
let current_block_height = height + blocks_loop_i;
|
||||
|
||||
if states.address_cohorts_durable_states.is_none()
|
||||
&& datasets
|
||||
.address
|
||||
.needs_durable_states(current_block_height, current_block_date)
|
||||
{
|
||||
states.address_cohorts_durable_states =
|
||||
Some(AddressCohortsDurableStates::init(
|
||||
&mut databases.address_index_to_address_data,
|
||||
));
|
||||
}
|
||||
|
||||
if states.utxo_cohorts_durable_states.is_none()
|
||||
&& datasets
|
||||
.utxo
|
||||
.needs_durable_states(current_block_height, current_block_date)
|
||||
{
|
||||
states.utxo_cohorts_durable_states =
|
||||
Some(UTXOCohortsDurableStates::init(&states.date_data_vec));
|
||||
}
|
||||
|
||||
let next_block_date = next_block_opt
|
||||
.as_ref()
|
||||
.map(|next_block| WNaiveDate::from_timestamp(next_block.header.time));
|
||||
|
||||
Reference in New Issue
Block a user