mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-10 06:53:33 -07:00
global: serialization optimizations for faster responses
This commit is contained in:
Generated
+184
-86
@@ -143,9 +143,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.99"
|
||||
version = "1.0.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
|
||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
||||
|
||||
[[package]]
|
||||
name = "append-only-vec"
|
||||
@@ -539,6 +539,7 @@ dependencies = [
|
||||
"brk_logger",
|
||||
"brk_parser",
|
||||
"brk_server",
|
||||
"brk_structs",
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"log",
|
||||
@@ -566,7 +567,6 @@ dependencies = [
|
||||
"brk_structs",
|
||||
"derive_deref",
|
||||
"log",
|
||||
"num_enum",
|
||||
"pco",
|
||||
"rayon",
|
||||
"serde",
|
||||
@@ -636,7 +636,6 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"tabled",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
@@ -1069,7 +1068,9 @@ dependencies = [
|
||||
"jiff",
|
||||
"log",
|
||||
"quick_cache",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sonic-rs",
|
||||
"tokio",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
@@ -1110,10 +1111,14 @@ dependencies = [
|
||||
"brk_error",
|
||||
"byteview",
|
||||
"derive_deref",
|
||||
"itoa",
|
||||
"jiff",
|
||||
"num_enum",
|
||||
"rapidhash",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"strum",
|
||||
"vecdb",
|
||||
"zerocopy",
|
||||
"zerocopy-derive",
|
||||
@@ -1149,12 +1154,6 @@ dependencies = [
|
||||
"allocator-api2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
@@ -1233,9 +1232,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.47"
|
||||
version = "4.5.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
|
||||
checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -1243,9 +1242,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.47"
|
||||
version = "4.5.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
|
||||
checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -1825,6 +1824,18 @@ version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "faststr"
|
||||
version = "0.2.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baec6a0289d7f1fe5665586ef7340af82e3037207bef60f5785e57569776f0c8"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"rkyv",
|
||||
"serde",
|
||||
"simdutf8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "file-id"
|
||||
version = "0.2.3"
|
||||
@@ -2700,6 +2711,26 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "munge"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7feb0b48aa0a25f9fe0899482c6e1379ee7a11b24a53073eacdecb9adb6dc60"
|
||||
dependencies = [
|
||||
"munge_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "munge_macro"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2e3795a5d2da581a8b252fec6022eee01aea10161a4d1bf237d4cbe47f7e988"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nibble_vec"
|
||||
version = "0.1.0"
|
||||
@@ -3370,17 +3401,6 @@ dependencies = [
|
||||
"seize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "papergrid"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6978128c8b51d8f4080631ceb2302ab51e32cc6e8615f735ee2f83fd269ae3f1"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"fnv",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.2"
|
||||
@@ -3637,28 +3657,6 @@ dependencies = [
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
@@ -3668,6 +3666,26 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptr_meta"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90"
|
||||
dependencies = [
|
||||
"ptr_meta_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptr_meta_derive"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick_cache"
|
||||
version = "0.6.16"
|
||||
@@ -3705,6 +3723,15 @@ dependencies = [
|
||||
"nibble_vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rancor"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947"
|
||||
dependencies = [
|
||||
"ptr_meta",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@@ -3890,6 +3917,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rend"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a35e8a6bf28cd121053a66aa2e6a2e3eaffad4a60012179f0e864aa5ffeff215"
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.14"
|
||||
@@ -3904,6 +3937,35 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19f5c3e5da784cd8c69d32cdc84673f3204536ca56e1fa01be31a74b92c932ac"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"hashbrown 0.15.5",
|
||||
"indexmap 2.11.4",
|
||||
"munge",
|
||||
"ptr_meta",
|
||||
"rancor",
|
||||
"rend",
|
||||
"rkyv_derive",
|
||||
"tinyvec",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv_derive"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4270433626cffc9c4c1d3707dd681f2a2718d3d7b09ad754bec137acecda8d22"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rolldown-ariadne"
|
||||
version = "0.5.3"
|
||||
@@ -4092,8 +4154,6 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
||||
[[package]]
|
||||
name = "seqdb"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b31ad41314db97a84d637ce25b5323f46572f0a0e356a789fd1fa3e617c04bd0"
|
||||
dependencies = [
|
||||
"allocative",
|
||||
"libc",
|
||||
@@ -4306,6 +4366,44 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sonic-number"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8a74044c092f4f43ca7a6cfd62854cf9fb5ac8502b131347c990bf22bef1dfe"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sonic-rs"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0275f9f2f07d47556fe60c2759da8bc4be6083b047b491b2d476aa0bfa558eb1"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
"faststr",
|
||||
"itoa",
|
||||
"ref-cast",
|
||||
"ryu",
|
||||
"serde",
|
||||
"simdutf8",
|
||||
"sonic-number",
|
||||
"sonic-simd",
|
||||
"thiserror 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sonic-simd"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b421f7b6aa4a5de8f685aaf398dfaa828346ee639d2b1c1061ab43d40baa6223"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sse-stream"
|
||||
version = "0.2.1"
|
||||
@@ -4349,6 +4447,27 @@ version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sugar_path"
|
||||
version = "1.2.0"
|
||||
@@ -4394,30 +4513,6 @@ dependencies = [
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tabled"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e39a2ee1fbcd360805a771e1b300f78cc88fec7b8d3e2f71cd37bbf23e725c7d"
|
||||
dependencies = [
|
||||
"papergrid",
|
||||
"tabled_derive",
|
||||
"testing_table",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tabled_derive"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ea5d1b13ca6cff1f9231ffd62f15eefd72543dab5e468735f1a456728a02846"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.22.0"
|
||||
@@ -4440,15 +4535,6 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "testing_table"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f8daae29995a24f65619e19d8d31dea5b389f3d853d8bf297bbf607cd0014cc"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.2"
|
||||
@@ -4550,6 +4636,21 @@ dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.47.1"
|
||||
@@ -4952,8 +5053,6 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23"
|
||||
[[package]]
|
||||
name = "vecdb"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe63b28536d63d008e824ff8fd5a66147b97d9cd893d392e19d8450488cfc8b0"
|
||||
dependencies = [
|
||||
"allocative",
|
||||
"ctrlc",
|
||||
@@ -4964,6 +5063,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"sonic-rs",
|
||||
"vecdb_derive",
|
||||
"zerocopy",
|
||||
"zerocopy-derive",
|
||||
@@ -4972,8 +5072,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "vecdb_derive"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19d38e2229203d0a3eda93507f0bf3d1ceb67c85832508d48b0268281cda3f9c"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
|
||||
+3
-2
@@ -71,9 +71,10 @@ serde = "1.0.225"
|
||||
serde_bytes = "0.11.19"
|
||||
serde_derive = "1.0.225"
|
||||
serde_json = { version = "1.0.145", features = ["float_roundtrip"] }
|
||||
sonic-rs = "0.3.0"
|
||||
tokio = { version = "1.47.1", features = ["rt-multi-thread"] }
|
||||
# vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]}
|
||||
vecdb = { version = "0.2.15", features = ["derive"]}
|
||||
vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]}
|
||||
# vecdb = { version = "0.2.15", features = ["derive"]}
|
||||
zerocopy = "0.8.27"
|
||||
zerocopy-derive = "0.8.27"
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@ brk_interface = { workspace = true }
|
||||
brk_logger = { workspace = true }
|
||||
brk_parser = { workspace = true }
|
||||
brk_server = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
vecdb = { workspace = true }
|
||||
clap = { version = "4.5.47", features = ["derive", "string"] }
|
||||
clap = { version = "4.5.48", features = ["derive", "string"] }
|
||||
color-eyre = "0.6.5"
|
||||
log = { workspace = true }
|
||||
minreq = { workspace = true }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{fs, io, path::Path};
|
||||
|
||||
use brk_computer::pools;
|
||||
use brk_interface::{Index, Interface};
|
||||
use brk_server::VERSION;
|
||||
use brk_structs::pools;
|
||||
|
||||
use crate::website::Website;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ brk_parser = { workspace = true }
|
||||
vecdb = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
log = { workspace = true }
|
||||
num_enum = "0.7.4"
|
||||
pco = "0.4.6"
|
||||
rayon = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::{collections::BTreeMap, path::Path, thread};
|
||||
|
||||
use brk_computer::{Computer, pools};
|
||||
use brk_computer::Computer;
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{AddressBytes, OutputIndex, OutputType};
|
||||
use brk_structs::{AddressBytes, OutputIndex, OutputType, pools};
|
||||
use vecdb::{AnyIterableVec, Exit, VecIterator};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
||||
@@ -464,7 +464,7 @@ impl Vecs {
|
||||
indexes_to_block_size: ComputedVecsFromHeight::forced_import(
|
||||
&db,
|
||||
"block_size",
|
||||
Source::Compute,
|
||||
Source::None,
|
||||
version + Version::ZERO,
|
||||
indexes,
|
||||
VecBuilderOptions::default()
|
||||
|
||||
@@ -4,23 +4,15 @@ use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_store::AnyStore;
|
||||
use brk_structs::{AddressBytes, Height, OutputIndex, OutputType};
|
||||
use brk_structs::{AddressBytes, Height, OutputIndex, OutputType, PoolId, Pools, pools};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec,
|
||||
PAGE_SIZE, RawVec, StoredIndex, VecIterator, Version,
|
||||
};
|
||||
|
||||
mod id;
|
||||
mod pool;
|
||||
#[allow(clippy::module_inception)]
|
||||
mod pools;
|
||||
mod vecs;
|
||||
|
||||
pub use id::*;
|
||||
pub use pool::*;
|
||||
pub use pools::*;
|
||||
|
||||
use crate::{
|
||||
chain,
|
||||
indexes::{self, Indexes},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Height, Sats, StoredF32, StoredU16, StoredU32};
|
||||
use brk_structs::{Height, PoolId, Pools, Sats, StoredF32, StoredU16, StoredU32};
|
||||
use vecdb::{AnyCollectableVec, AnyIterableVec, Database, Exit, StoredIndex, VecIterator, Version};
|
||||
|
||||
use crate::{
|
||||
PoolId, Pools, chain,
|
||||
chain,
|
||||
grouped::{
|
||||
ComputedValueVecsFromHeight, ComputedVecsFromDateIndex, ComputedVecsFromHeight, Source,
|
||||
VecBuilderOptions,
|
||||
|
||||
@@ -656,11 +656,11 @@ impl Vecs {
|
||||
// info!("stateful_starting_height = {stateful_starting_height}");
|
||||
|
||||
let starting_height = starting_indexes.height.min(stateful_starting_height);
|
||||
info!("starting_height = {starting_height}");
|
||||
// info!("starting_height = {starting_height}");
|
||||
let last_height = Height::from(indexer.vecs.height_to_blockhash.stamp());
|
||||
info!("last_height = {last_height}");
|
||||
// info!("last_height = {last_height}");
|
||||
if starting_height <= last_height {
|
||||
info!("starting_height = {starting_height}");
|
||||
// info!("starting_height = {starting_height}");
|
||||
|
||||
let starting_height = if starting_height.is_not_zero() {
|
||||
let mut set = [
|
||||
@@ -716,7 +716,7 @@ impl Vecs {
|
||||
} else {
|
||||
Height::ZERO
|
||||
};
|
||||
info!("starting_height = {starting_height}");
|
||||
// info!("starting_height = {starting_height}");
|
||||
|
||||
let starting_height = if starting_height.is_not_zero()
|
||||
&& separate_address_vecs
|
||||
@@ -729,7 +729,7 @@ impl Vecs {
|
||||
Height::ZERO
|
||||
};
|
||||
|
||||
info!("starting_height = {starting_height}");
|
||||
// info!("starting_height = {starting_height}");
|
||||
|
||||
let mut chain_state: Vec<BlockState>;
|
||||
if starting_height.is_not_zero() {
|
||||
|
||||
@@ -48,3 +48,9 @@ impl From<&LoadedAddressData> for SupplyState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SupplyState {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "utxos: {}, value: {}", self.utxos, self.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,4 @@ schemars = "1.0.4"
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde_with = "3.14.0"
|
||||
tabled = "0.20.0"
|
||||
nucleo-matcher = "0.3.1"
|
||||
|
||||
@@ -7,13 +7,13 @@ Unified data query and formatting interface for Bitcoin datasets with intelligen
|
||||
|
||||
## Overview
|
||||
|
||||
This crate provides a high-level interface for querying and formatting data from BRK's indexer and computer components. It offers intelligent vector search with fuzzy matching, parameter validation, range queries, and multi-format output (JSON, CSV, TSV, Markdown) with efficient caching and pagination support.
|
||||
This crate provides a high-level interface for querying and formatting data from BRK's indexer and computer components. It offers intelligent vector search with fuzzy matching, parameter validation, range queries, and multi-format output (JSON, CSV) with efficient caching and pagination support.
|
||||
|
||||
**Key Features:**
|
||||
|
||||
- Unified query interface across indexer and computer data sources
|
||||
- Intelligent search with fuzzy matching and helpful error messages
|
||||
- Multi-format output: JSON, CSV, TSV, Markdown with proper formatting
|
||||
- Multi-format output: JSON, CSV with proper formatting
|
||||
- Range-based data queries with flexible from/to parameters
|
||||
- Comprehensive pagination support for large datasets
|
||||
- Schema validation with JSON Schema generation for API documentation
|
||||
@@ -66,7 +66,7 @@ println!("{}", output);
|
||||
- **`Interface<'a>`**: Main query interface coordinating indexer and computer access
|
||||
- **`Params`**: Query parameters including index, IDs, range, and formatting options
|
||||
- **`Index`**: Enumeration of available data indexes (Height, Date, Address, etc.)
|
||||
- **`Format`**: Output format specification (JSON, CSV, TSV, MD)
|
||||
- **`Format`**: Output format specification (JSON, CSV)
|
||||
- **`Output`**: Formatted query results with multiple value types
|
||||
|
||||
### Key Methods
|
||||
@@ -146,31 +146,6 @@ match interface.search_and_format(params)? {
|
||||
}
|
||||
```
|
||||
|
||||
### Multi-Vector Query with Markdown Table
|
||||
|
||||
```rust
|
||||
use brk_interface::{Interface, Params, Index, Format};
|
||||
|
||||
// Query multiple vectors and format as table
|
||||
let params = Params {
|
||||
index: Index::Height,
|
||||
ids: vec![
|
||||
"height-to-blockhash".to_string(),
|
||||
"height-to-timestamp".to_string(),
|
||||
"height-to-difficulty".to_string()
|
||||
].into(),
|
||||
from: Some(800000),
|
||||
to: Some(800005),
|
||||
format: Some(Format::MD),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
match interface.search_and_format(params)? {
|
||||
Output::MD(table) => println!("{}", table),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
```
|
||||
|
||||
### Intelligent Error Handling
|
||||
|
||||
```rust
|
||||
@@ -219,11 +194,10 @@ The interface acts as a bridge between:
|
||||
- List: Array of values
|
||||
- Matrix: Array of arrays for multi-vector queries
|
||||
|
||||
**Tabular Output (CSV/TSV/MD):**
|
||||
**CSV Output:**
|
||||
|
||||
- Column headers from vector IDs
|
||||
- Row-wise data iteration with proper escaping
|
||||
- Markdown tables use `tabled` crate formatting
|
||||
|
||||
### Caching Strategy
|
||||
|
||||
@@ -247,15 +221,13 @@ Available indexes include:
|
||||
|
||||
- **JSON**: Structured data with nested objects/arrays
|
||||
- **CSV**: Comma-separated values with proper escaping
|
||||
- **TSV**: Tab-separated values for import compatibility
|
||||
- **MD**: Markdown tables for documentation and reports
|
||||
|
||||
## Code Analysis Summary
|
||||
|
||||
**Main Structure**: `Interface` struct coordinating between `Indexer` and `Computer` data sources \
|
||||
**Query System**: Parameter-driven search with `Params` struct supporting range queries and formatting options \
|
||||
**Error Handling**: Intelligent fuzzy matching with cached error messages and helpful suggestions \
|
||||
**Output Formats**: Multi-format support (JSON, CSV, TSV, Markdown) with proper data serialization \
|
||||
**Output Formats**: Multi-format support (JSON, CSV) with proper data serialization \
|
||||
**Caching**: `quick_cache` integration for error messages and expensive operations \
|
||||
**Search Logic**: `nucleo-matcher` fuzzy search for user-friendly vector name resolution \
|
||||
**Architecture**: Abstraction layer providing unified access to heterogeneous Bitcoin data sources
|
||||
|
||||
@@ -1,40 +1,26 @@
|
||||
use brk_error::Error;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Format {
|
||||
#[default]
|
||||
#[serde(alias = "json")]
|
||||
JSON,
|
||||
#[serde(alias = "csv")]
|
||||
CSV,
|
||||
#[serde(alias = "tsv")]
|
||||
TSV,
|
||||
#[serde(alias = "md", alias = "markdown")]
|
||||
MD,
|
||||
}
|
||||
|
||||
impl TryFrom<Option<String>> for Format {
|
||||
type Error = Error;
|
||||
fn try_from(value: Option<String>) -> Result<Self, Self::Error> {
|
||||
impl From<Option<String>> for Format {
|
||||
fn from(value: Option<String>) -> Self {
|
||||
if let Some(value) = value {
|
||||
let value = value.to_lowercase();
|
||||
let value = value.as_str();
|
||||
if value == "md" || value == "markdown" {
|
||||
Ok(Self::MD)
|
||||
} else if value == "csv" {
|
||||
Ok(Self::CSV)
|
||||
} else if value == "tsv" {
|
||||
Ok(Self::TSV)
|
||||
} else if value == "json" {
|
||||
Ok(Self::JSON)
|
||||
} else {
|
||||
Err(Error::Str("Fail"))
|
||||
if value == "csv" {
|
||||
return Self::CSV;
|
||||
}
|
||||
} else {
|
||||
Err(Error::Str("Fail"))
|
||||
}
|
||||
Self::JSON
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use brk_structs::{
|
||||
DateIndex, DecadeIndex, DifficultyEpoch, EmptyAddressIndex, EmptyOutputIndex, HalvingEpoch,
|
||||
Height, InputIndex, LoadedAddressIndex, MonthIndex, OpReturnIndex, OutputIndex,
|
||||
P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex,
|
||||
P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, Printable,
|
||||
P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, PrintableIndex,
|
||||
QuarterIndex, SemesterIndex, TxIndex, UnknownOutputIndex, WeekIndex, YearIndex,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
|
||||
@@ -12,7 +12,6 @@ use nucleo_matcher::{
|
||||
pattern::{AtomKind, CaseMatching, Normalization, Pattern},
|
||||
};
|
||||
use quick_cache::sync::Cache;
|
||||
use tabled::settings::Style;
|
||||
use vecdb::{AnyCollectableVec, AnyStoredVec};
|
||||
|
||||
mod deser;
|
||||
@@ -22,7 +21,6 @@ mod index;
|
||||
mod output;
|
||||
mod pagination;
|
||||
mod params;
|
||||
mod table;
|
||||
mod vecs;
|
||||
|
||||
pub use format::Format;
|
||||
@@ -30,7 +28,6 @@ pub use index::Index;
|
||||
pub use output::{Output, Value};
|
||||
pub use pagination::{PaginatedIndexParam, PaginationParam};
|
||||
pub use params::{IdParam, Params, ParamsOpt};
|
||||
pub use table::Tabled;
|
||||
use vecs::Vecs;
|
||||
|
||||
use crate::vecs::{IdToVec, IndexToVec};
|
||||
@@ -146,75 +143,66 @@ impl<'a> Interface<'a> {
|
||||
.unwrap_or_default()
|
||||
});
|
||||
|
||||
let mut values = vecs
|
||||
.iter()
|
||||
.map(|(_, vec)| -> Result<Vec<serde_json::Value>> {
|
||||
Ok(vec.collect_range_serde_json(from, to)?)
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
let format = params.format();
|
||||
|
||||
if values.is_empty() {
|
||||
return Ok(Output::default(format));
|
||||
}
|
||||
|
||||
let ids_last_i = vecs.len() - 1;
|
||||
|
||||
Ok(match format {
|
||||
Some(Format::CSV) | Some(Format::TSV) => {
|
||||
let delimiter = if format == Some(Format::CSV) {
|
||||
','
|
||||
} else {
|
||||
'\t'
|
||||
};
|
||||
|
||||
let mut text = vecs
|
||||
Format::CSV => {
|
||||
let headers = vecs.iter().map(|(id, _)| id.as_str()).collect::<Vec<_>>();
|
||||
let mut values = vecs
|
||||
.iter()
|
||||
.map(|(id, _)| id.to_owned())
|
||||
.collect::<Vec<_>>()
|
||||
.join(&delimiter.to_string());
|
||||
.map(|(_, vec)| Ok(vec.collect_range_string(from, to)?))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
text.push('\n');
|
||||
|
||||
let values_len = values.first().unwrap().len();
|
||||
|
||||
(0..values_len).for_each(|i| {
|
||||
let mut line = "".to_string();
|
||||
values.iter().enumerate().for_each(|(id_i, v)| {
|
||||
line += &v.get(i).unwrap().to_string();
|
||||
if id_i == ids_last_i {
|
||||
line.push('\n');
|
||||
} else {
|
||||
line.push(delimiter);
|
||||
}
|
||||
});
|
||||
text += &line;
|
||||
});
|
||||
|
||||
if format == Some(Format::CSV) {
|
||||
Output::CSV(text)
|
||||
} else {
|
||||
Output::TSV(text)
|
||||
if values.is_empty() {
|
||||
return Ok(Output::CSV(headers.join(",")));
|
||||
}
|
||||
}
|
||||
Some(Format::MD) => {
|
||||
let mut table =
|
||||
values.to_table(vecs.iter().map(|(s, _)| s.to_owned()).collect::<Vec<_>>());
|
||||
|
||||
table.with(Style::markdown());
|
||||
let first_len = values[0].len();
|
||||
let estimated_size = (headers.len() + values.len() * first_len) * 15;
|
||||
let mut csv = String::with_capacity(estimated_size);
|
||||
|
||||
Output::MD(table.to_string())
|
||||
}
|
||||
Some(Format::JSON) | None => {
|
||||
if values.len() == 1 {
|
||||
let mut values = values.pop().unwrap();
|
||||
if values.len() == 1 {
|
||||
let value = values.pop().unwrap();
|
||||
Output::Json(Value::Single(value))
|
||||
} else {
|
||||
Output::Json(Value::List(values))
|
||||
csv.push_str(&headers.join(","));
|
||||
csv.push('\n');
|
||||
|
||||
for col_index in 0..first_len {
|
||||
let mut first = true;
|
||||
for vec in &mut values {
|
||||
if col_index < vec.len() {
|
||||
if !first {
|
||||
csv.push(',');
|
||||
}
|
||||
first = false;
|
||||
|
||||
let field = std::mem::take(&mut vec[col_index]);
|
||||
|
||||
if field.contains(',') {
|
||||
csv.push('"');
|
||||
csv.push_str(&field);
|
||||
csv.push('"');
|
||||
} else {
|
||||
csv.push_str(&field);
|
||||
}
|
||||
}
|
||||
}
|
||||
csv.push('\n');
|
||||
}
|
||||
|
||||
Output::CSV(csv)
|
||||
}
|
||||
Format::JSON => {
|
||||
let mut values = vecs
|
||||
.iter()
|
||||
.map(|(_, vec)| -> Result<Vec<u8>> {
|
||||
Ok(vec.collect_range_json_bytes(from, to)?)
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
if values.is_empty() {
|
||||
return Ok(Output::default(format));
|
||||
}
|
||||
|
||||
if values.len() == 1 {
|
||||
Output::Json(Value::List(values.pop().unwrap()))
|
||||
} else {
|
||||
Output::Json(Value::Matrix(values))
|
||||
}
|
||||
|
||||
@@ -1,44 +1,54 @@
|
||||
use std::fmt;
|
||||
|
||||
use serde::Serialize;
|
||||
use tabled::Tabled as TabledTabled;
|
||||
|
||||
use crate::Format;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged, rename_all = "lowercase")]
|
||||
#[derive(Debug)]
|
||||
pub enum Output {
|
||||
Json(Value),
|
||||
CSV(String),
|
||||
TSV(String),
|
||||
MD(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, TabledTabled)]
|
||||
#[serde(untagged)]
|
||||
pub enum Value {
|
||||
Matrix(Vec<Vec<serde_json::Value>>),
|
||||
List(Vec<serde_json::Value>),
|
||||
Single(serde_json::Value),
|
||||
}
|
||||
|
||||
impl Output {
|
||||
pub fn default(format: Option<Format>) -> Self {
|
||||
match format {
|
||||
Some(Format::CSV) => Output::CSV("".to_string()),
|
||||
Some(Format::TSV) => Output::TSV("".to_string()),
|
||||
_ => Output::Json(Value::Single(serde_json::Value::Null)),
|
||||
#[allow(clippy::inherent_to_string)]
|
||||
pub fn to_string(self) -> String {
|
||||
match self {
|
||||
Output::CSV(s) => s,
|
||||
Output::Json(v) => unsafe { String::from_utf8_unchecked(v.to_vec()) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Output {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
#[derive(Debug)]
|
||||
pub enum Value {
|
||||
Matrix(Vec<Vec<u8>>),
|
||||
List(Vec<u8>),
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn to_vec(self) -> Vec<u8> {
|
||||
match self {
|
||||
Self::Json(value) => write!(f, "{}", serde_json::to_string_pretty(value).unwrap()),
|
||||
Self::CSV(string) => write!(f, "{string}"),
|
||||
Self::TSV(string) => write!(f, "{string}"),
|
||||
Self::MD(string) => write!(f, "{string}"),
|
||||
Value::List(v) => v,
|
||||
Self::Matrix(m) => {
|
||||
let total_size = m.iter().map(|v| v.len()).sum::<usize>() + m.len() - 1 + 2;
|
||||
let mut matrix = Vec::with_capacity(total_size);
|
||||
matrix.push(b'[');
|
||||
|
||||
for (i, vec) in m.into_iter().enumerate() {
|
||||
if i > 0 {
|
||||
matrix.push(b',');
|
||||
}
|
||||
matrix.extend(vec);
|
||||
}
|
||||
matrix.push(b']');
|
||||
matrix
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Output {
|
||||
pub fn default(format: Format) -> Self {
|
||||
match format {
|
||||
Format::CSV => Output::CSV("".to_string()),
|
||||
Format::JSON => Output::Json(Value::List(b"[]".to_vec())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct ParamsOpt {
|
||||
#[serde(default)]
|
||||
/// Format of the output
|
||||
#[schemars(description = "Format of the output")]
|
||||
format: Option<Format>,
|
||||
format: Format,
|
||||
}
|
||||
|
||||
impl ParamsOpt {
|
||||
@@ -82,11 +82,6 @@ impl ParamsOpt {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_format(mut self, format: Format) -> Self {
|
||||
self.format.replace(format);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from(&self) -> Option<i64> {
|
||||
self.from
|
||||
}
|
||||
@@ -107,7 +102,7 @@ impl ParamsOpt {
|
||||
self.to
|
||||
}
|
||||
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.format
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
use tabled::{Table, builder::Builder};
|
||||
|
||||
pub trait Tabled {
|
||||
fn to_table(&self, ids: Vec<String>) -> Table;
|
||||
}
|
||||
|
||||
impl Tabled for Vec<Vec<serde_json::Value>> {
|
||||
fn to_table(&self, ids: Vec<String>) -> Table {
|
||||
let mut builder = Builder::default();
|
||||
|
||||
builder.push_record(ids);
|
||||
|
||||
if let Some(first) = self.first() {
|
||||
let len = first.len();
|
||||
|
||||
(0..len).for_each(|index| {
|
||||
builder.push_record(
|
||||
self.iter()
|
||||
.map(|vec| vec.get(index).unwrap().to_string().replace("\"", "")),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
builder.build()
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ let version = mcp.get_version().await?;
|
||||
- `index`: Time dimension (height, date, week, month, etc.)
|
||||
- `ids`: Dataset identifiers (comma or space separated)
|
||||
- `from`/`to`: Range filtering (supports negative indexing from end)
|
||||
- `format`: Output format (json, csv, tsv, md)
|
||||
- `format`: Output format (json, csv)
|
||||
|
||||
**Pagination Parameters:**
|
||||
|
||||
|
||||
@@ -133,9 +133,12 @@ The response's format will depend on the given parameters, it will be:
|
||||
")]
|
||||
fn get_vecs(&self, Parameters(params): Parameters<Params>) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_vecs");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.search_and_format(params).unwrap()).unwrap(),
|
||||
]))
|
||||
Ok(CallToolResult::success(vec![Content::text(
|
||||
match self.interface.search_and_format(params) {
|
||||
Ok(output) => output.to_string(),
|
||||
Err(e) => format!("Error:\n{e}"),
|
||||
},
|
||||
)]))
|
||||
}
|
||||
|
||||
#[tool(description = "
|
||||
|
||||
@@ -16,7 +16,7 @@ use bitcoincore_rpc::RpcApi;
|
||||
use blk_index_to_blk_path::*;
|
||||
use brk_error::Result;
|
||||
use brk_structs::{BlkMetadata, BlkPosition, Block, Height, ParsedBlock};
|
||||
use crossbeam::channel::{Receiver, bounded};
|
||||
use crossbeam::channel::{bounded, Receiver};
|
||||
use parking_lot::{RwLock, RwLockReadGuard};
|
||||
use rayon::prelude::*;
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ vecdb = { workspace = true }
|
||||
jiff = { workspace = true }
|
||||
log = { workspace = true }
|
||||
quick_cache = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
sonic-rs = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tower-http = { version = "0.6.6", features = ["compression-full", "trace"] }
|
||||
tracing = "0.1.41"
|
||||
|
||||
@@ -12,7 +12,7 @@ This crate provides a high-performance HTTP server built on `axum` that exposes
|
||||
**Key Features:**
|
||||
|
||||
- RESTful API for blockchain data queries with flexible filtering
|
||||
- Multiple output formats: JSON, CSV, TSV, Markdown
|
||||
- Multiple output formats: JSON, CSV
|
||||
- Intelligent caching system with ETags and conditional requests
|
||||
- HTTP compression (Gzip, Brotli, Deflate, Zstd) for bandwidth efficiency
|
||||
- Static file serving for web interfaces and documentation
|
||||
@@ -81,7 +81,7 @@ server.serve(true).await?;
|
||||
**Supported Parameters:**
|
||||
|
||||
- `from` / `to`: Range filtering (height, timestamp, date-based)
|
||||
- `format`: Output format (json, csv, tsv, md)
|
||||
- `format`: Output format (json, csv)
|
||||
- Pagination parameters for large datasets
|
||||
|
||||
### Address API Response Format
|
||||
@@ -193,7 +193,7 @@ The server implements intelligent caching:
|
||||
2. **Parameter Validation**: Query parameter parsing and validation
|
||||
3. **Data Retrieval**: Interface calls to indexer/computer components
|
||||
4. **Caching Logic**: ETag generation and cache lookup
|
||||
5. **Format Conversion**: JSON/CSV/TSV/MD output formatting
|
||||
5. **Format Conversion**: JSON/CSV output formatting
|
||||
6. **Compression**: Response compression based on Accept-Encoding
|
||||
7. **Response**: HTTP response with appropriate headers
|
||||
|
||||
|
||||
@@ -11,13 +11,14 @@ use axum::{
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
routing::get,
|
||||
};
|
||||
use bitcoin::{Address, Network, Transaction, absolute::LockTime, consensus::Decodable};
|
||||
use bitcoin::{Address, Network, Transaction, consensus::Decodable};
|
||||
use bitcoincore_rpc::bitcoin;
|
||||
use brk_interface::{IdParam, Index, PaginatedIndexParam, PaginationParam, Params, ParamsOpt};
|
||||
use brk_parser::XORIndex;
|
||||
use brk_structs::{
|
||||
AddressBytesHash, AnyAddressDataIndexEnum, Bitcoin, OutputType, Txid, TxidPrefix,
|
||||
AddressBytesHash, AnyAddressDataIndexEnum, Bitcoin, OutputType, TxIndex, Txid, TxidPrefix,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use serde_json::Number;
|
||||
use vecdb::{AnyIterableVec, VecIterator};
|
||||
|
||||
@@ -32,6 +33,13 @@ pub trait ApiRoutes {
|
||||
|
||||
const TO_SEPARATOR: &str = "_to_";
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct TxResponse {
|
||||
txid: Txid,
|
||||
index: TxIndex,
|
||||
tx: Transaction,
|
||||
}
|
||||
|
||||
impl ApiRoutes for Router<AppState> {
|
||||
fn add_api_routes(self) -> Self {
|
||||
self.route(
|
||||
@@ -151,6 +159,7 @@ impl ApiRoutes for Router<AppState> {
|
||||
let Ok(txid) = bitcoin::Txid::from_str(&txid) else {
|
||||
return "Invalid txid".into_response()
|
||||
};
|
||||
|
||||
let txid = Txid::from(txid);
|
||||
let prefix = TxidPrefix::from(&txid);
|
||||
let interface = state.interface;
|
||||
@@ -162,22 +171,12 @@ impl ApiRoutes for Router<AppState> {
|
||||
.map(|opt| opt.map(|cow| cow.into_owned())) else {
|
||||
return "Unknown transaction".into_response();
|
||||
};
|
||||
|
||||
let txid = indexer
|
||||
.vecs
|
||||
.txindex_to_txid
|
||||
.iter()
|
||||
.unwrap_get_inner(txindex);
|
||||
let version = indexer
|
||||
.vecs
|
||||
.txindex_to_txversion
|
||||
.iter()
|
||||
.unwrap_get_inner(txindex);
|
||||
let rawlocktime = indexer
|
||||
.vecs
|
||||
.txindex_to_rawlocktime
|
||||
.iter()
|
||||
.unwrap_get_inner(txindex);
|
||||
let locktime = LockTime::from(rawlocktime);
|
||||
|
||||
let parser = interface.parser();
|
||||
let computer = interface.computer();
|
||||
@@ -213,14 +212,14 @@ impl ApiRoutes for Router<AppState> {
|
||||
return "Error decoding transaction".into_response();
|
||||
};
|
||||
|
||||
Json(serde_json::json!({
|
||||
"txid": txid,
|
||||
"index": txindex,
|
||||
"version": version,
|
||||
"locktime": locktime,
|
||||
"tx": tx,
|
||||
}))
|
||||
.into_response()
|
||||
let response = TxResponse { txid, index: txindex, tx };
|
||||
|
||||
let bytes = sonic_rs::to_vec(&response).unwrap();
|
||||
|
||||
Response::builder()
|
||||
.header("content-type", "application/json")
|
||||
.body(bytes.into())
|
||||
.unwrap()
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -89,7 +89,7 @@ fn req_to_response_res(
|
||||
Response::new(Body::from(v))
|
||||
} else {
|
||||
match interface.format(vecs, ¶ms.rest)? {
|
||||
Output::CSV(s) | Output::TSV(s) | Output::MD(s) => {
|
||||
Output::CSV(s) => {
|
||||
if let GuardResult::Guard(g) = guard_res {
|
||||
g.insert(s.clone().into())
|
||||
.map_err(|_| Error::QuickCacheError)?;
|
||||
@@ -97,7 +97,7 @@ fn req_to_response_res(
|
||||
s.into_response()
|
||||
}
|
||||
Output::Json(v) => {
|
||||
let json = serde_json::to_vec(&v)?;
|
||||
let json = v.to_vec();
|
||||
if let GuardResult::Guard(g) = guard_res {
|
||||
g.insert(json.clone().into())
|
||||
.map_err(|_| Error::QuickCacheError)?;
|
||||
@@ -115,17 +115,12 @@ fn req_to_response_res(
|
||||
headers.insert_cache_control_must_revalidate();
|
||||
|
||||
match format {
|
||||
Some(format) => {
|
||||
Format::CSV => {
|
||||
headers.insert_content_disposition_attachment();
|
||||
match format {
|
||||
Format::CSV => headers.insert_content_type_text_csv(),
|
||||
Format::MD => headers.insert_content_type_text_plain(),
|
||||
Format::TSV => headers.insert_content_type_text_tsv(),
|
||||
Format::JSON => headers.insert_content_type_application_json(),
|
||||
}
|
||||
headers.insert_content_type_text_csv()
|
||||
}
|
||||
None => headers.insert_content_type_application_json(),
|
||||
};
|
||||
Format::JSON => headers.insert_content_type_application_json(),
|
||||
}
|
||||
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ pub trait HeaderMapExtended {
|
||||
fn insert_content_type_application_pdf(&mut self);
|
||||
fn insert_content_type_text_css(&mut self);
|
||||
fn insert_content_type_text_csv(&mut self);
|
||||
fn insert_content_type_text_tsv(&mut self);
|
||||
fn insert_content_type_text_html(&mut self);
|
||||
fn insert_content_type_text_plain(&mut self);
|
||||
fn insert_content_type_font_woff2(&mut self);
|
||||
@@ -192,13 +191,6 @@ impl HeaderMapExtended for HeaderMap {
|
||||
self.insert(header::CONTENT_TYPE, "text/csv".parse().unwrap());
|
||||
}
|
||||
|
||||
fn insert_content_type_text_tsv(&mut self) {
|
||||
self.insert(
|
||||
header::CONTENT_TYPE,
|
||||
"text/tab-separated-values".parse().unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
fn insert_content_type_text_html(&mut self) {
|
||||
self.insert(header::CONTENT_TYPE, "text/html".parse().unwrap());
|
||||
}
|
||||
|
||||
@@ -14,13 +14,17 @@ allocative = { workspace = true }
|
||||
bitcoin = { workspace = true }
|
||||
bitcoincore-rpc = { workspace = true }
|
||||
brk_error = {workspace = true}
|
||||
vecdb = {workspace = true}
|
||||
byteview = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
itoa = "1.0.15"
|
||||
jiff = { workspace = true }
|
||||
num_enum = "0.7.4"
|
||||
rapidhash = "4.1.0"
|
||||
ryu = "1.0.20"
|
||||
serde = { workspace = true }
|
||||
serde_bytes = { workspace = true }
|
||||
strum = { version = "0.27", features = ["derive"] }
|
||||
vecdb = { workspace = true }
|
||||
zerocopy = { workspace = true }
|
||||
zerocopy-derive = { workspace = true }
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ mod structs;
|
||||
pub use groups::*;
|
||||
pub use structs::*;
|
||||
|
||||
pub use vecdb::{CheckedSub, Exit, Printable, Version};
|
||||
pub use vecdb::{CheckedSub, Exit, PrintableIndex, Version};
|
||||
|
||||
@@ -27,20 +27,16 @@ pub enum AddressBytes {
|
||||
|
||||
impl fmt::Display for AddressBytes {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
AddressBytes::P2PK65(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2PK33(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2PKH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2SH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2WPKH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2WSH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2TR(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2A(bytes) => bytes.to_string(),
|
||||
}
|
||||
)
|
||||
f.write_str(&match self {
|
||||
AddressBytes::P2PK65(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2PK33(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2PKH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2SH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2WPKH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2WSH(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2TR(bytes) => bytes.to_string(),
|
||||
AddressBytes::P2A(bytes) => bytes.to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ impl Serialize for AnyAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for AnyAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum AnyAddressDataIndexEnum {
|
||||
@@ -60,3 +66,12 @@ impl From<AnyAddressIndex> for AnyAddressDataIndexEnum {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// impl std::fmt::Display for AnyAddressDataIndexEnum {
|
||||
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
// match self {
|
||||
|
||||
// }
|
||||
// self.0.fmt(f)
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -139,3 +139,11 @@ impl CheckedSub<Bitcoin> for Bitcoin {
|
||||
Some(Self(self.0 - rhs.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Bitcoin {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
f.write_str(str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,3 +29,11 @@ impl Add<u32> for BlkPosition {
|
||||
Self(self.0 + rhs as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for BlkPosition {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ impl TryFrom<(&Client, Height)> for BlockHash {
|
||||
|
||||
impl fmt::Display for BlockHash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", bitcoin::BlockHash::from(self))
|
||||
f.write_str(&bitcoin::BlockHash::from(self).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,3 +165,11 @@ impl CheckedSub for Cents {
|
||||
self.0.checked_sub(rhs.0).map(Cents::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Cents {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,12 +118,24 @@ impl From<DateIndex> for Date {
|
||||
|
||||
impl std::fmt::Display for Date {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&format!(
|
||||
"{}-{:0>2}-{:0>2}",
|
||||
self.year(),
|
||||
self.month(),
|
||||
self.day()
|
||||
))
|
||||
let mut buf = itoa::Buffer::new();
|
||||
|
||||
f.write_str(buf.format(self.year()))?;
|
||||
f.write_str("-")?;
|
||||
|
||||
let month = self.month();
|
||||
if month < 10 {
|
||||
f.write_str("0")?;
|
||||
}
|
||||
f.write_str(buf.format(month))?;
|
||||
f.write_str("-")?;
|
||||
|
||||
let day = self.day();
|
||||
if day < 10 {
|
||||
f.write_str("0")?;
|
||||
}
|
||||
|
||||
f.write_str(buf.format(day))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use std::{
|
||||
fmt,
|
||||
ops::{Add, Rem},
|
||||
};
|
||||
use std::ops::{Add, Rem};
|
||||
|
||||
use allocative::Allocative;
|
||||
use brk_error::Error;
|
||||
use jiff::Span;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, FromCoarserIndex, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, FromCoarserIndex, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::{DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, WeekIndex, YearIndex};
|
||||
@@ -99,13 +96,15 @@ impl Rem<usize> for DateIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for DateIndex {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
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 Printable for DateIndex {
|
||||
impl PrintableIndex for DateIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"dateindex"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{Date, DateIndex, YearIndex};
|
||||
@@ -116,7 +116,7 @@ impl From<YearIndex> for DecadeIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for DecadeIndex {
|
||||
impl PrintableIndex for DecadeIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"decadeindex"
|
||||
}
|
||||
@@ -125,3 +125,11 @@ impl Printable for DecadeIndex {
|
||||
&["decade", "decadeindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DecadeIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::Height;
|
||||
@@ -91,7 +91,7 @@ impl CheckedSub for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for DifficultyEpoch {
|
||||
impl PrintableIndex for DifficultyEpoch {
|
||||
fn to_string() -> &'static str {
|
||||
"difficultyepoch"
|
||||
}
|
||||
@@ -100,3 +100,11 @@ impl Printable for DifficultyEpoch {
|
||||
&["difficulty", "difficultyepoch"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DifficultyEpoch {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,3 +386,11 @@ impl Sum for Dollars {
|
||||
Self::from(dollars)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Dollars {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
f.write_str(str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,3 +25,9 @@ impl From<&LoadedAddressData> for EmptyAddressData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for EmptyAddressData {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "transfered: {}", self.transfered)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -55,12 +55,14 @@ impl Add<usize> for EmptyAddressIndex {
|
||||
Self(self.0 + rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub<EmptyAddressIndex> for EmptyAddressIndex {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
impl Printable for EmptyAddressIndex {
|
||||
|
||||
impl PrintableIndex for EmptyAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"emptyaddressindex"
|
||||
}
|
||||
@@ -69,3 +71,9 @@ impl Printable for EmptyAddressIndex {
|
||||
&["emptyaddr", "emptyaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for EmptyAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -52,12 +52,14 @@ impl Add<usize> for EmptyOutputIndex {
|
||||
Self(self.0 + rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub<EmptyOutputIndex> for EmptyOutputIndex {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
impl Printable for EmptyOutputIndex {
|
||||
|
||||
impl PrintableIndex for EmptyOutputIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"emptyoutputindex"
|
||||
}
|
||||
@@ -66,3 +68,9 @@ impl Printable for EmptyOutputIndex {
|
||||
&["emptyout", "emptyoutputindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for EmptyOutputIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,3 +100,11 @@ impl Ord for FeeRate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for FeeRate {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
f.write_str(str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::Height;
|
||||
@@ -97,7 +97,7 @@ impl Div<usize> for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for HalvingEpoch {
|
||||
impl PrintableIndex for HalvingEpoch {
|
||||
fn to_string() -> &'static str {
|
||||
"halvingepoch"
|
||||
}
|
||||
@@ -106,3 +106,11 @@ impl Printable for HalvingEpoch {
|
||||
&["halving", "halvingepoch"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for HalvingEpoch {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
fmt::{self, Debug},
|
||||
fmt::Debug,
|
||||
ops::{Add, AddAssign, Rem},
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ use bitcoincore_rpc::{Client, RpcApi};
|
||||
use byteview::ByteView;
|
||||
use derive_deref::Deref;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, Stamp, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, Stamp, StoredCompressed};
|
||||
use zerocopy::{FromBytes, IntoBytes};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
@@ -170,12 +170,6 @@ impl Rem<usize> for Height {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Height {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for Height {
|
||||
fn from(value: u32) -> Self {
|
||||
Self(value)
|
||||
@@ -268,7 +262,7 @@ impl From<Height> for Stamp {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for Height {
|
||||
impl PrintableIndex for Height {
|
||||
fn to_string() -> &'static str {
|
||||
"height"
|
||||
}
|
||||
@@ -277,3 +271,11 @@ impl Printable for Height {
|
||||
&["h", "height"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Height {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign};
|
||||
use allocative::Allocative;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::Vin;
|
||||
@@ -99,7 +99,7 @@ impl From<InputIndex> for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for InputIndex {
|
||||
impl PrintableIndex for InputIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"inputindex"
|
||||
}
|
||||
@@ -108,3 +108,11 @@ impl Printable for InputIndex {
|
||||
&["in", "inputindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for InputIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ impl From<EmptyAddressData> for LoadedAddressData {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&EmptyAddressData> for LoadedAddressData {
|
||||
fn from(value: &EmptyAddressData) -> Self {
|
||||
Self {
|
||||
@@ -100,3 +101,13 @@ impl From<&EmptyAddressData> for LoadedAddressData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LoadedAddressData {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"sent: {}, received: {}, realized_cap: {}, utxos: {}",
|
||||
self.sent, self.received, self.realized_cap, self.utxos
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -58,7 +58,7 @@ impl CheckedSub<LoadedAddressIndex> for LoadedAddressIndex {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
impl Printable for LoadedAddressIndex {
|
||||
impl PrintableIndex for LoadedAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"loadedaddressindex"
|
||||
}
|
||||
@@ -67,3 +67,9 @@ impl Printable for LoadedAddressIndex {
|
||||
&["loadedaddr", "loadedaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LoadedAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ mod p2shaddressindex;
|
||||
mod p2traddressindex;
|
||||
mod p2wpkhaddressindex;
|
||||
mod p2wshaddressindex;
|
||||
mod pool;
|
||||
mod poolid;
|
||||
mod pools;
|
||||
mod quarterindex;
|
||||
mod rawlocktime;
|
||||
mod sats;
|
||||
@@ -104,6 +107,9 @@ pub use p2shaddressindex::*;
|
||||
pub use p2traddressindex::*;
|
||||
pub use p2wpkhaddressindex::*;
|
||||
pub use p2wshaddressindex::*;
|
||||
pub use pool::*;
|
||||
pub use poolid::*;
|
||||
pub use pools::*;
|
||||
pub use quarterindex::*;
|
||||
pub use rawlocktime::*;
|
||||
pub use sats::*;
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{Date, DateIndex, YearIndex};
|
||||
@@ -107,7 +107,7 @@ impl CheckedSub for MonthIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for MonthIndex {
|
||||
impl PrintableIndex for MonthIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"monthindex"
|
||||
}
|
||||
@@ -116,3 +116,11 @@ impl Printable for MonthIndex {
|
||||
&["m", "month", "monthindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for MonthIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,16 @@ impl Serialize for OHLCCents {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OHLCCents {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}, {}, {}, {}",
|
||||
self.open, self.high, self.low, self.close
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)]
|
||||
#[repr(C)]
|
||||
pub struct OHLCDollars {
|
||||
@@ -120,6 +130,16 @@ impl From<&OHLCCents> for OHLCDollars {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OHLCDollars {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}, {}, {}, {}",
|
||||
self.open, self.high, self.low, self.close
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)]
|
||||
#[repr(C)]
|
||||
pub struct OHLCSats {
|
||||
@@ -165,6 +185,16 @@ impl From<Close<Sats>> for OHLCSats {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OHLCSats {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}, {}, {}, {}",
|
||||
self.open, self.high, self.low, self.close
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Default,
|
||||
@@ -272,6 +302,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::fmt::Display for Open<T>
|
||||
where
|
||||
T: std::fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Default,
|
||||
@@ -379,6 +418,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::fmt::Display for High<T>
|
||||
where
|
||||
T: std::fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Default,
|
||||
@@ -486,6 +534,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::fmt::Display for Low<T>
|
||||
where
|
||||
T: std::fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Default,
|
||||
@@ -615,12 +672,11 @@ impl Sum for Close<Dollars> {
|
||||
}
|
||||
}
|
||||
|
||||
// impl<T> Mul<usize> for Close<T>
|
||||
// where
|
||||
// T: Mul<usize, Output = T>,
|
||||
// {
|
||||
// type Output = Self;
|
||||
// fn mul(self, rhs: usize) -> Self::Output {
|
||||
// Self(self.0 * rhs)
|
||||
// }
|
||||
// }
|
||||
impl<T> std::fmt::Display for Close<T>
|
||||
where
|
||||
T: std::fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -59,7 +59,7 @@ impl CheckedSub<OpReturnIndex> for OpReturnIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for OpReturnIndex {
|
||||
impl PrintableIndex for OpReturnIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"opreturnindex"
|
||||
}
|
||||
@@ -68,3 +68,9 @@ impl Printable for OpReturnIndex {
|
||||
&["op", "opreturn", "opreturnindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OpReturnIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign};
|
||||
use allocative::Allocative;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::copy_first_8bytes;
|
||||
@@ -115,7 +115,7 @@ impl From<&[u8]> for OutputIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for OutputIndex {
|
||||
impl PrintableIndex for OutputIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"outputindex"
|
||||
}
|
||||
@@ -124,3 +124,11 @@ impl Printable for OutputIndex {
|
||||
&["out", "outputindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OutputIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use bitcoin::{Address, AddressType, ScriptBuf, opcodes::all::OP_PUSHBYTES_2};
|
||||
use brk_error::Error;
|
||||
use serde::Serialize;
|
||||
use strum::Display;
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
Display,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
@@ -18,6 +20,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
Serialize,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[repr(u8)]
|
||||
pub enum OutputType {
|
||||
P2PK65,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -72,7 +72,7 @@ impl CheckedSub<P2AAddressIndex> for P2AAddressIndex {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
impl Printable for P2AAddressIndex {
|
||||
impl PrintableIndex for P2AAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2aaddressindex"
|
||||
}
|
||||
@@ -81,3 +81,9 @@ impl Printable for P2AAddressIndex {
|
||||
&["aaddr", "p2aaddr", "p2aaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2AAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -58,7 +58,7 @@ impl CheckedSub<P2MSOutputIndex> for P2MSOutputIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2MSOutputIndex {
|
||||
impl PrintableIndex for P2MSOutputIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2msoutputindex"
|
||||
}
|
||||
@@ -67,3 +67,9 @@ impl Printable for P2MSOutputIndex {
|
||||
&["msout", "p2msout", "p2msoutputindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2MSOutputIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2PK33AddressIndex> for P2PK33AddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2PK33AddressIndex {
|
||||
impl PrintableIndex for P2PK33AddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2pk33addressindex"
|
||||
}
|
||||
@@ -82,3 +82,9 @@ impl Printable for P2PK33AddressIndex {
|
||||
&["pk33addr", "p2pk33addr", "p2pk33addressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2PK33AddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2PK65AddressIndex> for P2PK65AddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2PK65AddressIndex {
|
||||
impl PrintableIndex for P2PK65AddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2pk65addressindex"
|
||||
}
|
||||
@@ -81,3 +81,9 @@ impl Printable for P2PK65AddressIndex {
|
||||
&["pk65addr", "p2pk65addr", "p2pk65addressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2PK65AddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2PKHAddressIndex> for P2PKHAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2PKHAddressIndex {
|
||||
impl PrintableIndex for P2PKHAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2pkhaddressindex"
|
||||
}
|
||||
@@ -82,3 +82,9 @@ impl Printable for P2PKHAddressIndex {
|
||||
&["pkhaddr", "p2pkhaddr", "p2pkhaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2PKHAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::ops::Add;
|
||||
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -78,7 +78,7 @@ impl CheckedSub<P2SHAddressIndex> for P2SHAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2SHAddressIndex {
|
||||
impl PrintableIndex for P2SHAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2shaddressindex"
|
||||
}
|
||||
@@ -87,3 +87,9 @@ impl Printable for P2SHAddressIndex {
|
||||
&["shaddr", "p2shaddr", "p2shaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2SHAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2TRAddressIndex> for P2TRAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2TRAddressIndex {
|
||||
impl PrintableIndex for P2TRAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2traddressindex"
|
||||
}
|
||||
@@ -82,3 +82,9 @@ impl Printable for P2TRAddressIndex {
|
||||
&["traddr", "p2traddr", "p2traddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2TRAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2WPKHAddressIndex> for P2WPKHAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2WPKHAddressIndex {
|
||||
impl PrintableIndex for P2WPKHAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2wpkhaddressindex"
|
||||
}
|
||||
@@ -82,3 +82,9 @@ impl Printable for P2WPKHAddressIndex {
|
||||
&["wpkhaddr", "p2wpkhaddr", "p2wpkhaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2WPKHAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::ops::Add;
|
||||
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -73,7 +73,7 @@ impl CheckedSub<P2WSHAddressIndex> for P2WSHAddressIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for P2WSHAddressIndex {
|
||||
impl PrintableIndex for P2WSHAddressIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"p2wshaddressindex"
|
||||
}
|
||||
@@ -82,3 +82,9 @@ impl Printable for P2WSHAddressIndex {
|
||||
&["wshaddr", "p2wshaddr", "p2wshaddressindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for P2WSHAddressIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use allocative::Allocative;
|
||||
|
||||
use crate::pools::PoolId;
|
||||
use super::PoolId;
|
||||
|
||||
#[derive(Debug, Allocative)]
|
||||
pub struct Pool {
|
||||
@@ -14,8 +14,7 @@ pub struct Pool {
|
||||
|
||||
impl Pool {
|
||||
pub fn serialized_id(&self) -> String {
|
||||
let value = serde_json::to_value(self.id).unwrap();
|
||||
value.as_str().unwrap().to_string()
|
||||
self.id.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use allocative::Allocative;
|
||||
use num_enum::{FromPrimitive, IntoPrimitive};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::Display;
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
// Created from the list in `pools.rs`
|
||||
@@ -9,6 +10,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
#[derive(
|
||||
Debug,
|
||||
Copy,
|
||||
Display,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
@@ -25,6 +27,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
Allocative,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[repr(u8)]
|
||||
pub enum PoolId {
|
||||
#[default]
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::MonthIndex;
|
||||
@@ -95,7 +95,7 @@ impl CheckedSub for QuarterIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for QuarterIndex {
|
||||
impl PrintableIndex for QuarterIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"quarterindex"
|
||||
}
|
||||
@@ -104,3 +104,11 @@ impl Printable for QuarterIndex {
|
||||
&["q", "quarter", "quarterindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for QuarterIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,3 +28,10 @@ impl From<RawLockTime> for LockTime {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RawLockTime {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let lock_time = LockTime::from(*self);
|
||||
f.write_str(&lock_time.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,3 +251,11 @@ impl Mul<Sats> for usize {
|
||||
Self::Output::from(rhs.0 * self as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Sats {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::MonthIndex;
|
||||
@@ -95,7 +95,7 @@ impl CheckedSub for SemesterIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for SemesterIndex {
|
||||
impl PrintableIndex for SemesterIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"semesterindex"
|
||||
}
|
||||
@@ -104,3 +104,11 @@ impl Printable for SemesterIndex {
|
||||
&["s", "semester", "semesterindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SemesterIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{Printable, StoredCompressed};
|
||||
use vecdb::{PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
#[derive(
|
||||
@@ -49,7 +49,7 @@ impl From<StoredBool> for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredBool {
|
||||
impl PrintableIndex for StoredBool {
|
||||
fn to_string() -> &'static str {
|
||||
"bool"
|
||||
}
|
||||
@@ -58,3 +58,13 @@ impl Printable for StoredBool {
|
||||
&["bool"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredBool {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.is_true() {
|
||||
f.write_str("true")
|
||||
} else {
|
||||
f.write_str("false")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::{
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::{Close, StoredU32};
|
||||
@@ -206,7 +206,7 @@ impl Ord for StoredF32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredF32 {
|
||||
impl PrintableIndex for StoredF32 {
|
||||
fn to_string() -> &'static str {
|
||||
"f32"
|
||||
}
|
||||
@@ -221,3 +221,11 @@ impl Sum for StoredF32 {
|
||||
Self(iter.map(|v| v.0).sum::<f32>())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredF32 {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
f.write_str(str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::{Bitcoin, Dollars};
|
||||
@@ -174,7 +174,7 @@ impl From<Bitcoin> for StoredF64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredF64 {
|
||||
impl PrintableIndex for StoredF64 {
|
||||
fn to_string() -> &'static str {
|
||||
"f64"
|
||||
}
|
||||
@@ -196,3 +196,11 @@ impl Div<Bitcoin> for StoredF64 {
|
||||
Self(self.0 / f64::from(rhs))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredF64 {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
f.write_str(str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
|
||||
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
#[derive(
|
||||
@@ -94,7 +94,7 @@ impl From<StoredI16> for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredI16 {
|
||||
impl PrintableIndex for StoredI16 {
|
||||
fn to_string() -> &'static str {
|
||||
"i16"
|
||||
}
|
||||
@@ -103,3 +103,11 @@ impl Printable for StoredI16 {
|
||||
&["i16"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredI16 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::borrow::Cow;
|
||||
use byteview::ByteView;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::Printable;
|
||||
use vecdb::PrintableIndex;
|
||||
|
||||
#[derive(Default, Debug, Deref, Clone, Serialize)]
|
||||
pub struct StoredString(String);
|
||||
@@ -53,7 +53,7 @@ impl From<&StoredString> for ByteView {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredString {
|
||||
impl PrintableIndex for StoredString {
|
||||
fn to_string() -> &'static str {
|
||||
"string"
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div};
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{
|
||||
@@ -175,7 +175,7 @@ impl From<EmptyOutputIndex> for StoredU16 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredU16 {
|
||||
impl PrintableIndex for StoredU16 {
|
||||
fn to_string() -> &'static str {
|
||||
"u16"
|
||||
}
|
||||
@@ -184,3 +184,11 @@ impl Printable for StoredU16 {
|
||||
&["u16"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredU16 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div, Mul};
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{
|
||||
@@ -205,7 +205,7 @@ impl From<EmptyOutputIndex> for StoredU32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredU32 {
|
||||
impl PrintableIndex for StoredU32 {
|
||||
fn to_string() -> &'static str {
|
||||
"u32"
|
||||
}
|
||||
@@ -214,3 +214,11 @@ impl Printable for StoredU32 {
|
||||
&["u32"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredU32 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Div};
|
||||
use allocative::Allocative;
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{
|
||||
@@ -220,7 +220,7 @@ impl From<EmptyOutputIndex> for StoredU64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredU64 {
|
||||
impl PrintableIndex for StoredU64 {
|
||||
fn to_string() -> &'static str {
|
||||
"u64"
|
||||
}
|
||||
@@ -229,3 +229,11 @@ impl Printable for StoredU64 {
|
||||
&["u64"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredU64 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::ops::{Add, AddAssign, Div};
|
||||
|
||||
use vecdb::{CheckedSub, Printable};
|
||||
use derive_deref::Deref;
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, PrintableIndex};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
pub type StoredPhantom = StoredU8;
|
||||
@@ -99,7 +99,7 @@ impl From<StoredU8> for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for StoredU8 {
|
||||
impl PrintableIndex for StoredU8 {
|
||||
fn to_string() -> &'static str {
|
||||
"u8"
|
||||
}
|
||||
@@ -108,3 +108,11 @@ impl Printable for StoredU8 {
|
||||
&["u8"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoredU8 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,3 +158,11 @@ impl From<Timestamp> for f64 {
|
||||
value.0 as f64
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Timestamp {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ impl From<&Txid> for bitcoin::Txid {
|
||||
|
||||
impl fmt::Display for Txid {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", bitcoin::Txid::from(self))
|
||||
f.write_str(&bitcoin::Txid::from(self).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use allocative::Allocative;
|
||||
use byteview::ByteView;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::copy_first_4bytes;
|
||||
@@ -115,7 +115,7 @@ impl From<TxIndex> for StoredU32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for TxIndex {
|
||||
impl PrintableIndex for TxIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"txindex"
|
||||
}
|
||||
@@ -124,3 +124,11 @@ impl Printable for TxIndex {
|
||||
&["tx", "txindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TxIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,3 +52,11 @@ impl From<TxVersion> for StoredU16 {
|
||||
Self::from(value.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TxVersion {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,3 +117,11 @@ impl CheckedSub<TypeIndex> for TypeIndex {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TypeIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::ops::Add;
|
||||
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use serde::Serialize;
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::TypeIndex;
|
||||
@@ -59,7 +59,7 @@ impl CheckedSub<UnknownOutputIndex> for UnknownOutputIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for UnknownOutputIndex {
|
||||
impl PrintableIndex for UnknownOutputIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"unknownoutputindex"
|
||||
}
|
||||
@@ -68,3 +68,9 @@ impl Printable for UnknownOutputIndex {
|
||||
&["unknownout", "unknownoutputindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for UnknownOutputIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{Date, DateIndex};
|
||||
@@ -118,7 +118,7 @@ impl CheckedSub for WeekIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for WeekIndex {
|
||||
impl PrintableIndex for WeekIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"weekindex"
|
||||
}
|
||||
@@ -127,3 +127,11 @@ impl Printable for WeekIndex {
|
||||
&["w", "week", "weekindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for WeekIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,3 +81,11 @@ impl Div<Weight> for Weight {
|
||||
Self(self.0 / rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Weight {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use allocative::Allocative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Printable, StoredCompressed};
|
||||
use vecdb::{CheckedSub, PrintableIndex, StoredCompressed};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{Date, DateIndex, MonthIndex};
|
||||
@@ -113,7 +113,7 @@ impl From<MonthIndex> for YearIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Printable for YearIndex {
|
||||
impl PrintableIndex for YearIndex {
|
||||
fn to_string() -> &'static str {
|
||||
"yearindex"
|
||||
}
|
||||
@@ -122,3 +122,11 @@ impl Printable for YearIndex {
|
||||
&["y", "year", "yearindex"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for YearIndex {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
- add support for https (rustls)
|
||||
- _STORE_
|
||||
- save height and version in one file
|
||||
- _STRUCTS_
|
||||
- remove `checked_sub` trait ? (checked with the `dev` profile)
|
||||
- __DOCS__
|
||||
- _README_
|
||||
- add a comparison table with alternatives
|
||||
|
||||
Reference in New Issue
Block a user