mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-28 08:39:59 -07:00
parser: fix metadata versioning
This commit is contained in:
@@ -14,7 +14,7 @@ use crate::{
|
||||
states::{AddressCohortsDurableStates, States, UTXOCohortsDurableStates},
|
||||
structs::{DateData, MapKey, Timestamp, RAM},
|
||||
utils::{generate_allocation_files, log, time},
|
||||
Config, Date, Exit, Height,
|
||||
Config, Exit, Height,
|
||||
};
|
||||
|
||||
pub fn iter_blocks(
|
||||
@@ -175,9 +175,11 @@ pub fn iter_blocks(
|
||||
if is_date_last_block {
|
||||
height += blocks_loop_i;
|
||||
|
||||
let is_new_year = next_block_date.as_ref().map_or(true, Date::is_new_year);
|
||||
let is_check_point = next_block_date.as_ref().map_or(true, |date| {
|
||||
date.is_first_of_january() || date.is_first_of_june()
|
||||
});
|
||||
|
||||
if is_new_year
|
||||
if is_check_point
|
||||
|| ram.max_exceeded(config)
|
||||
|| height.is_close_to_end(approx_block_count)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Metadata {
|
||||
pub fn import(path: &str, version: u16) -> Self {
|
||||
Self {
|
||||
path: path.to_owned(),
|
||||
data: MetadataData::import(path, version).unwrap_or_default(),
|
||||
data: MetadataData::import(path, version),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,13 @@ impl MetadataData {
|
||||
format!("{folder_path}/{name}")
|
||||
}
|
||||
|
||||
pub fn import(path: &str, version: u16) -> color_eyre::Result<Self> {
|
||||
pub fn import(path: &str, version: u16) -> Self {
|
||||
let mut s = Self::_import(path, version).unwrap_or_default();
|
||||
s.version = version;
|
||||
s
|
||||
}
|
||||
|
||||
fn _import(path: &str, version: u16) -> color_eyre::Result<Self> {
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
let s: MetadataData = Serialization::Binary.import(Path::new(&Self::full_path(path)))?;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct Config {
|
||||
#[arg(long, value_name = "SECONDS")]
|
||||
pub delay: Option<u64>,
|
||||
|
||||
/// Maximum ram you want the program to use in GB, default: 75% of total, not saved
|
||||
/// Maximum ram you want the program to use in GB, default: 50% of total, not saved
|
||||
#[arg(long, value_name = "GB")]
|
||||
pub max_ram: Option<f64>,
|
||||
|
||||
|
||||
@@ -74,9 +74,13 @@ impl Date {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_new_year(&self) -> bool {
|
||||
pub fn is_first_of_january(&self) -> bool {
|
||||
self.day() == 1 && self.month() == 1
|
||||
}
|
||||
|
||||
pub fn is_first_of_june(&self) -> bool {
|
||||
self.day() == 1 && self.month() == 6
|
||||
}
|
||||
}
|
||||
|
||||
impl MapKey<DateMapChunkId> for Date {
|
||||
|
||||
@@ -20,7 +20,7 @@ impl RAM {
|
||||
(ram_used / 1_000_000_000.0) > max_ram
|
||||
} else {
|
||||
let ram_total = self.total_memory() as f64;
|
||||
ram_used / ram_total > 0.75
|
||||
ram_used / ram_total > 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user