mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
global: one big snapshot
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use color_eyre::eyre::eyre;
|
||||
use brk_error::Error;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -16,7 +16,7 @@ pub enum Format {
|
||||
}
|
||||
|
||||
impl TryFrom<Option<String>> for Format {
|
||||
type Error = color_eyre::Report;
|
||||
type Error = Error;
|
||||
fn try_from(value: Option<String>) -> Result<Self, Self::Error> {
|
||||
if let Some(value) = value {
|
||||
let value = value.to_lowercase();
|
||||
@@ -30,10 +30,10 @@ impl TryFrom<Option<String>> for Format {
|
||||
} else if value == "json" {
|
||||
Ok(Self::JSON)
|
||||
} else {
|
||||
Err(eyre!("Fail"))
|
||||
Err(Error::Str("Fail"))
|
||||
}
|
||||
} else {
|
||||
Err(eyre!("Fail"))
|
||||
Err(Error::Str("Fail"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
use std::fmt::{self, Debug};
|
||||
|
||||
use brk_core::{
|
||||
use brk_error::Error;
|
||||
use brk_structs::{
|
||||
DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height, InputIndex,
|
||||
MonthIndex, OpReturnIndex, OutputIndex, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex,
|
||||
P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex,
|
||||
P2WSHAddressIndex, Printable, QuarterIndex, SemesterIndex, TxIndex, UnknownOutputIndex,
|
||||
WeekIndex, YearIndex,
|
||||
};
|
||||
use color_eyre::eyre::eyre;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, de::Error};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, JsonSchema)]
|
||||
pub enum Index {
|
||||
@@ -146,7 +146,7 @@ impl Index {
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for Index {
|
||||
type Error = color_eyre::Report;
|
||||
type Error = Error;
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
Ok(match value.to_lowercase().as_str() {
|
||||
v if (Self::DateIndex).possible_values().contains(&v) => Self::DateIndex,
|
||||
@@ -186,7 +186,7 @@ impl TryFrom<&str> for Index {
|
||||
v if (Self::UnknownOutputIndex).possible_values().contains(&v) => {
|
||||
Self::UnknownOutputIndex
|
||||
}
|
||||
_ => return Err(eyre!("Bad index")),
|
||||
_ => return Err(Error::Str("Bad index")),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ impl<'de> Deserialize<'de> for Index {
|
||||
// dbg!(index);
|
||||
Ok(index)
|
||||
} else {
|
||||
Err(Error::custom("Bad index"))
|
||||
Err(serde::de::Error::custom("Bad index"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use brk_computer::Computer;
|
||||
use brk_core::{Height, Result};
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vecs::{AnyCollectableVec, AnyStampedVec};
|
||||
use brk_structs::Height;
|
||||
use brk_vecs::{AnyCollectableVec, AnyStoredVec};
|
||||
use tabled::settings::Style;
|
||||
|
||||
mod deser;
|
||||
@@ -88,7 +89,7 @@ impl<'a> Interface<'a> {
|
||||
&self,
|
||||
vecs: Vec<(String, &&dyn AnyCollectableVec)>,
|
||||
params: &ParamsOpt,
|
||||
) -> color_eyre::Result<Output> {
|
||||
) -> Result<Output> {
|
||||
let from = params.from().map(|from| {
|
||||
vecs.iter()
|
||||
.map(|(_, v)| v.i64_to_usize(from))
|
||||
@@ -106,7 +107,7 @@ impl<'a> Interface<'a> {
|
||||
let mut values = vecs
|
||||
.iter()
|
||||
.map(|(_, vec)| -> Result<Vec<serde_json::Value>> {
|
||||
vec.collect_range_serde_json(from, to)
|
||||
Ok(vec.collect_range_serde_json(from, to)?)
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
@@ -179,7 +180,7 @@ impl<'a> Interface<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn search_and_format(&self, params: Params) -> color_eyre::Result<Output> {
|
||||
pub fn search_and_format(&self, params: Params) -> Result<Output> {
|
||||
self.format(self.search(¶ms), ¶ms.rest)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,7 @@ impl<'a> Vecs<'a> {
|
||||
.into_iter()
|
||||
.for_each(|vec| this.insert(vec));
|
||||
|
||||
computer
|
||||
.vecs
|
||||
.vecs()
|
||||
.into_iter()
|
||||
.for_each(|vec| this.insert(vec));
|
||||
computer.vecs().into_iter().for_each(|vec| this.insert(vec));
|
||||
|
||||
let mut ids = this.id_to_index_to_vec.keys().cloned().collect::<Vec<_>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user