diff --git a/Cargo.lock b/Cargo.lock index 241126695..67bea0ff5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,9 +146,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-compression" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cf008e5e1a9e9e22a7d3c9a4992e21a350290069e36d8fb72304ed17e8f2d2" +checksum = "59a194f9d963d8099596278594b3107448656ba73831c9d8c783e613ce86da64" dependencies = [ "brotli", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 04398d36a..8999800ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ package.version = "0.0.10" package.repository = "https://github.com/bitcoinresearchkit/brk" [profile.release] -lto = "thin" +lto = "fat" codegen-units = 1 panic = "abort" diff --git a/README.md b/README.md index dcd98806b..53ab3213f 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The Bitcoin Research Kit is a suite of tools designed to parse, index, compute, serve and display data stored on a Bitcoin Core node. -In other words it's an alternative to [Glassnode](https://glassnode.com), [mempool.space](https://mempool.space/) and [electrs](https://github.com/romanz/electrs) all in one package with a particular focus on the self-hosting experience. +In other words it's an alternative to [Glassnode](https://glassnode.com), [mempool.space](https://mempool.space/) and [esplora](https://github.com/Blockstream/electrs)/[electrs](https://github.com/romanz/esplora) all in one package with a particular focus on the self-hosting experience. The toolkit can be used in various ways to accommodate as many needs as possible. diff --git a/crates/brk_core/src/structs/ohlc.rs b/crates/brk_core/src/structs/ohlc.rs index 5bf830780..7e780c2da 100644 --- a/crates/brk_core/src/structs/ohlc.rs +++ b/crates/brk_core/src/structs/ohlc.rs @@ -1,7 +1,7 @@ use std::ops::{Add, Div}; use derive_deref::Deref; -use serde::Serialize; +use serde::{Serialize, Serializer, ser::SerializeTuple}; use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; use super::{Cents, Dollars, Sats}; @@ -37,7 +37,7 @@ impl From> for OHLCCents { } } -#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)] +#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] #[repr(C)] pub struct OHLCDollars { pub open: Open, @@ -46,6 +46,20 @@ pub struct OHLCDollars { pub close: Close, } +impl Serialize for OHLCDollars { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut tup = serializer.serialize_tuple(4)?; + tup.serialize_element(&self.open)?; + tup.serialize_element(&self.high)?; + tup.serialize_element(&self.low)?; + tup.serialize_element(&self.close)?; + tup.end() + } +} + impl From<(Open, High, Low, Close)> for OHLCDollars { fn from(value: (Open, High, Low, Close)) -> Self { Self { diff --git a/crates/brk_server/src/api/query/dts.rs b/crates/brk_server/src/api/query/dts.rs index b0e9dd94a..868ecb389 100644 --- a/crates/brk_server/src/api/query/dts.rs +++ b/crates/brk_server/src/api/query/dts.rs @@ -5,7 +5,6 @@ use brk_query::{Index, Query}; use crate::Website; const SCRIPTS: &str = "scripts"; -const TPYES: &str = "types"; #[allow(clippy::upper_case_acronyms)] pub trait DTS { @@ -24,23 +23,26 @@ impl DTS for Query<'static> { return Ok(()); } - let path = path.join(SCRIPTS).join(TPYES); + let path = path.join(SCRIPTS); fs::create_dir_all(&path)?; - let path = path.join(Path::new("vecid-to-indexes.d.ts")); + let path = path.join(Path::new("vecid-to-indexes.js")); let indexes = Index::all(); let mut contents = indexes .iter() .enumerate() - .map(|(i_of_i, i)| format!("type {} = {};", i, i_of_i)) + .map(|(i_of_i, i)| { + // let lowered = i.to_string().to_lowercase(); + format!("const {i} = {i_of_i};\n/** @typedef {{typeof {i}}} {i} */",) + }) .collect::>() .join("\n"); contents += &format!( - "\n\nexport type Index = {};", + "\n\n/** @typedef {{{}}} Index */", indexes .iter() .map(|i| i.to_string()) @@ -48,7 +50,7 @@ impl DTS for Query<'static> { .join(" | ") ); - contents += "\n\nexport interface VecIdToIndexes {\n"; + contents += "\n\nexport const VecIdToIndexes = {\n"; self.vecid_to_index_to_vec .iter() @@ -60,7 +62,7 @@ impl DTS for Query<'static> { .join(", "); contents += &format!( - " {}: [{indexes}]\n", + " {}: [{indexes}],\n", if id.contains("-") { format!("\"{id}\"") } else { @@ -71,7 +73,8 @@ impl DTS for Query<'static> { contents.push('}'); - contents += "\n\nexport type VecId = keyof VecIdToIndexes;"; + contents += "\n/** @typedef {typeof VecIdToIndexes} VecIdToIndexes */"; + contents += "\n/** @typedef {keyof VecIdToIndexes} VecId */\n"; fs::write(path, contents) } diff --git a/websites/kibo.money/packages/lightweight-charts/types.d.ts b/websites/kibo.money/packages/lightweight-charts/types.d.ts index 458aaeb74..015e59f26 100644 --- a/websites/kibo.money/packages/lightweight-charts/types.d.ts +++ b/websites/kibo.money/packages/lightweight-charts/types.d.ts @@ -7,12 +7,10 @@ import { LineStyleOptions, SeriesOptionsCommon, Time, - CandlestickData, ISeriesApi, BaselineData, -} from "./v5.0.4/types"; -import { Color, Valued, ValuedCandlestickData } from "../../scripts/types/self"; -import { VecId, VecIdToIndexes } from "../../scripts/types/vecid-to-indexes"; +} from "./v5.0.5/types"; +import { VecId } from "../../scripts/vecid-to-indexes"; interface BaseSeriesBlueprint { title: string; @@ -28,7 +26,7 @@ interface CandlestickSeriesBlueprint extends BaseSeriesBlueprint { type: "Candlestick"; color?: Color; options?: DeepPartial; - data?: Accessor<(CandlestickData