global: serialization optimizations for faster responses

This commit is contained in:
nym21
2025-09-20 18:42:15 +02:00
parent 23f6397a97
commit 2c5b502da9
90 changed files with 915 additions and 460 deletions
+1 -1
View File
@@ -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};
+10 -14
View File
@@ -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)
}
}
+1 -1
View File
@@ -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())
}
}
+8
View File
@@ -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)
}
}
+18 -6
View File
@@ -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))
}
}
+8 -9
View File
@@ -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"
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+11 -9
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+6
View File
@@ -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::*;
+10 -2
View File
@@ -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)
}
}
+65 -9
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+45
View File
@@ -0,0 +1,45 @@
use allocative::Allocative;
use super::PoolId;
#[derive(Debug, Allocative)]
pub struct Pool {
pub id: PoolId,
pub name: &'static str,
pub addresses: Box<[&'static str]>,
pub tags: Box<[&'static str]>,
pub tags_lowercase: Box<[String]>,
pub link: &'static str,
}
impl Pool {
pub fn serialized_id(&self) -> String {
self.id.to_string()
}
}
impl From<(usize, JSONPool)> for Pool {
fn from((index, pool): (usize, JSONPool)) -> Self {
Self {
id: (index as u8).into(),
name: pool.name,
addresses: pool.addresses,
tags_lowercase: pool
.tags
.iter()
.map(|t| t.to_lowercase())
.collect::<Vec<_>>()
.into_boxed_slice(),
tags: pool.tags,
link: pool.link,
}
}
}
#[derive(Debug)]
pub struct JSONPool {
pub name: &'static str,
pub addresses: Box<[&'static str]>,
pub tags: Box<[&'static str]>,
pub link: &'static str,
}
+290
View File
@@ -0,0 +1,290 @@
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`
// Can be used as index for said list
#[allow(clippy::upper_case_acronyms)]
#[derive(
Debug,
Copy,
Display,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Serialize,
Deserialize,
FromPrimitive,
IntoPrimitive,
FromBytes,
IntoBytes,
Immutable,
KnownLayout,
Allocative,
)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
#[repr(u8)]
pub enum PoolId {
#[default]
Unknown,
BlockFills,
UltimusPool,
TerraPool,
Luxor,
OneThash,
BtcCom,
Bitfarms,
HuobiPool,
WayiCn,
CanoePool,
BtcTop,
BitcoinCom,
Pool175btc,
GbMiners,
AXbt,
AsicMiner,
BitMinter,
BitcoinRussia,
BtcServ,
SimplecoinUs,
BtcGuild,
Eligius,
OzCoin,
EclipseMc,
MaxBtc,
TripleMining,
CoinLab,
Pool50btc,
GhashIo,
StMiningCorp,
Bitparking,
Mmpool,
Polmine,
KncMiner,
Bitalo,
F2Pool,
Hhtt,
MegaBigPower,
MtRed,
NmcBit,
YourbtcNet,
GiveMeCoins,
BraiinsPool,
AntPool,
MultiCoinCo,
BcpoolIo,
Cointerra,
KanoPool,
SoloCk,
CkPool,
NiceHash,
BitClub,
BitcoinAffiliateNetwork,
Btcc,
BwPool,
ExxBw,
Bitsolo,
BitFury,
TwentyOneInc,
DigitalBtc,
EightBaochi,
MyBtcCoinPool,
TbDice,
HashPool,
Nexious,
BravoMining,
HotPool,
OkExPool,
BcMonster,
OneHash,
Bixin,
TatmasPool,
ViaBtc,
ConnectBtc,
BatPool,
Waterhole,
DcExploration,
Dcex,
BtPool,
FiftyEightCoin,
BitcoinIndia,
ShawnP0wers,
PHashIo,
RigPool,
HaoZhuZhu,
SevenPool,
MiningKings,
HashBx,
DPool,
Rawpool,
Haominer,
Helix,
BitcoinUkraine,
Poolin,
SecretSuperstar,
TigerpoolNet,
SigmapoolCom,
OkpoolTop,
Hummerpool,
Tangpool,
BytePool,
SpiderPool,
NovaBlock,
MiningCity,
BinancePool,
Minerium,
LubianCom,
Okkong,
AaoPool,
EmcdPool,
FoundryUsa,
SbiCrypto,
ArkPool,
PureBtcCom,
MaraPool,
KuCoinPool,
EntrustCharityPool,
OkMiner,
Titan,
PegaPool,
BtcNuggets,
CloudHashing,
DigitalXMintsy,
Telco214,
BtcPoolParty,
Multipool,
TransactionCoinMining,
BtcDig,
TrickysBtcPool,
BtcMp,
Eobot,
Unomp,
Patels,
GoGreenLight,
EkanemBtc,
Canoe,
Tiger,
OneM1x,
Zulupool,
SecPool,
Ocean,
WhitePool,
Wk057,
FutureBitApolloSolo,
CarbonNegative,
PortlandHodl,
Phoenix,
Neopool,
MaxiPool,
BitFuFuPool,
LuckyPool,
MiningDutch,
PublicPool,
MiningSquared,
InnopolisTech,
BtcLab,
Parasite,
Dummy158,
Dummy159,
Dummy160,
Dummy161,
Dummy162,
Dummy163,
Dummy164,
Dummy165,
Dummy166,
Dummy167,
Dummy168,
Dummy169,
Dummy170,
Dummy171,
Dummy172,
Dummy173,
Dummy174,
Dummy175,
Dummy176,
Dummy177,
Dummy178,
Dummy179,
Dummy180,
Dummy181,
Dummy182,
Dummy183,
Dummy184,
Dummy185,
Dummy186,
Dummy187,
Dummy188,
Dummy189,
Dummy190,
Dummy191,
Dummy192,
Dummy193,
Dummy194,
Dummy195,
Dummy196,
Dummy197,
Dummy198,
Dummy199,
Dummy200,
Dummy201,
Dummy202,
Dummy203,
Dummy204,
Dummy205,
Dummy206,
Dummy207,
Dummy208,
Dummy209,
Dummy210,
Dummy211,
Dummy212,
Dummy213,
Dummy214,
Dummy215,
Dummy216,
Dummy217,
Dummy218,
Dummy219,
Dummy220,
Dummy221,
Dummy222,
Dummy223,
Dummy224,
Dummy225,
Dummy226,
Dummy227,
Dummy228,
Dummy229,
Dummy230,
Dummy231,
Dummy232,
Dummy233,
Dummy234,
Dummy235,
Dummy236,
Dummy237,
Dummy238,
Dummy239,
Dummy240,
Dummy241,
Dummy242,
Dummy243,
Dummy244,
Dummy245,
Dummy246,
Dummy247,
Dummy248,
Dummy249,
Dummy250,
Dummy251,
Dummy252,
Dummy253,
Dummy254,
Dummy255,
}
File diff suppressed because it is too large Load Diff
+10 -2
View File
@@ -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())
}
}
+8
View File
@@ -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)
}
}
+12 -2
View File
@@ -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")
}
}
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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"
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+1 -1
View File
@@ -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())
}
}
+10 -2
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}
+8
View File
@@ -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)
}
}
+10 -2
View File
@@ -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)
}
}