mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 06:01:57 -07:00
global: snap
This commit is contained in:
@@ -4,7 +4,7 @@ use brk_computer::prices::Vecs as PricesVecs;
|
||||
use brk_error::{Error, Result};
|
||||
use brk_indexer::Lengths;
|
||||
use brk_oracle::{
|
||||
Config, HistogramEma, HistogramEmaCompact, HistogramRaw, Oracle, START_HEIGHT_SLOW,
|
||||
Config, HistogramEma, HistogramEmaCompact, HistogramRaw, Oracle,
|
||||
cents_to_bin, sats_to_bin,
|
||||
};
|
||||
use brk_types::{Day1, Dollars, Sats, TxOutIndex};
|
||||
@@ -157,7 +157,7 @@ impl Query {
|
||||
Ok(cents_to_bin(cents.inner() as f64))
|
||||
}
|
||||
|
||||
/// `START_HEIGHT_SLOW <= height < min(spot price len, safe height)` or 404.
|
||||
/// `height < min(spot price len, safe height)` or 404.
|
||||
/// Returns the safe lengths so callers cap reads at the same bound.
|
||||
fn check_histogram_height(&self, height: usize) -> Result<Lengths> {
|
||||
let safe = self.safe_lengths();
|
||||
@@ -169,7 +169,7 @@ impl Query {
|
||||
.height
|
||||
.len()
|
||||
.min(safe.height.to_usize());
|
||||
if height < START_HEIGHT_SLOW || height >= bound {
|
||||
if height >= bound {
|
||||
return Err(Error::NotFound(format!(
|
||||
"oracle histogram unavailable for height {height}"
|
||||
)));
|
||||
@@ -192,8 +192,7 @@ impl Query {
|
||||
.min(safe.height.to_usize());
|
||||
let start = first_height
|
||||
.collect_one(day)
|
||||
.map_or(usize::MAX, |h| h.to_usize())
|
||||
.max(START_HEIGHT_SLOW);
|
||||
.map_or(usize::MAX, |h| h.to_usize());
|
||||
let end = first_height
|
||||
.collect_one(day + 1)
|
||||
.map_or(bound, |h| h.to_usize())
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::Cents;
|
||||
|
||||
/// Aggregation strategy for URPD buckets.
|
||||
/// Options: raw (no aggregation), lin200/lin500/lin1000 (linear $200/$500/$1000),
|
||||
/// log10/log50/log100/log200 (logarithmic with 10/50/100/200 buckets per decade).
|
||||
/// log10/log50/log100/log200/log500/log1000 (logarithmic with 10/50/100/200/500/1000 buckets per decade).
|
||||
#[derive(
|
||||
Debug, Display, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
|
||||
)]
|
||||
@@ -22,6 +22,8 @@ pub enum UrpdAggregation {
|
||||
Log50,
|
||||
Log100,
|
||||
Log200,
|
||||
Log500,
|
||||
Log1000,
|
||||
}
|
||||
|
||||
impl UrpdAggregation {
|
||||
@@ -42,6 +44,8 @@ impl UrpdAggregation {
|
||||
Self::Log50 => Some(50),
|
||||
Self::Log100 => Some(100),
|
||||
Self::Log200 => Some(200),
|
||||
Self::Log500 => Some(500),
|
||||
Self::Log1000 => Some(1000),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -55,7 +59,7 @@ impl UrpdAggregation {
|
||||
let size = self.linear_size_cents().unwrap();
|
||||
(price_cents / size) * size
|
||||
}
|
||||
Self::Log10 | Self::Log50 | Self::Log100 | Self::Log200 => {
|
||||
Self::Log10 | Self::Log50 | Self::Log100 | Self::Log200 | Self::Log500 | Self::Log1000 => {
|
||||
if price_cents == Cents::ZERO {
|
||||
return Cents::ZERO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user