mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 23:59:58 -07:00
parser: fix utxo panic after soft reset
This commit is contained in:
@@ -88,19 +88,19 @@ impl CohortDataset {
|
||||
.any(|sub| sub.price_paid.needs_insert(height, date))
|
||||
}
|
||||
|
||||
fn needs_insert_realized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
pub fn needs_insert_realized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.sub_datasets_vec()
|
||||
.iter()
|
||||
.any(|sub| sub.realized.needs_insert(height, date))
|
||||
}
|
||||
|
||||
fn needs_insert_unrealized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
pub fn needs_insert_unrealized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.sub_datasets_vec()
|
||||
.iter()
|
||||
.any(|sub| sub.unrealized.needs_insert(height, date))
|
||||
}
|
||||
|
||||
fn needs_insert_input(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
pub fn needs_insert_input(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.sub_datasets_vec()
|
||||
.iter()
|
||||
.any(|sub| sub.input.needs_insert(height, date))
|
||||
@@ -112,7 +112,7 @@ impl CohortDataset {
|
||||
// .any(|sub| sub.output.needs_insert(height, date))
|
||||
// }
|
||||
|
||||
fn insert_realized_data(&mut self, insert_data: &InsertData) {
|
||||
pub fn insert_realized_data(&mut self, insert_data: &InsertData) {
|
||||
let split_realized_state = insert_data
|
||||
.address_cohorts_realized_states
|
||||
.as_ref()
|
||||
@@ -141,6 +141,8 @@ impl CohortDataset {
|
||||
let address_count = insert_data
|
||||
.states
|
||||
.address_cohorts_durable_states
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(&self.split)
|
||||
.unwrap()
|
||||
.address_count;
|
||||
@@ -377,6 +379,8 @@ impl CohortDataset {
|
||||
let liquidity_split_processed_address_state = insert_data
|
||||
.states
|
||||
.address_cohorts_durable_states
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(&self.split);
|
||||
|
||||
if liquidity_split_processed_address_state.is_none() {
|
||||
|
||||
@@ -6,7 +6,7 @@ use allocative::Allocative;
|
||||
use itertools::Itertools;
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::{states::SplitByAddressCohort, structs::BiMap};
|
||||
use crate::{states::SplitByAddressCohort, structs::BiMap, WNaiveDate};
|
||||
|
||||
use self::{all_metadata::AllAddressesMetadataDataset, cohort::CohortDataset};
|
||||
|
||||
@@ -59,53 +59,73 @@ impl AddressDatasets {
|
||||
.for_each(|(cohort, _)| cohort.insert(insert_data))
|
||||
}
|
||||
|
||||
// pub fn needs_insert_utxo(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.utxo.needs_insert(height, date))
|
||||
pub fn needs_durable_states(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
let needs_insert_utxo = self.needs_insert_utxo(height, date);
|
||||
let needs_insert_capitalization = self.needs_insert_capitalization(height, date);
|
||||
let needs_insert_supply = self.needs_insert_supply(height, date);
|
||||
let needs_one_shot_states = self.needs_one_shot_states(height, date);
|
||||
|
||||
needs_insert_utxo
|
||||
|| needs_insert_capitalization
|
||||
|| needs_insert_supply
|
||||
|| needs_one_shot_states
|
||||
}
|
||||
|
||||
pub fn needs_one_shot_states(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.needs_insert_price_paid(height, date) || self.needs_insert_unrealized(height, date)
|
||||
}
|
||||
|
||||
// pub fn needs_sent_states(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.needs_insert_input(height, date) || self.needs_insert_realized(height, date)
|
||||
// }
|
||||
|
||||
// pub fn needs_insert_capitalization(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
pub fn needs_insert_utxo(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.cohorts
|
||||
.as_vec()
|
||||
.iter()
|
||||
.any(|(dataset, _)| dataset.needs_insert_utxo(height, date))
|
||||
}
|
||||
|
||||
pub fn needs_insert_capitalization(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.cohorts
|
||||
.as_vec()
|
||||
.iter()
|
||||
.any(|(dataset, _)| dataset.needs_insert_capitalization(height, date))
|
||||
}
|
||||
|
||||
pub fn needs_insert_supply(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.cohorts
|
||||
.as_vec()
|
||||
.iter()
|
||||
.any(|(dataset, _)| dataset.needs_insert_supply(height, date))
|
||||
}
|
||||
|
||||
pub fn needs_insert_price_paid(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.cohorts
|
||||
.as_vec()
|
||||
.iter()
|
||||
.any(|(dataset, _)| dataset.needs_insert_price_paid(height, date))
|
||||
}
|
||||
|
||||
// pub fn needs_insert_realized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.capitalization.needs_insert(height, date))
|
||||
// .any(|(dataset, _)| dataset.needs_insert_realized(height, date))
|
||||
// }
|
||||
|
||||
// pub fn needs_insert_supply(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.supply.needs_insert(height, date))
|
||||
// }
|
||||
pub fn needs_insert_unrealized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
self.cohorts
|
||||
.as_vec()
|
||||
.iter()
|
||||
.any(|(dataset, _)| dataset.needs_insert_unrealized(height, date))
|
||||
}
|
||||
|
||||
// pub fn needs_insert_price_paid(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// pub fn needs_insert_input(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.price_paid.needs_insert(height, date))
|
||||
// }
|
||||
|
||||
// fn needs_insert_realized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.realized.needs_insert(height, date))
|
||||
// }
|
||||
|
||||
// fn needs_insert_unrealized(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.unrealized.needs_insert(height, date))
|
||||
// }
|
||||
|
||||
// fn needs_insert_input(&self, height: usize, date: WNaiveDate) -> bool {
|
||||
// self.cohorts
|
||||
// .as_vec()
|
||||
// .iter()
|
||||
// .any(|(dataset, _)| dataset.input.needs_insert(height, date))
|
||||
// .any(|(dataset, _)| dataset.needs_insert_input(height, date))
|
||||
// }
|
||||
|
||||
pub fn compute(
|
||||
|
||||
@@ -48,6 +48,8 @@ impl UTXODataset {
|
||||
insert_data,
|
||||
&states
|
||||
.utxo_cohorts_durable_states
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(&self.id)
|
||||
.durable_states
|
||||
.supply_state,
|
||||
@@ -59,6 +61,8 @@ impl UTXODataset {
|
||||
insert_data,
|
||||
&states
|
||||
.utxo_cohorts_durable_states
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(&self.id)
|
||||
.durable_states
|
||||
.utxo_state,
|
||||
@@ -70,6 +74,8 @@ impl UTXODataset {
|
||||
insert_data,
|
||||
&states
|
||||
.utxo_cohorts_durable_states
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.get(&self.id)
|
||||
.durable_states
|
||||
.capitalization_state,
|
||||
|
||||
Reference in New Issue
Block a user