mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 15:19:58 -07:00
server: add support for .json .csv and ?all=true
This commit is contained in:
@@ -3,7 +3,8 @@ use allocative::Allocative;
|
||||
use crate::{
|
||||
datasets::{AnyDataset, InsertData, MinInitialStates},
|
||||
states::InputState,
|
||||
structs::{AnyBiMap, BiMap},
|
||||
structs::{AnyBiMap, AnyDateMap, AnyHeightMap, BiMap},
|
||||
DateMap, HeightMap,
|
||||
};
|
||||
|
||||
#[derive(Default, Allocative)]
|
||||
@@ -12,7 +13,8 @@ pub struct InputSubDataset {
|
||||
|
||||
// Inserted
|
||||
pub count: BiMap<u64>,
|
||||
pub volume: BiMap<f64>,
|
||||
pub volume: HeightMap<f64>,
|
||||
pub volume_1d_sum: DateMap<f64>,
|
||||
// Computed
|
||||
// add inputs_per_second
|
||||
}
|
||||
@@ -31,7 +33,8 @@ impl InputSubDataset {
|
||||
min_initial_states: MinInitialStates::default(),
|
||||
|
||||
count: BiMap::new_bin(1, &f("input_count")),
|
||||
volume: BiMap::new_bin(1, &f("input_volume")),
|
||||
volume: HeightMap::new_bin(1, &f("input_volume")),
|
||||
volume_1d_sum: DateMap::new_bin(1, &f("input_volume_1d_sum")),
|
||||
};
|
||||
|
||||
s.min_initial_states
|
||||
@@ -56,12 +59,13 @@ impl InputSubDataset {
|
||||
.height
|
||||
.insert(height, state.count().round() as u64);
|
||||
|
||||
self.volume.height.insert(height, state.volume().to_btc());
|
||||
self.volume.insert(height, state.volume().to_btc());
|
||||
|
||||
if is_date_last_block {
|
||||
self.count.date.insert(date, count);
|
||||
|
||||
self.volume.date_insert_sum_range(date, date_blocks_range);
|
||||
self.volume_1d_sum
|
||||
.insert(date, self.volume.sum_range(date_blocks_range));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,10 +76,26 @@ impl AnyDataset for InputSubDataset {
|
||||
}
|
||||
|
||||
fn to_inserted_bi_map_vec(&self) -> Vec<&(dyn AnyBiMap + Send + Sync)> {
|
||||
vec![&self.count, &self.volume]
|
||||
vec![&self.count]
|
||||
}
|
||||
|
||||
fn to_inserted_mut_bi_map_vec(&mut self) -> Vec<&mut dyn AnyBiMap> {
|
||||
vec![&mut self.count, &mut self.volume]
|
||||
vec![&mut self.count]
|
||||
}
|
||||
|
||||
fn to_inserted_height_map_vec(&self) -> Vec<&(dyn AnyHeightMap + Send + Sync)> {
|
||||
vec![&self.volume]
|
||||
}
|
||||
|
||||
fn to_inserted_mut_height_map_vec(&mut self) -> Vec<&mut dyn AnyHeightMap> {
|
||||
vec![&mut self.volume]
|
||||
}
|
||||
|
||||
fn to_inserted_date_map_vec(&self) -> Vec<&(dyn AnyDateMap + Send + Sync)> {
|
||||
vec![&self.volume_1d_sum]
|
||||
}
|
||||
|
||||
fn to_inserted_mut_date_map_vec(&mut self) -> Vec<&mut dyn AnyDateMap> {
|
||||
vec![&mut self.volume_1d_sum]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user