struct_iterable: removed, seems not needed anymore

This commit is contained in:
nym21
2025-02-12 00:06:46 +01:00
parent 385b881068
commit eaf76e27f5
20 changed files with 64 additions and 571 deletions

View File

@@ -1,13 +0,0 @@
use axum::{
extract::State,
response::{IntoResponse, Response},
};
use serde_json::Value;
use crate::{io::Json, server::AppState};
pub async fn last_values_handler(State(app_state): State<AppState>) -> Response {
let values = Json::import::<Value>(&app_state.config.path_datasets_last_values()).unwrap();
let values = axum::Json(values);
values.into_response()
}

View File

@@ -1,6 +1,6 @@
use std::fmt::{self, Debug};
use computer::Date;
use computer::Dateindex;
use indexer::{
Addressindex, Height, P2PK33index, P2PK65index, P2PKHindex, P2SHindex, P2TRindex, P2WPKHindex, P2WSHindex, Txindex,
Txinindex, Txoutindex,
@@ -9,7 +9,7 @@ use indexer::{
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Index {
Addressindex,
Date,
DateIndex,
Height,
P2PK33index,
P2PK65index,
@@ -27,19 +27,19 @@ impl TryFrom<&str> for Index {
type Error = ();
fn try_from(value: &str) -> Result<Self, Self::Error> {
Ok(match value {
"addri" | "addressindex" => Self::Addressindex,
"d" | "date" => Self::Date,
"h" | "height" => Self::Height,
"p2pk33index" => Self::P2PK33index,
"p2pk65index" => Self::P2PK65index,
"p2pkhindex" => Self::P2PKHindex,
"p2shindex" => Self::P2SHindex,
"p2trindex" => Self::P2TRindex,
"p2wpkhindex" => Self::P2WPKHindex,
"p2wshindex" => Self::P2WSHindex,
"txi" | "txindex" => Self::Txindex,
"txini" | "txinindex" => Self::Txinindex,
"txouti" | "txoutindex" => Self::Txoutindex,
"addri" | "addressindex" => Self::Addressindex,
"p2pk33i" | "p2pk33index" => Self::P2PK33index,
"p2pk65i" | "p2pk65index" => Self::P2PK65index,
"p2pkhi" | "p2pkhindex" => Self::P2PKHindex,
"p2shi" | "p2shindex" => Self::P2SHindex,
"p2tri" | "p2trindex" => Self::P2TRindex,
"p2wpkhi" | "p2wpkhindex" => Self::P2WPKHindex,
"p2wshi" | "p2wshindex" => Self::P2WSHindex,
_ => return Err(()),
})
}
@@ -60,9 +60,9 @@ impl IndexTypeToIndexEnum for Addressindex {
Index::Addressindex
}
}
impl IndexTypeToIndexEnum for Date {
impl IndexTypeToIndexEnum for Dateindex {
fn to_enum() -> Index {
Index::Date
Index::DateIndex
}
}
impl IndexTypeToIndexEnum for Height {

View File

@@ -1,32 +0,0 @@
use axum::extract::Query;
use color_eyre::eyre::eyre;
use crate::server::api::handlers::DatasetParams;
pub enum DatasetRange {
All,
Chunk(DatasetRangeChunk),
}
impl TryFrom<&Query<DatasetParams>> for DatasetRange {
type Error = color_eyre::Report;
fn try_from(query: &Query<DatasetParams>) -> Result<Self, Self::Error> {
if let Some(chunk) = query.chunk {
if query.all.is_some() {
Err(eyre!("chunk and all are exclusive"))
} else {
Ok(Self::Chunk(DatasetRangeChunk::Chunk(chunk)))
}
} else if query.all.is_some() {
Ok(Self::All)
} else {
Ok(Self::Chunk(DatasetRangeChunk::Last))
}
}
}
pub enum DatasetRangeChunk {
Chunk(usize),
Last,
}