global: snapshot

This commit is contained in:
nym21
2025-11-11 09:36:24 +01:00
parent 37f5f50867
commit 2dcbd8df99
101 changed files with 978 additions and 456 deletions
Generated
+1
View File
@@ -710,6 +710,7 @@ dependencies = [
"jiff",
"log",
"owo-colors",
"parking_lot",
]
[[package]]
+36 -13
View File
@@ -15,6 +15,7 @@ use brk_error::Result;
pub struct Bencher {
bench_dir: PathBuf,
monitored_path: PathBuf,
stop_flag: Arc<AtomicBool>,
monitor_thread: Option<JoinHandle<Result<()>>>,
}
@@ -22,7 +23,7 @@ pub struct Bencher {
impl Bencher {
/// Create a new bencher for the given crate name
/// Creates directory structure: workspace_root/benches/{crate_name}/{timestamp}/
pub fn new(crate_name: &str, workspace_root: &Path) -> Result<Self> {
pub fn new(crate_name: &str, workspace_root: &Path, monitored_path: &Path) -> Result<Self> {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
let bench_dir = workspace_root
@@ -34,18 +35,36 @@ impl Bencher {
Ok(Self {
bench_dir,
monitored_path: monitored_path.to_path_buf(),
stop_flag: Arc::new(AtomicBool::new(false)),
monitor_thread: None,
})
}
/// Create a bencher using CARGO_MANIFEST_DIR to find workspace root
pub fn from_cargo_env() -> Result<Self> {
let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.ok_or("Failed to find workspace root")?;
let crate_name = env!("CARGO_PKG_NAME");
Self::new(crate_name, workspace_root)
pub fn from_cargo_env(crate_name: &str, monitored_path: &Path) -> Result<Self> {
let mut current = std::env::current_dir()
.map_err(|e| format!("Failed to get current directory: {}", e))
.unwrap();
let workspace_root = loop {
let cargo_toml = current.join("Cargo.toml");
if cargo_toml.exists() {
let contents = std::fs::read_to_string(&cargo_toml)
.map_err(|e| format!("Failed to read Cargo.toml: {}", e))
.unwrap();
if contents.contains("[workspace]") {
break current;
}
}
current = current
.parent()
.ok_or("Workspace root not found")?
.to_path_buf();
};
Self::new(crate_name, &workspace_root, monitored_path)
}
/// Start monitoring disk usage and memory footprint
@@ -56,8 +75,10 @@ impl Bencher {
let stop_flag = self.stop_flag.clone();
let bench_dir = self.bench_dir.clone();
let monitored_path = self.monitored_path.clone();
let handle = thread::spawn(move || monitor_resources(&bench_dir, stop_flag));
let handle =
thread::spawn(move || monitor_resources(&monitored_path, &bench_dir, stop_flag));
self.monitor_thread = Some(handle);
Ok(())
@@ -189,7 +210,11 @@ fn get_memory_usage(pid: u32) -> Result<(f64, f64)> {
}
}
fn monitor_resources(bench_dir: &Path, stop_flag: Arc<AtomicBool>) -> Result<()> {
fn monitor_resources(
monitored_path: &Path,
bench_dir: &Path,
stop_flag: Arc<AtomicBool>,
) -> Result<()> {
let disk_file = bench_dir.join("disk_usage.csv");
let memory_file = bench_dir.join("memory_footprint.csv");
@@ -210,23 +235,21 @@ fn monitor_resources(bench_dir: &Path, stop_flag: Arc<AtomicBool>) -> Result<()>
// Get disk usage
if let Ok(output) = Command::new("du")
.args(["-sh", bench_dir.to_str().unwrap()])
.args(["-sh", monitored_path.to_str().unwrap()])
.output()
&& let Ok(stdout) = String::from_utf8(output.stdout)
&& let Some(size_str) = stdout.split_whitespace().next()
&& let Some(size_mb) = parse_du_output(size_str)
{
writeln!(disk_writer, "{},{}", elapsed_ms, size_mb)?;
disk_writer.flush()?;
}
// Get memory footprint (cross-platform)
if let Ok((footprint, peak)) = get_memory_usage(pid) {
writeln!(memory_writer, "{},{},{}", elapsed_ms, footprint, peak)?;
memory_writer.flush()?;
}
thread::sleep(Duration::from_secs(1));
thread::sleep(Duration::from_secs(5));
}
Ok(())
+108 -44
View File
@@ -18,6 +18,18 @@ struct BenchmarkRun {
data: Vec<DataPoint>,
}
// Dark theme colors
const BG_COLOR: RGBColor = RGBColor(18, 18, 24);
const TEXT_COLOR: RGBColor = RGBColor(230, 230, 240);
const CHART_COLORS: [RGBColor; 6] = [
RGBColor(255, 99, 132), // Pink/Red
RGBColor(54, 162, 235), // Blue
RGBColor(75, 192, 192), // Teal
RGBColor(255, 206, 86), // Yellow
RGBColor(153, 102, 255), // Purple
RGBColor(255, 159, 64), // Orange
];
pub struct Visualizer {
workspace_root: PathBuf,
}
@@ -32,6 +44,7 @@ impl Visualizer {
pub fn from_cargo_env() -> Result<Self> {
let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.and_then(|p| p.parent())
.ok_or("Failed to find workspace root")?
.to_path_buf();
Ok(Self { workspace_root })
@@ -141,10 +154,10 @@ impl Visualizer {
crate_name: &str,
runs: &[BenchmarkRun],
) -> Result<()> {
let output_path = crate_path.join("disk_usage_chart.png");
let output_path = crate_path.join("disk_usage_chart.svg");
let root = BitMapBackend::new(&output_path, (1200, 800)).into_drawing_area();
root.fill(&WHITE)?;
let root = SVGBackend::new(&output_path, (1200, 700)).into_drawing_area();
root.fill(&BG_COLOR)?;
let max_time = runs
.iter()
@@ -157,40 +170,59 @@ impl Visualizer {
.flat_map(|r| r.data.iter().map(|d| d.value))
.fold(0.0_f64, f64::max);
// Convert to seconds and GB
let max_time_s = (max_time as f64) / 1000.0;
let max_value_gb = max_value / 1024.0;
let mut chart = ChartBuilder::on(&root)
.caption(
format!("{} - Disk Usage", crate_name),
("sans-serif", 40).into_font(),
format!("{} Disk Usage", crate_name),
("SF Mono", 24).into_font().color(&TEXT_COLOR),
)
.margin(10)
.x_label_area_size(40)
.y_label_area_size(60)
.build_cartesian_2d(0u64..max_time, 0.0..max_value * 1.1)?;
.margin(20)
.x_label_area_size(55)
.y_label_area_size(75)
.build_cartesian_2d(0.0..max_time_s * 1.05, 0.0..max_value_gb * 1.1)?;
chart
.configure_mesh()
.x_desc("Time (ms)")
.y_desc("Disk Usage (MB)")
.disable_mesh()
.x_desc("Time (s)")
.y_desc("Disk Usage (GB)")
.x_label_offset(10)
.y_label_offset(10)
.x_label_formatter(&|x| format!("{:.1}", x))
.y_label_formatter(&|y| format!("{:.2}", y))
.x_labels(8)
.y_labels(6)
.x_label_style(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.7)))
.y_label_style(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.7)))
.axis_style(TEXT_COLOR.mix(0.3))
.draw()?;
let colors = [&RED, &BLUE, &GREEN, &CYAN, &MAGENTA, &YELLOW];
for (idx, run) in runs.iter().enumerate() {
let color = colors[idx % colors.len()];
let color = CHART_COLORS[idx % CHART_COLORS.len()];
chart
.draw_series(LineSeries::new(
run.data.iter().map(|d| (d.timestamp_ms, d.value)),
color,
run.data
.iter()
.map(|d| (d.timestamp_ms as f64 / 1000.0, d.value / 1024.0)),
color.stroke_width(2),
))?
.label(&run.run_id)
.legend(move |(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], color));
.legend(move |(x, y)| {
PathElement::new(vec![(x, y), (x + 20, y)], color.stroke_width(2))
});
}
chart
.configure_series_labels()
.background_style(WHITE.mix(0.8))
.border_style(BLACK)
.position(SeriesLabelPosition::UpperLeft)
.label_font(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.9)))
.background_style(BG_COLOR.mix(0.98))
.border_style(BG_COLOR)
.margin(10)
.draw()?;
root.present()?;
@@ -205,10 +237,10 @@ impl Visualizer {
crate_name: &str,
runs: &[BenchmarkRun],
) -> Result<()> {
let output_path = crate_path.join("memory_footprint_chart.png");
let output_path = crate_path.join("memory_footprint_chart.svg");
let root = BitMapBackend::new(&output_path, (1200, 800)).into_drawing_area();
root.fill(&WHITE)?;
let root = SVGBackend::new(&output_path, (1200, 700)).into_drawing_area();
root.fill(&BG_COLOR)?;
// Read memory CSV files which have 3 columns: timestamp, footprint, peak
let mut enhanced_runs = Vec::new();
@@ -259,55 +291,87 @@ impl Visualizer {
.flat_map(|(_, f, p)| f.iter().chain(p.iter()).map(|d| d.value))
.fold(0.0_f64, f64::max);
// Convert to seconds and GB
let max_time_s = (max_time as f64) / 1000.0;
let max_value_gb = max_value / 1024.0;
let mut chart = ChartBuilder::on(&root)
.caption(
format!("{} - Memory Footprint", crate_name),
("sans-serif", 40).into_font(),
format!("{} Memory Footprint", crate_name),
("SF Mono", 24).into_font().color(&TEXT_COLOR),
)
.margin(10)
.x_label_area_size(40)
.y_label_area_size(60)
.build_cartesian_2d(0u64..max_time, 0.0..max_value * 1.1)?;
.margin(20)
.x_label_area_size(55)
.y_label_area_size(75)
.build_cartesian_2d(0.0..max_time_s * 1.05, 0.0..max_value_gb * 1.1)?;
chart
.configure_mesh()
.x_desc("Time (ms)")
.y_desc("Memory (MB)")
.disable_mesh()
.x_desc("Time (s)")
.y_desc("Memory (GB)")
.x_label_offset(10)
.y_label_offset(10)
.x_label_formatter(&|x| format!("{:.1}", x))
.y_label_formatter(&|y| format!("{:.2}", y))
.x_labels(8)
.y_labels(6)
.x_label_style(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.7)))
.y_label_style(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.7)))
.axis_style(TEXT_COLOR.mix(0.3))
.draw()?;
let colors = [&RED, &BLUE, &GREEN, &CYAN, &MAGENTA, &YELLOW];
for (idx, (run_id, footprint_data, peak_data)) in enhanced_runs.iter().enumerate() {
let color = colors[idx % colors.len()];
let color = CHART_COLORS[idx % CHART_COLORS.len()];
// Draw footprint line (solid)
chart
.draw_series(LineSeries::new(
footprint_data.iter().map(|d| (d.timestamp_ms, d.value)),
color,
footprint_data
.iter()
.map(|d| (d.timestamp_ms as f64 / 1000.0, d.value / 1024.0)),
color.stroke_width(2),
))?
.label(format!("{} (current)", run_id))
.legend(move |(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], color));
.legend(move |(x, y)| {
PathElement::new(vec![(x, y), (x + 20, y)], color.stroke_width(2))
});
// Draw peak line (dashed)
// Draw peak line (dashed, slightly transparent)
let dashed_color = color.mix(0.5);
chart
.draw_series(LineSeries::new(
peak_data.iter().map(|d| (d.timestamp_ms, d.value)),
color.stroke_width(2).filled(),
))?
.draw_series(
peak_data
.iter()
.map(|d| (d.timestamp_ms as f64 / 1000.0, d.value / 1024.0))
.zip(
peak_data
.iter()
.skip(1)
.map(|d| (d.timestamp_ms as f64 / 1000.0, d.value / 1024.0)),
)
.enumerate()
.filter(|(i, _)| i % 2 == 0) // Create dashed effect
.map(|(_, (p1, p2))| {
PathElement::new(vec![p1, p2], dashed_color.stroke_width(2))
}),
)?
.label(format!("{} (peak)", run_id))
.legend(move |(x, y)| {
PathElement::new(
vec![(x, y), (x + 10, y), (x + 20, y)],
color.stroke_width(2),
dashed_color.stroke_width(2),
)
});
}
chart
.configure_series_labels()
.background_style(WHITE.mix(0.8))
.border_style(BLACK)
.position(SeriesLabelPosition::UpperLeft)
.label_font(("SF Mono", 16).into_font().color(&TEXT_COLOR.mix(0.9)))
.background_style(BG_COLOR.mix(0.98))
.border_style(BG_COLOR)
.margin(10)
.draw()?;
root.present()?;
+1 -1
View File
@@ -11,7 +11,7 @@ use brk_types::{
};
use vecdb::{
Database, EagerVec, Exit, IterableCloneableVec, IterableVec, LazyVecFrom1, LazyVecFrom2,
LazyVecFrom3, PAGE_SIZE, StoredIndex, TypedVecIterator,
LazyVecFrom3, PAGE_SIZE, TypedVecIterator, VecIndex,
};
use crate::grouped::{
+1 -1
View File
@@ -7,7 +7,7 @@ use brk_traversable::Traversable;
use brk_types::{DateIndex, Height, OHLCCents, Version};
use vecdb::{
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, IterableVec, PAGE_SIZE, RawVec,
StoredIndex, VecIterator,
VecIndex, VecIterator,
};
use super::{Indexes, indexes};
@@ -3,7 +3,7 @@ use brk_traversable::Traversable;
use brk_types::{CheckedSub, StoredU64, Version};
use vecdb::{
AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec, IterableVec,
StoredIndex, StoredRaw,
VecIndex, VecValue,
};
use crate::utils::get_percentile;
@@ -13,7 +13,7 @@ use super::ComputedType;
#[derive(Clone, Debug, Traversable)]
pub struct EagerVecsBuilder<I, T>
where
I: StoredIndex,
I: VecIndex,
T: ComputedType,
{
pub first: Option<Box<EagerVec<I, T>>>,
@@ -34,7 +34,7 @@ const VERSION: Version = Version::ZERO;
impl<I, T> EagerVecsBuilder<I, T>
where
I: StoredIndex,
I: VecIndex,
T: ComputedType,
{
pub fn forced_import_compressed(
@@ -244,7 +244,7 @@ where
exit: &Exit,
) -> Result<()>
where
I2: StoredIndex + StoredRaw + CheckedSub<I2>,
I2: VecIndex + VecValue + CheckedSub<I2>,
{
self.validate_computed_version_or_reset(
source.version() + first_indexes.version() + count_indexes.version(),
@@ -403,7 +403,7 @@ where
exit: &Exit,
) -> Result<()>
where
I2: StoredIndex + StoredRaw + CheckedSub<I2>,
I2: VecIndex + VecValue + CheckedSub<I2>,
{
if self.pct90.is_some()
|| self.pct75.is_some()
@@ -1,6 +1,6 @@
use brk_traversable::Traversable;
use brk_types::Version;
use vecdb::{FromCoarserIndex, IterableBoxedVec, IterableCloneableVec, LazyVecFrom2, StoredIndex};
use vecdb::{FromCoarserIndex, IterableBoxedVec, IterableCloneableVec, LazyVecFrom2, VecIndex};
use crate::grouped::{EagerVecsBuilder, VecBuilderOptions};
@@ -10,9 +10,9 @@ use super::ComputedType;
#[derive(Clone, Traversable)]
pub struct LazyVecsBuilder<I, T, S1I, S2T>
where
I: StoredIndex,
I: VecIndex,
T: ComputedType,
S1I: StoredIndex,
S1I: VecIndex,
S2T: ComputedType,
{
pub first: Option<Box<LazyVecFrom2<I, T, S1I, T, I, S2T>>>,
@@ -28,9 +28,9 @@ const VERSION: Version = Version::ZERO;
impl<I, T, S1I, S2T> LazyVecsBuilder<I, T, S1I, S2T>
where
I: StoredIndex,
I: VecIndex,
T: ComputedType + 'static,
S1I: StoredIndex + 'static + FromCoarserIndex<I>,
S1I: VecIndex + 'static + FromCoarserIndex<I>,
S2T: ComputedType,
{
#[allow(clippy::too_many_arguments)]
+13 -11
View File
@@ -1,23 +1,25 @@
use std::ops::{Add, AddAssign, Div};
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
pub trait ComputedType
where
Self: StoredCompressed
+ From<usize>
+ Div<usize, Output = Self>
+ Add<Output = Self>
+ AddAssign
+ Ord,
{
}
impl<T> ComputedType for T where
T: StoredCompressed
Self: Compressable
+ From<usize>
+ Div<usize, Output = Self>
+ Add<Output = Self>
+ AddAssign
+ Ord
+ Formattable,
{
}
impl<T> ComputedType for T where
T: Compressable
+ From<usize>
+ Div<usize, Output = Self>
+ Add<Output = Self>
+ AddAssign
+ Ord
+ Formattable
{
}
@@ -7,7 +7,7 @@ use brk_types::{
};
use vecdb::{
AnyVec, AnyWritableVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
IterableCloneableVec, StoredIndex, TypedVecIterator,
IterableCloneableVec, TypedVecIterator, VecIndex,
};
use crate::{
@@ -3,7 +3,7 @@ use brk_traversable::Traversable;
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
use vecdb::{
AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec, IterableVec,
StoredIndex, TypedVecIterator,
TypedVecIterator, VecIndex,
};
use crate::{
@@ -3,7 +3,7 @@ use brk_traversable::Traversable;
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
use vecdb::{
AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec, Exit,
GenericStoredVec, IterableVec, StoredIndex,
GenericStoredVec, IterableVec, VecIndex,
};
use crate::{Indexes, grouped::source::Source, indexes};
@@ -3,8 +3,8 @@ use brk_indexer::Indexer;
use brk_traversable::Traversable;
use brk_types::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
use vecdb::{
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, StoredIndex,
StoredVec,
CollectableVec, Database, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom3, StoredVec,
VecIndex,
};
use crate::{Indexes, grouped::Source, indexes, price};
+1 -1
View File
@@ -14,7 +14,7 @@ use brk_types::{
};
use vecdb::{
Database, EagerVec, Exit, IterableCloneableVec, LazyVecFrom1, LazyVecFrom2, PAGE_SIZE,
StoredIndex, TypedVecIterator,
TypedVecIterator, VecIndex,
};
const VERSION: Version = Version::ZERO;
+1 -1
View File
@@ -3,7 +3,7 @@ use std::{path::Path, thread};
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Date, DateIndex, Dollars, Height, Sats, StoredF32, StoredU16, Version};
use vecdb::{Database, EagerVec, Exit, GenericStoredVec, PAGE_SIZE, StoredIndex, TypedVecIterator};
use vecdb::{Database, EagerVec, Exit, GenericStoredVec, PAGE_SIZE, TypedVecIterator, VecIndex};
use crate::{
grouped::{ComputedStandardDeviationVecsFromDateIndex, Source, StandardDeviationVecsOptions},
+1 -1
View File
@@ -8,7 +8,7 @@ use brk_types::{Address, AddressBytes, Height, OutputType, PoolId, Pools, TxOutI
use rayon::prelude::*;
use vecdb::{
AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, IterableVec, PAGE_SIZE, RawVec,
StoredIndex, TypedVecIterator, Version,
TypedVecIterator, VecIndex, Version,
};
mod vecs;
+1 -1
View File
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Height, PoolId, Pools, Sats, StoredF32, StoredU16, StoredU32};
use vecdb::{Database, Exit, GenericStoredVec, IterableVec, StoredIndex, Version};
use vecdb::{Database, Exit, GenericStoredVec, IterableVec, VecIndex, Version};
use crate::{
chain,
+1 -1
View File
@@ -8,7 +8,7 @@ use brk_types::{
};
use vecdb::{
AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, IterableVec, PAGE_SIZE,
RawVec, StoredIndex,
RawVec, VecIndex,
};
use crate::{fetched, grouped::Source};
+1 -1
View File
@@ -18,7 +18,7 @@ use smallvec::SmallVec;
use vecdb::{
AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec, Exit, Format,
GenericStoredVec, ImportOptions, IterableCloneableVec, IterableVec, LazyVecFrom1, PAGE_SIZE,
RawVec, Reader, Stamp, StoredIndex, TypedVecIterator,
RawVec, Reader, Stamp, TypedVecIterator, VecIndex,
};
use crate::{
@@ -1,14 +1,14 @@
use std::collections::BTreeMap;
use vecdb::{CompressedVec, RawVec, StoredCompressed, StoredIndex, StoredRaw};
use vecdb::{Compressable, CompressedVec, RawVec, VecIndex, VecValue};
#[derive(Debug)]
pub struct RangeMap<I, T>(BTreeMap<I, T>);
impl<I, T> RangeMap<I, T>
where
I: StoredIndex,
T: StoredIndex,
I: VecIndex,
T: VecIndex,
{
pub fn get(&self, key: I) -> Option<&T> {
self.0.range(..=key).next_back().map(|(&min, value)| {
@@ -22,8 +22,8 @@ where
impl<I, T> From<&RawVec<I, T>> for RangeMap<T, I>
where
I: StoredIndex,
T: StoredIndex + StoredRaw,
I: VecIndex,
T: VecIndex + VecValue,
{
#[inline]
fn from(vec: &RawVec<I, T>) -> Self {
@@ -38,8 +38,8 @@ where
impl<I, T> From<&CompressedVec<I, T>> for RangeMap<T, I>
where
I: StoredIndex,
T: StoredIndex + StoredCompressed,
I: VecIndex,
T: VecIndex + Compressable,
{
#[inline]
fn from(vec: &CompressedVec<I, T>) -> Self {
@@ -11,7 +11,7 @@ use brk_types::{
};
use derive_deref::{Deref, DerefMut};
use rustc_hash::FxHashMap;
use vecdb::{Database, Exit, Format, IterableVec, StoredIndex};
use vecdb::{Database, Exit, Format, IterableVec, VecIndex};
use crate::{
Indexes, indexes, price,
+8
View File
@@ -2,6 +2,7 @@ use std::ops::{Add, AddAssign, SubAssign};
use brk_types::{CheckedSub, LoadedAddressData, Sats};
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)]
@@ -55,3 +56,10 @@ impl std::fmt::Display for SupplyState {
write!(f, "utxos: {}, value: {}", self.utxo_count, self.value)
}
}
impl Formattable for SupplyState {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+4 -4
View File
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_types::{Bitcoin, CheckedSub, Close, Date, DateIndex, Dollars, Sats, StoredF32};
use vecdb::{
AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, IterableVec, StoredIndex, Version,
AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, IterableVec, VecIndex, Version,
};
const DCA_AMOUNT: Dollars = Dollars::mint(100.0);
@@ -225,7 +225,7 @@ pub trait ComputeFromSats<I> {
}
impl<I> ComputeFromSats<I> for EagerVec<I, Bitcoin>
where
I: StoredIndex,
I: VecIndex,
{
fn compute_from_sats(
&mut self,
@@ -263,7 +263,7 @@ pub trait ComputeFromBitcoin<I> {
}
impl<I> ComputeFromBitcoin<I> for EagerVec<I, Dollars>
where
I: StoredIndex,
I: VecIndex,
{
fn compute_from_bitcoin(
&mut self,
@@ -305,7 +305,7 @@ pub trait ComputeDrawdown<I> {
}
impl<I> ComputeDrawdown<I> for EagerVec<I, StoredF32>
where
I: StoredIndex,
I: VecIndex,
{
fn compute_drawdown(
&mut self,
+4 -1
View File
@@ -34,13 +34,16 @@ fn main() -> Result<()> {
let exit = Exit::new();
exit.set_ctrlc_handler();
let mut bencher = Bencher::from_cargo_env()?;
let mut bencher =
Bencher::from_cargo_env(env!("CARGO_PKG_NAME"), &outputs_dir.join("indexed/stores"))?;
bencher.start()?;
let i = Instant::now();
indexer.checked_index(&blocks, &client, &exit)?;
dbg!(i.elapsed());
drop(indexer);
// Stop and finalize
bencher.stop()?;
@@ -9,7 +9,7 @@ use brk_error::Result;
use brk_indexer::Indexer;
use brk_types::TxInIndex;
use rayon::prelude::*;
use vecdb::{AnyVec, GenericStoredVec, StoredIndex};
use vecdb::{AnyVec, GenericStoredVec, VecIndex};
fn main() -> Result<()> {
brk_logger::init(Some(Path::new(".log")))?;
+3 -3
View File
@@ -6,7 +6,7 @@ use brk_types::{
UnknownOutputIndex,
};
use log::debug;
use vecdb::{GenericStoredVec, IterableStoredVec, IterableVec, StoredIndex, StoredRaw};
use vecdb::{GenericStoredVec, IterableStoredVec, IterableVec, VecIndex, VecValue};
use crate::{Stores, Vecs};
@@ -227,8 +227,8 @@ pub fn starting_index<I, T>(
starting_height: Height,
) -> Option<I>
where
I: StoredRaw + StoredIndex + From<usize>,
T: StoredRaw,
I: VecValue + VecIndex + From<usize>,
T: VecValue,
{
let h = Height::from(height_to_index.stamp());
if h.is_zero() {
+1 -1
View File
@@ -10,7 +10,7 @@ use brk_types::{
};
use fjall2::{CompressionType as Compression, PersistMode, TransactionalKeyspace};
use rayon::prelude::*;
use vecdb::{AnyVec, GenericStoredVec, StoredIndex, TypedVecIterator, VecIterator};
use vecdb::{AnyVec, GenericStoredVec, TypedVecIterator, VecIndex, VecIterator};
use crate::Indexes;
+16 -7
View File
@@ -8,9 +8,9 @@ use brk_types::{
OutPoint, OutputType, StoredString, TxIndex, TxOutIndex, TxidPrefix, TypeIndex, Unit, Version,
Vout,
};
use fjall3::{Database, PersistMode};
use fjall3::{Database, PersistMode, WriteBatch};
use rayon::prelude::*;
use vecdb::{AnyVec, GenericStoredVec, StoredIndex, TypedVecIterator, VecIterator};
use vecdb::{AnyVec, GenericStoredVec, TypedVecIterator, VecIndex, VecIterator};
use crate::Indexes;
@@ -158,13 +158,10 @@ impl Stores {
}
pub fn commit(&mut self, height: Height) -> Result<()> {
[
let items = [
&mut self.blockhashprefix_to_height as &mut dyn AnyStore,
&mut self.height_to_coinbase_tag,
&mut self.txidprefix_to_txindex,
// &mut self.addresshash_to_typeindex
// &mut self.addresstype_to_addressindex_and_txindex,
// &mut self.addresstype_to_addressindex_and_unspentoutpoint,
]
.into_par_iter()
.chain(
@@ -182,7 +179,19 @@ impl Stores {
.par_iter_mut()
.map(|s| s as &mut dyn AnyStore),
) // Changed from par_iter_mut()
.try_for_each(|store| store.commit(height))?;
.map(|store| {
let items = store.take_all_f3();
store.export_meta_if_needed(height)?;
Ok(items)
})
.collect::<Result<Vec<_>>>()?;
let capacity = items.iter().map(|v| v.len()).sum();
let mut batch = WriteBatch::with_capacity(self.database.clone(), capacity);
items.into_iter().for_each(|items| {
batch.ingest(items);
});
batch.commit()?;
self.database
.persist(PersistMode::SyncAll)
+1
View File
@@ -14,3 +14,4 @@ env_logger = "0.11.8"
jiff = { workspace = true }
log = { workspace = true }
owo-colors = "4.2.3"
parking_lot = { workspace = true }
+12 -18
View File
@@ -5,26 +5,27 @@ use std::{
fs::{self, OpenOptions},
io::{self, Write},
path::Path,
sync::OnceLock,
};
use env_logger::{Builder, Env};
use jiff::{Timestamp, tz};
pub use owo_colors::OwoColorize;
use parking_lot::Mutex;
static LOG_FILE: OnceLock<Mutex<fs::File>> = OnceLock::new();
#[inline]
pub fn init(path: Option<&Path>) -> io::Result<()> {
let file = path.map(|path| {
if let Some(path) = path {
let _ = fs::remove_file(path);
OpenOptions::new()
.create(true)
.append(true)
.open(path)
.unwrap()
});
let file = OpenOptions::new().create(true).append(true).open(path)?;
LOG_FILE.set(Mutex::new(file)).ok();
}
Builder::from_env(Env::default().default_filter_or(
// "info,bitcoin=off,bitcoincore-rpc=off,fjall=off,lsm-tree=off,rolldown=off,rolldown=off,rmcp=off,brk_rmcp=off,tracing=off,aide=off,brk_aide=off",
"debug,bitcoin=off,bitcoincore-rpc=off,rolldown=off,rolldown=off,rmcp=off,brk_rmcp=off,tracing=off,aide=off,brk_aide=off",
"info,bitcoin=off,bitcoincore-rpc=off,fjall=off,lsm-tree=off,rolldown=off,rolldown=off,rmcp=off,brk_rmcp=off,tracing=off,aide=off,brk_aide=off",
// "debug,fjall=trace,bitcoin=off,bitcoincore-rpc=off,rolldown=off,rolldown=off,rmcp=off,brk_rmcp=off,tracing=off,aide=off,brk_aide=off",
))
.format(move |buf, record| {
let date_time = Timestamp::now()
@@ -37,15 +38,8 @@ pub fn init(path: Option<&Path>) -> io::Result<()> {
let dash = "-";
let args = record.args();
if let Some(file) = file.as_ref() {
let _ = write(
file.try_clone().unwrap(),
&date_time,
target,
&level,
dash,
args,
);
if let Some(file) = LOG_FILE.get() {
let _ = write(&mut *file.lock(), &date_time, target, &level, dash, args);
}
let colored_date_time = date_time.bright_black();
+1 -16
View File
@@ -155,22 +155,7 @@ impl Query {
if index > 0 {
csv.push(',');
}
// Check if we need CSV escaping
let start_pos = csv.len();
if writer.write_next(&mut csv)? {
let end_pos = csv.len();
// If contains comma, rewrite with quotes
if csv[start_pos..end_pos].contains(',') {
let value = csv[start_pos..end_pos].to_string(); // Only allocate if needed
csv.truncate(start_pos);
csv.push('"');
csv.push_str(&value);
csv.push('"');
}
}
writer.write_next(&mut csv)?;
}
csv.push('\n');
}
+2 -1
View File
@@ -1,6 +1,7 @@
use brk_error::Result;
use brk_types::{Height, Version};
use fjall2::{InnerItem, PartitionHandle};
use fjall3::Item;
pub trait AnyStore: Send + Sync {
fn name(&self) -> &'static str;
@@ -11,6 +12,6 @@ pub trait AnyStore: Send + Sync {
fn export_meta_if_needed(&mut self, height: Height) -> Result<()>;
fn partition(&self) -> &PartitionHandle;
fn take_all_f2(&mut self) -> Vec<InnerItem>;
fn commit(&mut self) -> Result<()>;
fn take_all_f3(&mut self) -> Vec<Item>;
// fn take_all_f3(&mut self) -> Box<dyn Iterator<Item = Item>>;
}
+3 -40
View File
@@ -192,9 +192,9 @@ where
items.into_iter().map(InnerItem::from).collect()
}
// fn take_all_f3(&mut self) -> Box<dyn Iterator<Item = Item>> {
// Box::new([].into_iter())
// }
fn take_all_f3(&mut self) -> Vec<fjall3::Item> {
panic!()
}
fn export_meta_if_needed(&mut self, height: Height) -> Result<()> {
if self.has(height) {
@@ -204,43 +204,6 @@ where
Ok(())
}
fn commit(&mut self) -> Result<()> {
if self.puts.is_empty() && self.dels.is_empty() {
return Ok(());
}
// if self.mode.is_unique_push_only() {
// if !self.dels.is_empty() {
// unreachable!();
// }
// let mut puts = mem::take(&mut self.puts).into_iter().collect::<Vec<_>>();
// puts.sort_unstable_by(|(k1, _), (k2, _)| k1.cmp(k2));
// dbg!(&puts);
// self.partition.ingest(
// puts.into_iter()
// .map(|(k, v)| (ByteView::from(k), ByteView::from(v))),
// )?;
// } else {
let mut items = mem::take(&mut self.puts)
.into_iter()
.map(|(key, value)| Item::Value { key, value })
.chain(
mem::take(&mut self.dels)
.into_iter()
.map(|key| Item::Tomb(key)),
)
.collect::<Vec<_>>();
items.sort_unstable();
// self.keyspace.inner().batch().commit_partition(
// self.partition.inner(),
// items.into_iter().map(InnerItem::from).collect::<Vec<_>>(),
// )?;
// }
Ok(())
}
fn name(&self) -> &'static str {
self.name
}
+35 -84
View File
@@ -4,10 +4,7 @@ use brk_error::Result;
use brk_types::{Height, Version};
use byteview8::ByteView;
use fjall3::{
Database,
Keyspace,
KeyspaceCreateOptions,
// ValueType,
Database, Keyspace, KeyspaceCreateOptions, ValueType,
config::{BloomConstructionPolicy, FilterPolicy, FilterPolicyEntry, PinningPolicy},
};
@@ -22,7 +19,6 @@ use crate::any::AnyStore;
pub struct StoreFjallV3<Key, Value> {
meta: StoreMeta,
name: &'static str,
database: Database,
keyspace: Keyspace,
puts: FxHashMap<Key, Value>,
dels: FxHashSet<Key>,
@@ -67,7 +63,6 @@ where
Ok(Self {
meta,
name: Box::leak(Box::new(name.to_string())),
database: database.clone(),
keyspace,
puts: FxHashMap::default(),
dels: FxHashSet::default(),
@@ -188,37 +183,7 @@ where
panic!()
}
// fn take_all_f3(&mut self) -> Box<dyn Iterator<Item = Item>> {
// Box::new([].into_iter())
// }
fn export_meta_if_needed(&mut self, height: Height) -> Result<()> {
if self.has(height) {
return Ok(());
}
self.meta.export(height)?;
Ok(())
}
fn commit(&mut self) -> Result<()> {
if self.puts.is_empty() && self.dels.is_empty() {
return Ok(());
}
// if self.mode.is_push_only() {
// if !self.dels.is_empty() {
// unreachable!();
// }
// let mut puts = mem::take(&mut self.puts).into_iter().collect::<Vec<_>>();
// puts.sort_unstable_by(|(k1, _), (k2, _)| k1.cmp(k2));
// // dbg!(&puts);
// self.keyspace.ingest(
// puts.into_iter()
// .map(|(k, v)| (ByteView::from(k), ByteView::from(v))),
// )?;
// } else {
let mut batch = self.database.batch();
// let mut batch = self.database.inner().batch();
fn take_all_f3(&mut self) -> Vec<fjall3::Item> {
let mut items = mem::take(&mut self.puts)
.into_iter()
.map(|(key, value)| Item::Value { key, value })
@@ -229,31 +194,17 @@ where
)
.collect::<Vec<_>>();
items.sort_unstable();
items.into_iter().for_each(|item| match item {
Item::Value { key, value } => {
batch.insert(&self.keyspace, ByteView::from(key), ByteView::from(value))
}
Item::Tomb(key) => batch.remove(&self.keyspace, ByteView::from(key)),
});
batch.commit()?;
// }
// batch.ingest(
// items
// .into_iter()
// .map(|i| i.fjalled(&self.keyspace))
// .collect::<Vec<_>>(),
// );
// batch.commit_keyspace(&self.keyspace)?;
// batch.ingest(
// items
// .into_iter()
// .map(|i| i.fjalled(&self.keyspace))
// .collect::<Vec<_>>(),
// );
// batch.commit_keyspace(&self.keyspace)?;
// batch.commit_keyspace(self.keyspace.inner())?;
items
.into_iter()
.map(|v| v.fjalled(&self.keyspace))
.collect()
}
fn export_meta_if_needed(&mut self, height: Height) -> Result<()> {
if self.has(height) {
return Ok(());
}
self.meta.export(height)?;
Ok(())
}
@@ -278,7 +229,7 @@ where
}
}
enum Item<K, V> {
pub enum Item<K, V> {
Value { key: K, value: V },
Tomb(K),
}
@@ -310,28 +261,28 @@ impl<K, V> Item<K, V> {
}
}
// pub fn fjalled(self, keyspace: &Keyspace) -> fjall3::Item
// where
// K: Into<ByteView>,
// V: Into<ByteView>,
// {
// let keyspace_id = keyspace.id;
// // let keyspace_id = keyspace.inner().id;
// match self {
// Item::Value { key, value } => fjall3::Item {
// keyspace_id,
// key: key.into().into(),
// value: value.into().into(),
// value_type: ValueType::Value,
// },
// Item::Tomb(key) => fjall3::Item {
// keyspace_id,
// key: key.into().into(),
// value: [].into(),
// value_type: ValueType::Tombstone,
// },
// }
// }
pub fn fjalled(self, keyspace: &Keyspace) -> fjall3::Item
where
K: Into<ByteView>,
V: Into<ByteView>,
{
let keyspace_id = keyspace.id;
// let keyspace_id = keyspace.inner().id;
match self {
Item::Value { key, value } => fjall3::Item {
keyspace_id,
key: key.into().into(),
value: value.into().into(),
value_type: ValueType::Value,
},
Item::Tomb(key) => fjall3::Item {
keyspace_id,
key: key.into().into(),
value: [].into(),
value_type: ValueType::Tombstone,
},
}
}
}
#[derive(Debug, Clone, Copy)]
+36 -36
View File
@@ -5,8 +5,8 @@ pub use brk_types::TreeNode;
#[cfg(feature = "derive")]
pub use brk_traversable_derive::Traversable;
use vecdb::{
AnyVec, AnyWritableVec, CompressedVec, ComputedVec, EagerVec, LazyVecFrom1, LazyVecFrom2,
LazyVecFrom3, RawVec, StoredCompressed, StoredIndex, StoredRaw, StoredVec,
AnyVec, AnyWritableVec, Compressable, CompressedVec, ComputedVec, EagerVec, Formattable,
LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, RawVec, StoredVec, VecIndex, VecValue,
};
pub trait Traversable {
@@ -16,8 +16,8 @@ pub trait Traversable {
impl<I, T> Traversable for RawVec<I, T>
where
I: StoredIndex,
T: StoredRaw,
I: VecIndex,
T: VecValue + Formattable,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -30,8 +30,8 @@ where
impl<I, T> Traversable for CompressedVec<I, T>
where
I: StoredIndex,
T: StoredCompressed,
I: VecIndex,
T: Compressable + Formattable,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -44,8 +44,8 @@ where
impl<I, T> Traversable for StoredVec<I, T>
where
I: StoredIndex,
T: StoredCompressed,
I: VecIndex,
T: Compressable + Formattable,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -58,8 +58,8 @@ where
impl<I, T> Traversable for EagerVec<I, T>
where
I: StoredIndex,
T: StoredCompressed,
I: VecIndex,
T: Compressable + Formattable,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -72,10 +72,10 @@ where
impl<I, T, S1I, S1T> Traversable for LazyVecFrom1<I, T, S1I, S1T>
where
I: StoredIndex,
T: StoredRaw,
S1I: StoredIndex,
S1T: StoredRaw,
I: VecIndex,
T: VecValue + Formattable,
S1I: VecIndex,
S1T: VecValue,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -88,12 +88,12 @@ where
impl<I, T, S1I, S1T, S2I, S2T> Traversable for LazyVecFrom2<I, T, S1I, S1T, S2I, S2T>
where
I: StoredIndex,
T: StoredRaw,
S1I: StoredIndex,
S1T: StoredRaw,
S2I: StoredIndex,
S2T: StoredRaw,
I: VecIndex,
T: VecValue + Formattable,
S1I: VecIndex,
S1T: VecValue,
S2I: VecIndex,
S2T: VecValue,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -107,14 +107,14 @@ where
impl<I, T, S1I, S1T, S2I, S2T, S3I, S3T> Traversable
for LazyVecFrom3<I, T, S1I, S1T, S2I, S2T, S3I, S3T>
where
I: StoredIndex,
T: StoredRaw,
S1I: StoredIndex,
S1T: StoredRaw,
S2I: StoredIndex,
S2T: StoredRaw,
S3I: StoredIndex,
S3T: StoredRaw,
I: VecIndex,
T: VecValue + Formattable,
S1I: VecIndex,
S1T: VecValue,
S2I: VecIndex,
S2T: VecValue,
S3I: VecIndex,
S3T: VecValue,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
@@ -128,14 +128,14 @@ where
impl<I, T, S1I, S1T, S2I, S2T, S3I, S3T> Traversable
for ComputedVec<I, T, S1I, S1T, S2I, S2T, S3I, S3T>
where
I: StoredIndex,
T: StoredCompressed,
S1I: StoredIndex,
S1T: StoredCompressed,
S2I: StoredIndex,
S2T: StoredCompressed,
S3I: StoredIndex,
S3T: StoredCompressed,
I: VecIndex,
T: Compressable + Formattable,
S1I: VecIndex,
S1T: Compressable,
S2I: VecIndex,
S2T: Compressable,
S3I: VecIndex,
S3T: Compressable,
{
fn iter_any_writable(&self) -> impl Iterator<Item = &dyn AnyWritableVec> {
std::iter::once(self as &dyn AnyWritableVec)
+1 -1
View File
@@ -244,7 +244,7 @@ Storage types provide space optimization:
**Financial Types**: Multi-denomination OHLC support with automatic conversions \
**Address System**: Complete Bitcoin script type classification with 280 enum variants \
**Time Indexing**: Hierarchical calendar system from daily to decade-level granularity \
**Storage Integration**: `vecdb::StoredCompressed` traits for efficient database operations \
**Storage Integration**: `vecdb::Compressable` traits for efficient database operations \
**Architecture**: Type-driven design prioritizing memory efficiency and domain correctness
---
-8
View File
@@ -1,5 +1,3 @@
use std::fmt;
use bitcoin::ScriptBuf;
use brk_error::Error;
@@ -39,12 +37,6 @@ impl AddressBytes {
}
}
impl fmt::Display for AddressBytes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&super::Address::try_from(self).unwrap().to_string())
}
}
impl TryFrom<&ScriptBuf> for AddressBytes {
type Error = Error;
fn try_from(script: &ScriptBuf) -> Result<Self, Self::Error> {
+8
View File
@@ -1,4 +1,5 @@
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{EmptyAddressIndex, LoadedAddressIndex, TypeIndex};
@@ -48,6 +49,13 @@ impl std::fmt::Display for AnyAddressIndex {
}
}
impl Formattable for AnyAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum AnyAddressDataIndexEnum {
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::Serialize;
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{Sats, StoredF64};
@@ -19,7 +19,7 @@ use super::{Sats, StoredF64};
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct Bitcoin(f64);
@@ -150,3 +150,10 @@ impl std::fmt::Display for Bitcoin {
f.write_str(str)
}
}
impl Formattable for Bitcoin {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,11 +1,11 @@
use std::ops::Add;
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, StoredCompressed,
Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, Compressable,
)]
pub struct BlkPosition(u64);
@@ -37,3 +37,10 @@ impl std::fmt::Display for BlkPosition {
f.write_str(str)
}
}
impl Formattable for BlkPosition {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -5,6 +5,7 @@ use brk_error::Error;
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::{Serialize, Serializer};
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
/// Block hash
@@ -70,3 +71,10 @@ impl Serialize for BlockHash {
serializer.serialize_str(&self.to_string())
}
}
impl Formattable for BlockHash {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,7 +1,7 @@
use std::ops::{Add, Div, Mul};
use serde::Serialize;
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::Dollars;
@@ -20,7 +20,7 @@ use super::Dollars;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct Cents(i64);
@@ -183,3 +183,10 @@ impl std::fmt::Display for Cents {
f.write_str(str)
}
}
impl Formattable for Cents {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+15 -8
View File
@@ -1,6 +1,6 @@
use jiff::{Span, Zoned, civil::Date as Date_, tz::TimeZone};
use serde::{Serialize, Serializer};
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::ONE_DAY_IN_SEC_F64;
@@ -19,7 +19,7 @@ use super::{DateIndex, Timestamp};
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct Date(u32);
@@ -121,6 +121,15 @@ impl From<DateIndex> for Date {
}
}
impl Serialize for Date {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
}
}
impl std::fmt::Display for Date {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buf = itoa::Buffer::new();
@@ -144,11 +153,9 @@ impl std::fmt::Display for Date {
}
}
impl Serialize for Date {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
impl Formattable for Date {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+27 -20
View File
@@ -3,7 +3,7 @@ use std::ops::{Add, Rem};
use brk_error::Error;
use jiff::Span;
use serde::Serialize;
use vecdb::{CheckedSub, FromCoarserIndex, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, FromCoarserIndex, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, WeekIndex, YearIndex};
@@ -24,7 +24,7 @@ use super::Date;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct DateIndex(u16);
@@ -98,24 +98,6 @@ impl Rem<usize> for DateIndex {
}
}
impl std::fmt::Display for DateIndex {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buf = itoa::Buffer::new();
let str = buf.format(self.0);
f.write_str(str)
}
}
impl PrintableIndex for DateIndex {
fn to_string() -> &'static str {
"dateindex"
}
fn to_possible_strings() -> &'static [&'static str] {
&["d", "date", "dateindex"]
}
}
impl FromCoarserIndex<WeekIndex> for DateIndex {
fn min_from(coarser: WeekIndex) -> usize {
let coarser = usize::from(coarser);
@@ -247,3 +229,28 @@ impl FromCoarserIndex<DecadeIndex> for DateIndex {
.into()
}
}
impl PrintableIndex for DateIndex {
fn to_string() -> &'static str {
"dateindex"
}
fn to_possible_strings() -> &'static [&'static str] {
&["d", "date", "dateindex"]
}
}
impl std::fmt::Display for DateIndex {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut buf = itoa::Buffer::new();
let str = buf.format(self.0);
f.write_str(str)
}
}
impl Formattable for DateIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{Date, DateIndex, YearIndex};
@@ -24,7 +24,7 @@ use super::{Date, DateIndex, YearIndex};
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct DecadeIndex(u16);
@@ -138,3 +138,10 @@ impl std::fmt::Display for DecadeIndex {
f.write_str(str)
}
}
impl Formattable for DecadeIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::Height;
@@ -26,7 +26,7 @@ pub const BLOCKS_PER_DIFF_EPOCHS: u32 = 2016;
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct DifficultyEpoch(u16);
@@ -110,3 +110,10 @@ impl std::fmt::Display for DifficultyEpoch {
f.write_str(str)
}
}
impl Formattable for DifficultyEpoch {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -8,7 +8,7 @@ use std::{
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{Low, Open};
@@ -27,7 +27,7 @@ use super::{Bitcoin, Cents, Close, High, Sats, StoredF32, StoredF64};
KnownLayout,
Serialize,
Deserialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct Dollars(f64);
@@ -408,3 +408,10 @@ impl std::fmt::Display for Dollars {
f.write_str(str)
}
}
impl Formattable for Dollars {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -1,4 +1,5 @@
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{LoadedAddressData, Sats};
@@ -46,3 +47,10 @@ impl std::fmt::Display for EmptyAddressData {
)
}
}
impl Formattable for EmptyAddressData {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -22,7 +22,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct EmptyAddressIndex(TypeIndex);
@@ -81,3 +81,10 @@ impl std::fmt::Display for EmptyAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for EmptyAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct EmptyOutputIndex(TypeIndex);
impl From<TypeIndex> for EmptyOutputIndex {
@@ -78,3 +78,10 @@ impl std::fmt::Display for EmptyOutputIndex {
self.0.fmt(f)
}
}
impl Formattable for EmptyOutputIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,13 +4,13 @@ use std::{
};
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{Sats, StoredU64};
#[derive(
Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, StoredCompressed,
Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, Compressable,
)]
pub struct FeeRate(f64);
@@ -102,3 +102,10 @@ impl std::fmt::Display for FeeRate {
f.write_str(str)
}
}
impl Formattable for FeeRate {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::Height;
@@ -26,7 +26,7 @@ pub const BLOCKS_PER_HALVING: u32 = 210_000;
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct HalvingEpoch(u16);
@@ -116,3 +116,10 @@ impl std::fmt::Display for HalvingEpoch {
f.write_str(str)
}
}
impl Formattable for HalvingEpoch {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -7,7 +7,7 @@ use byteview::ByteView;
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, Stamp, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex, Stamp};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{BLOCKS_PER_DIFF_EPOCHS, BLOCKS_PER_HALVING, copy_first_4bytes};
@@ -31,7 +31,7 @@ use super::StoredU64;
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
JsonSchema,
Hash,
)]
@@ -278,3 +278,10 @@ impl std::fmt::Display for Height {
f.write_str(str)
}
}
impl Formattable for Height {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8 -1
View File
@@ -1,6 +1,6 @@
use brk_error::{Error, Result};
use serde::Serialize;
use vecdb::CheckedSub;
use vecdb::{CheckedSub, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{Bitcoin, Dollars, EmptyAddressData, Sats};
@@ -139,3 +139,10 @@ impl std::fmt::Display for LoadedAddressData {
)
}
}
impl Formattable for LoadedAddressData {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -22,7 +22,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct LoadedAddressIndex(TypeIndex);
@@ -77,3 +77,10 @@ impl std::fmt::Display for LoadedAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for LoadedAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{Date, DateIndex, YearIndex};
@@ -24,7 +24,7 @@ use super::{Date, DateIndex, YearIndex};
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct MonthIndex(u16);
@@ -129,3 +129,10 @@ impl std::fmt::Display for MonthIndex {
f.write_str(str)
}
}
impl Formattable for MonthIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+78 -16
View File
@@ -1,11 +1,12 @@
use std::{
fmt::Display,
iter::Sum,
ops::{Add, AddAssign, Div},
};
use derive_deref::{Deref, DerefMut};
use serde::{Serialize, Serializer, ser::SerializeTuple};
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::StoredF64;
@@ -59,7 +60,7 @@ impl Serialize for OHLCCents {
}
}
impl std::fmt::Display for OHLCCents {
impl Display for OHLCCents {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
@@ -69,6 +70,13 @@ impl std::fmt::Display for OHLCCents {
}
}
impl Formattable for OHLCCents {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)]
#[repr(C)]
pub struct OHLCDollars {
@@ -135,7 +143,7 @@ impl From<&OHLCCents> for OHLCDollars {
}
}
impl std::fmt::Display for OHLCDollars {
impl Display for OHLCDollars {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
@@ -145,6 +153,13 @@ impl std::fmt::Display for OHLCDollars {
}
}
impl Formattable for OHLCDollars {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)]
#[repr(C)]
pub struct OHLCSats {
@@ -192,7 +207,7 @@ impl From<Close<Sats>> for OHLCSats {
}
}
impl std::fmt::Display for OHLCSats {
impl Display for OHLCSats {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
@@ -202,6 +217,13 @@ impl std::fmt::Display for OHLCSats {
}
}
impl Formattable for OHLCSats {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
#[derive(
Debug,
Default,
@@ -218,7 +240,7 @@ impl std::fmt::Display for OHLCSats {
Deref,
DerefMut,
Serialize,
StoredCompressed,
Compressable,
)]
#[repr(transparent)]
pub struct Open<T>(T);
@@ -315,15 +337,25 @@ where
}
}
impl<T> std::fmt::Display for Open<T>
impl<T> Display for Open<T>
where
T: std::fmt::Display,
T: Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl<T> Formattable for Open<T>
where
T: Display,
{
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
#[derive(
Debug,
Default,
@@ -340,7 +372,7 @@ where
Deref,
DerefMut,
Serialize,
StoredCompressed,
Compressable,
)]
#[repr(transparent)]
pub struct High<T>(T);
@@ -437,15 +469,25 @@ where
}
}
impl<T> std::fmt::Display for High<T>
impl<T> Display for High<T>
where
T: std::fmt::Display,
T: Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl<T> Formattable for High<T>
where
T: Display,
{
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
#[derive(
Debug,
Default,
@@ -462,7 +504,7 @@ where
Deref,
DerefMut,
Serialize,
StoredCompressed,
Compressable,
)]
#[repr(transparent)]
pub struct Low<T>(T);
@@ -559,15 +601,25 @@ where
}
}
impl<T> std::fmt::Display for Low<T>
impl<T> Display for Low<T>
where
T: std::fmt::Display,
T: Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl<T> Formattable for Low<T>
where
T: Display,
{
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
#[derive(
Debug,
Default,
@@ -584,7 +636,7 @@ where
Deref,
DerefMut,
Serialize,
StoredCompressed,
Compressable,
)]
#[repr(transparent)]
pub struct Close<T>(T);
@@ -704,11 +756,21 @@ impl Sum for Close<Dollars> {
}
}
impl<T> std::fmt::Display for Close<T>
impl<T> Display for Close<T>
where
T: std::fmt::Display,
T: Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl<T> Formattable for Close<T>
where
T: Display,
{
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct OpReturnIndex(TypeIndex);
@@ -78,3 +78,10 @@ impl std::fmt::Display for OpReturnIndex {
self.0.fmt(f)
}
}
impl Formattable for OpReturnIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,6 +1,6 @@
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{TxIndex, Vout};
@@ -21,7 +21,7 @@ use crate::{TxIndex, Vout};
Serialize,
JsonSchema,
Hash,
StoredCompressed,
Compressable,
)]
pub struct OutPoint(u64);
@@ -52,3 +52,10 @@ impl std::fmt::Display for OutPoint {
write!(f, "txindex: {}, vout: {}", self.txindex(), self.vout())
}
}
impl Formattable for OutPoint {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+8
View File
@@ -3,6 +3,7 @@ use brk_error::Error;
use schemars::JsonSchema;
use serde::Serialize;
use strum::Display;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
@@ -914,3 +915,10 @@ impl From<&[u8]> for OutputType {
Self::read_from_bytes(value).unwrap()
}
}
impl Formattable for OutputType {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2AAddressIndex(TypeIndex);
impl From<TypeIndex> for P2AAddressIndex {
@@ -94,3 +94,10 @@ impl std::fmt::Display for P2AAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2AAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x2;
@@ -42,3 +43,10 @@ impl fmt::Display for P2ABytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2ABytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2MSOutputIndex(TypeIndex);
impl From<TypeIndex> for P2MSOutputIndex {
@@ -77,3 +77,10 @@ impl std::fmt::Display for P2MSOutputIndex {
self.0.fmt(f)
}
}
impl Formattable for P2MSOutputIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2PK33AddressIndex(TypeIndex);
impl From<TypeIndex> for P2PK33AddressIndex {
@@ -95,3 +95,10 @@ impl std::fmt::Display for P2PK33AddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2PK33AddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x33;
@@ -42,3 +43,10 @@ impl fmt::Display for P2PK33Bytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2PK33Bytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2PK65AddressIndex(TypeIndex);
impl From<TypeIndex> for P2PK65AddressIndex {
@@ -94,3 +94,10 @@ impl std::fmt::Display for P2PK65AddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2PK65AddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x65;
@@ -42,3 +43,10 @@ impl fmt::Display for P2PK65Bytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2PK65Bytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2PKHAddressIndex(TypeIndex);
impl From<TypeIndex> for P2PKHAddressIndex {
@@ -95,3 +95,10 @@ impl std::fmt::Display for P2PKHAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2PKHAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x20;
@@ -42,3 +43,10 @@ impl fmt::Display for P2PKHBytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2PKHBytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2SHAddressIndex(TypeIndex);
impl From<TypeIndex> for P2SHAddressIndex {
@@ -101,3 +101,10 @@ impl std::fmt::Display for P2SHAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2SHAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x20;
@@ -42,3 +43,10 @@ impl fmt::Display for P2SHBytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2SHBytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2TRAddressIndex(TypeIndex);
impl From<TypeIndex> for P2TRAddressIndex {
@@ -95,3 +95,10 @@ impl std::fmt::Display for P2TRAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2TRAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x32;
@@ -42,3 +43,10 @@ impl fmt::Display for P2TRBytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2TRBytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2WPKHAddressIndex(TypeIndex);
impl From<TypeIndex> for P2WPKHAddressIndex {
@@ -95,3 +95,10 @@ impl std::fmt::Display for P2WPKHAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2WPKHAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x20;
@@ -42,3 +43,10 @@ impl fmt::Display for P2WPKHBytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2WPKHBytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct P2WSHAddressIndex(TypeIndex);
impl From<TypeIndex> for P2WSHAddressIndex {
@@ -95,3 +95,10 @@ impl std::fmt::Display for P2WSHAddressIndex {
self.0.fmt(f)
}
}
impl Formattable for P2WSHAddressIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -2,6 +2,7 @@ use std::fmt;
use derive_deref::Deref;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::U8x32;
@@ -42,3 +43,10 @@ impl fmt::Display for P2WSHBytes {
write!(f, "{:?}", self.0)
}
}
impl Formattable for P2WSHBytes {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+8
View File
@@ -1,6 +1,7 @@
use num_enum::{FromPrimitive, IntoPrimitive};
use serde::{Deserialize, Serialize};
use strum::Display;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
// Created from the list in `pools.rs`
@@ -286,3 +287,10 @@ pub enum PoolId {
Dummy254,
Dummy255,
}
impl Formattable for PoolId {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::MonthIndex;
@@ -24,7 +24,7 @@ use super::MonthIndex;
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct QuarterIndex(u16);
@@ -115,3 +115,10 @@ impl std::fmt::Display for QuarterIndex {
f.write_str(str)
}
}
impl Formattable for QuarterIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,7 +1,7 @@
use bitcoin::{absolute::LockTime, locktime::absolute::LOCK_TIME_THRESHOLD};
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
/// Transaction locktime
@@ -14,7 +14,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
KnownLayout,
FromBytes,
Serialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct RawLockTime(u32);
@@ -48,3 +48,10 @@ impl std::fmt::Display for RawLockTime {
f.write_str(&lock_time.to_string())
}
}
impl Formattable for RawLockTime {
#[inline(always)]
fn may_need_escaping() -> bool {
true
}
}
+9 -2
View File
@@ -7,7 +7,7 @@ use bitcoin::Amount;
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::StoredF64;
@@ -31,7 +31,7 @@ use super::{Bitcoin, Cents, Dollars, Height};
KnownLayout,
Serialize,
Deserialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct Sats(u64);
@@ -284,3 +284,10 @@ impl std::fmt::Display for Sats {
f.write_str(str)
}
}
impl Formattable for Sats {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::MonthIndex;
@@ -24,7 +24,7 @@ use super::MonthIndex;
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct SemesterIndex(u16);
@@ -115,3 +115,10 @@ impl std::fmt::Display for SemesterIndex {
f.write_str(str)
}
}
impl Formattable for SemesterIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,6 +1,6 @@
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{PrintableIndex, StoredCompressed};
use vecdb::{Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
@@ -18,7 +18,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredBool(u16);
@@ -68,3 +68,10 @@ impl std::fmt::Display for StoredBool {
}
}
}
impl Formattable for StoredBool {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -8,7 +8,7 @@ use std::{
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{Close, StoredU32};
@@ -26,7 +26,7 @@ use super::{Dollars, StoredF64};
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredF32(f32);
@@ -236,3 +236,10 @@ impl std::fmt::Display for StoredF32 {
f.write_str(str)
}
}
impl Formattable for StoredF32 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -7,7 +7,7 @@ use std::{
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{Bitcoin, Dollars};
@@ -23,7 +23,7 @@ use crate::{Bitcoin, Dollars};
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredF64(f64);
@@ -209,3 +209,10 @@ impl std::fmt::Display for StoredF64 {
f.write_str(str)
}
}
impl Formattable for StoredF64 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
@@ -20,7 +20,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredI16(i16);
@@ -116,3 +116,10 @@ impl std::fmt::Display for StoredI16 {
f.write_str(str)
}
}
impl Formattable for StoredI16 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{
@@ -26,7 +26,7 @@ use super::{
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredU16(u16);
@@ -207,3 +207,10 @@ impl std::fmt::Display for StoredU16 {
f.write_str(str)
}
}
impl Formattable for StoredU16 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div, Mul};
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{
@@ -26,7 +26,7 @@ use super::{
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredU32(u32);
@@ -238,3 +238,10 @@ impl std::fmt::Display for StoredU32 {
f.write_str(str)
}
}
impl Formattable for StoredU32 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{
@@ -27,7 +27,7 @@ use super::{
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct StoredU64(u64);
@@ -260,3 +260,10 @@ impl std::fmt::Display for StoredU64 {
f.write_str(str)
}
}
impl Formattable for StoredU64 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8 -1
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
use derive_deref::Deref;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex};
use vecdb::{CheckedSub, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
pub type StoredPhantom = StoredU8;
@@ -121,3 +121,10 @@ impl std::fmt::Display for StoredU8 {
f.write_str(str)
}
}
impl Formattable for StoredU8 {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use derive_deref::Deref;
use jiff::{civil::date, tz::TimeZone};
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::Date;
@@ -24,7 +24,7 @@ use super::Date;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct Timestamp(u32);
@@ -175,3 +175,10 @@ impl std::fmt::Display for Timestamp {
f.write_str(str)
}
}
impl Formattable for Timestamp {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -4,6 +4,7 @@ use bitcoin::hashes::Hash;
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::{Serialize, Serializer};
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
/// Transaction ID (hash)
@@ -77,3 +78,10 @@ impl Serialize for Txid {
serializer.serialize_str(&self.to_string())
}
}
impl Formattable for Txid {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use byteview::ByteView;
use derive_deref::{Deref, DerefMut};
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::copy_first_4bytes;
@@ -27,7 +27,7 @@ use super::StoredU32;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
JsonSchema,
Hash,
)]
@@ -164,3 +164,10 @@ impl std::fmt::Display for TxIndex {
f.write_str(str)
}
}
impl Formattable for TxIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign};
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::Vin;
@@ -23,7 +23,7 @@ use super::Vin;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct TxInIndex(u64);
@@ -123,3 +123,10 @@ impl std::fmt::Display for TxInIndex {
f.write_str(str)
}
}
impl Formattable for TxInIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign};
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::copy_first_8bytes;
@@ -25,7 +25,7 @@ use super::Vout;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct TxOutIndex(u64);
@@ -140,3 +140,10 @@ impl std::fmt::Display for TxOutIndex {
f.write_str(str)
}
}
impl Formattable for TxOutIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -1,7 +1,7 @@
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::StoredU16;
@@ -21,7 +21,7 @@ use super::StoredU16;
KnownLayout,
FromBytes,
Serialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct TxVersion(u16);
@@ -66,3 +66,10 @@ impl std::fmt::Display for TxVersion {
f.write_str(str)
}
}
impl Formattable for TxVersion {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -3,7 +3,7 @@ use std::ops::Add;
use byteview::ByteView;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::copy_first_4bytes;
@@ -24,7 +24,7 @@ use crate::copy_first_4bytes;
KnownLayout,
Serialize,
Deserialize,
StoredCompressed,
Compressable,
JsonSchema,
Hash,
)]
@@ -150,3 +150,10 @@ impl std::fmt::Display for TypeIndex {
f.write_str(str)
}
}
impl Formattable for TypeIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -2,7 +2,7 @@ use std::ops::Add;
use derive_deref::{Deref, DerefMut};
use serde::Serialize;
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::TypeIndex;
@@ -23,7 +23,7 @@ use crate::TypeIndex;
IntoBytes,
KnownLayout,
Serialize,
StoredCompressed,
Compressable,
)]
pub struct UnknownOutputIndex(TypeIndex);
@@ -78,3 +78,10 @@ impl std::fmt::Display for UnknownOutputIndex {
self.0.fmt(f)
}
}
impl Formattable for UnknownOutputIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+8
View File
@@ -1,6 +1,7 @@
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::Formattable;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::copy_first_2bytes;
@@ -105,3 +106,10 @@ impl std::fmt::Display for Vout {
self.0.fmt(f)
}
}
impl Formattable for Vout {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -4,7 +4,7 @@ use std::{
};
use serde::{Deserialize, Serialize};
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
use vecdb::{CheckedSub, Compressable, Formattable, PrintableIndex};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use super::{Date, DateIndex};
@@ -24,7 +24,7 @@ use super::{Date, DateIndex};
Immutable,
IntoBytes,
KnownLayout,
StoredCompressed,
Compressable,
)]
pub struct WeekIndex(u16);
@@ -139,3 +139,10 @@ impl std::fmt::Display for WeekIndex {
f.write_str(str)
}
}
impl Formattable for WeekIndex {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}
+9 -2
View File
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div};
use derive_deref::Deref;
use schemars::JsonSchema;
use serde::Serialize;
use vecdb::StoredCompressed;
use vecdb::{Compressable, Formattable};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[derive(
@@ -20,7 +20,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
KnownLayout,
FromBytes,
Serialize,
StoredCompressed,
Compressable,
JsonSchema,
)]
pub struct Weight(u64);
@@ -94,3 +94,10 @@ impl std::fmt::Display for Weight {
f.write_str(str)
}
}
impl Formattable for Weight {
#[inline(always)]
fn may_need_escaping() -> bool {
false
}
}

Some files were not shown because too many files have changed in this diff Show More