mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 23:59:58 -07:00
app: add height datasets
This commit is contained in:
@@ -185,6 +185,7 @@ impl MiningDataset {
|
||||
block_size_recap: RecapDataset::import(
|
||||
&f("block_size_1d"),
|
||||
RecapOptions::default()
|
||||
.add_sum()
|
||||
.add_average()
|
||||
.add_max()
|
||||
.add_90p()
|
||||
@@ -548,7 +549,12 @@ impl MiningDataset {
|
||||
|
||||
self.block_size_recap.compute(
|
||||
*date,
|
||||
&mut self.block_vbytes.get_or_import_range_inclusive(first, last),
|
||||
&mut self
|
||||
.block_size
|
||||
.get_or_import_range_inclusive(first, last)
|
||||
.into_iter()
|
||||
.map(OrderedFloat)
|
||||
.collect_vec(),
|
||||
);
|
||||
|
||||
self.block_weight_recap.compute(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::BTreeMap, ops::RangeInclusive};
|
||||
use std::{collections::BTreeMap, fs, ops::RangeInclusive};
|
||||
|
||||
use allocative::Allocative;
|
||||
|
||||
@@ -140,7 +140,7 @@ impl AllDatasets {
|
||||
s.min_initial_states
|
||||
.consume(MinInitialStates::compute_from_datasets(&s));
|
||||
|
||||
s.export_path_to_type()?;
|
||||
s.export_meta_files()?;
|
||||
|
||||
Ok(s)
|
||||
}
|
||||
@@ -263,7 +263,7 @@ impl AllDatasets {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn export_path_to_type(&self) -> color_eyre::Result<()> {
|
||||
pub fn export_meta_files(&self) -> color_eyre::Result<()> {
|
||||
let path_to_type: BTreeMap<&str, &str> = self
|
||||
.to_any_dataset_vec()
|
||||
.into_iter()
|
||||
@@ -275,7 +275,27 @@ impl AllDatasets {
|
||||
})
|
||||
.collect();
|
||||
|
||||
Json::export("../datasets/disk_path_to_type.json", &path_to_type)
|
||||
let datasets_len = path_to_type.len();
|
||||
|
||||
Json::export("../datasets/disk_path_to_type.json", &path_to_type)?;
|
||||
|
||||
let server_trigger_path = "../server/.trigger";
|
||||
|
||||
fs::create_dir_all(server_trigger_path)?;
|
||||
|
||||
let datasets_len_path = format!("{server_trigger_path}/datasets_len.txt");
|
||||
|
||||
if let Ok(len) = fs::read_to_string(&datasets_len_path) {
|
||||
if let Ok(len) = len.parse::<usize>() {
|
||||
if datasets_len == len {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs::write(datasets_len_path, datasets_len.to_string())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn export(&mut self) -> color_eyre::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user