mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-17 14:08:10 -07:00
global: snapshot
This commit is contained in:
Generated
+13
-3
@@ -527,6 +527,7 @@ dependencies = [
|
|||||||
"brk_bencher",
|
"brk_bencher",
|
||||||
"brk_binder",
|
"brk_binder",
|
||||||
"brk_bundler",
|
"brk_bundler",
|
||||||
|
"brk_client",
|
||||||
"brk_computer",
|
"brk_computer",
|
||||||
"brk_error",
|
"brk_error",
|
||||||
"brk_fetcher",
|
"brk_fetcher",
|
||||||
@@ -614,6 +615,15 @@ dependencies = [
|
|||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brk_client"
|
||||||
|
version = "0.1.0-alpha.1"
|
||||||
|
dependencies = [
|
||||||
|
"brk_types",
|
||||||
|
"minreq",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "brk_computer"
|
name = "brk_computer"
|
||||||
version = "0.1.0-alpha.1"
|
version = "0.1.0-alpha.1"
|
||||||
@@ -4217,7 +4227,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rawdb"
|
name = "rawdb"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@@ -5407,7 +5417,7 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vecdb"
|
name = "vecdb"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"log",
|
"log",
|
||||||
@@ -5426,7 +5436,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vecdb_derive"
|
name = "vecdb_derive"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.111",
|
"syn 2.0.111",
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ brk_bencher = { version = "0.1.0-alpha.1", path = "crates/brk_bencher" }
|
|||||||
brk_binder = { version = "0.1.0-alpha.1", path = "crates/brk_binder" }
|
brk_binder = { version = "0.1.0-alpha.1", path = "crates/brk_binder" }
|
||||||
brk_bundler = { version = "0.1.0-alpha.1", path = "crates/brk_bundler" }
|
brk_bundler = { version = "0.1.0-alpha.1", path = "crates/brk_bundler" }
|
||||||
brk_cli = { version = "0.1.0-alpha.1", path = "crates/brk_cli" }
|
brk_cli = { version = "0.1.0-alpha.1", path = "crates/brk_cli" }
|
||||||
|
brk_client = { version = "0.1.0-alpha.1", path = "crates/brk_client" }
|
||||||
brk_computer = { version = "0.1.0-alpha.1", path = "crates/brk_computer" }
|
brk_computer = { version = "0.1.0-alpha.1", path = "crates/brk_computer" }
|
||||||
brk_error = { version = "0.1.0-alpha.1", path = "crates/brk_error" }
|
brk_error = { version = "0.1.0-alpha.1", path = "crates/brk_error" }
|
||||||
brk_fetcher = { version = "0.1.0-alpha.1", path = "crates/brk_fetcher" }
|
brk_fetcher = { version = "0.1.0-alpha.1", path = "crates/brk_fetcher" }
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ full = [
|
|||||||
"bencher",
|
"bencher",
|
||||||
"binder",
|
"binder",
|
||||||
"bundler",
|
"bundler",
|
||||||
|
"client",
|
||||||
"computer",
|
"computer",
|
||||||
"error",
|
"error",
|
||||||
"fetcher",
|
"fetcher",
|
||||||
@@ -33,6 +34,7 @@ full = [
|
|||||||
bencher = ["brk_bencher"]
|
bencher = ["brk_bencher"]
|
||||||
binder = ["brk_binder"]
|
binder = ["brk_binder"]
|
||||||
bundler = ["brk_bundler"]
|
bundler = ["brk_bundler"]
|
||||||
|
client = ["brk_client"]
|
||||||
computer = ["brk_computer"]
|
computer = ["brk_computer"]
|
||||||
error = ["brk_error"]
|
error = ["brk_error"]
|
||||||
fetcher = ["brk_fetcher"]
|
fetcher = ["brk_fetcher"]
|
||||||
@@ -54,6 +56,7 @@ types = ["brk_types"]
|
|||||||
brk_bencher = { workspace = true, optional = true }
|
brk_bencher = { workspace = true, optional = true }
|
||||||
brk_binder = { workspace = true, optional = true }
|
brk_binder = { workspace = true, optional = true }
|
||||||
brk_bundler = { workspace = true, optional = true }
|
brk_bundler = { workspace = true, optional = true }
|
||||||
|
brk_client = { workspace = true, optional = true }
|
||||||
brk_computer = { workspace = true, optional = true }
|
brk_computer = { workspace = true, optional = true }
|
||||||
brk_error = { workspace = true, optional = true }
|
brk_error = { workspace = true, optional = true }
|
||||||
brk_fetcher = { workspace = true, optional = true }
|
brk_fetcher = { workspace = true, optional = true }
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ pub use brk_binder as binder;
|
|||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use brk_bundler as bundler;
|
pub use brk_bundler as bundler;
|
||||||
|
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use brk_client as client;
|
||||||
|
|
||||||
#[cfg(feature = "computer")]
|
#[cfg(feature = "computer")]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use brk_computer as computer;
|
pub use brk_computer as computer;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
lib.rs
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "brk_client"
|
||||||
|
description = "A BRK API client"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
brk_types = { workspace = true }
|
||||||
|
minreq = { workspace = true }
|
||||||
|
serde = { workspace = true }
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# brk_client
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fn main() {
|
||||||
|
let profile = std::env::var("PROFILE").unwrap_or_default();
|
||||||
|
|
||||||
|
if profile == "release" {
|
||||||
|
println!("cargo:rustc-flag=-C");
|
||||||
|
println!("cargo:rustc-flag=target-cpu=native");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -176,84 +176,84 @@ impl Computer {
|
|||||||
info!("Computed prices in {:?}", i.elapsed());
|
info!("Computed prices in {:?}", i.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread::scope(|scope| -> Result<()> {
|
thread::scope(|scope| -> Result<()> {
|
||||||
// let blks = scope.spawn(|| -> Result<()> {
|
let blks = scope.spawn(|| -> Result<()> {
|
||||||
info!("Computing BLKs metadata...");
|
info!("Computing BLKs metadata...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.blks
|
self.blks
|
||||||
.compute(indexer, &starting_indexes, reader, exit)?;
|
.compute(indexer, &starting_indexes, reader, exit)?;
|
||||||
info!("Computed blk in {:?}", i.elapsed());
|
info!("Computed blk in {:?}", i.elapsed());
|
||||||
// Ok(())
|
Ok(())
|
||||||
// });
|
});
|
||||||
|
|
||||||
// let constants = scope.spawn(|| -> Result<()> {
|
let constants = scope.spawn(|| -> Result<()> {
|
||||||
info!("Computing constants...");
|
info!("Computing constants...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.constants
|
self.constants
|
||||||
.compute(&self.indexes, &starting_indexes, exit)?;
|
.compute(&self.indexes, &starting_indexes, exit)?;
|
||||||
info!("Computed constants in {:?}", i.elapsed());
|
info!("Computed constants in {:?}", i.elapsed());
|
||||||
// Ok(())
|
Ok(())
|
||||||
// });
|
});
|
||||||
|
|
||||||
// let chain = scope.spawn(|| -> Result<()> {
|
let chain = scope.spawn(|| -> Result<()> {
|
||||||
info!("Computing chain...");
|
info!("Computing chain...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.chain.compute(
|
self.chain.compute(
|
||||||
indexer,
|
indexer,
|
||||||
&self.indexes,
|
&self.indexes,
|
||||||
&starting_indexes,
|
&starting_indexes,
|
||||||
self.price.as_ref(),
|
self.price.as_ref(),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
info!("Computed chain in {:?}", i.elapsed());
|
info!("Computed chain in {:?}", i.elapsed());
|
||||||
// Ok(())
|
Ok(())
|
||||||
// });
|
});
|
||||||
|
|
||||||
if let Some(price) = self.price.as_ref() {
|
if let Some(price) = self.price.as_ref() {
|
||||||
info!("Computing market...");
|
info!("Computing market...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.market.compute(price, &starting_indexes, exit)?;
|
self.market.compute(price, &starting_indexes, exit)?;
|
||||||
info!("Computed market in {:?}", i.elapsed());
|
info!("Computed market in {:?}", i.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
// blks.join().unwrap()?;
|
blks.join().unwrap()?;
|
||||||
// constants.join().unwrap()?;
|
constants.join().unwrap()?;
|
||||||
// chain.join().unwrap()?;
|
chain.join().unwrap()?;
|
||||||
// Ok(())
|
Ok(())
|
||||||
// })?;
|
})?;
|
||||||
|
|
||||||
let starting_indexes_clone = starting_indexes.clone();
|
let starting_indexes_clone = starting_indexes.clone();
|
||||||
// thread::scope(|scope| -> Result<()> {
|
thread::scope(|scope| -> Result<()> {
|
||||||
// let pools = scope.spawn(|| -> Result<()> {
|
let pools = scope.spawn(|| -> Result<()> {
|
||||||
info!("Computing pools...");
|
info!("Computing pools...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.pools.compute(
|
self.pools.compute(
|
||||||
indexer,
|
indexer,
|
||||||
&self.indexes,
|
&self.indexes,
|
||||||
&starting_indexes_clone,
|
&starting_indexes_clone,
|
||||||
&self.chain,
|
&self.chain,
|
||||||
self.price.as_ref(),
|
self.price.as_ref(),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
info!("Computed pools in {:?}", i.elapsed());
|
info!("Computed pools in {:?}", i.elapsed());
|
||||||
// Ok(())
|
Ok(())
|
||||||
// });
|
});
|
||||||
|
|
||||||
info!("Computing stateful...");
|
info!("Computing stateful...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
self.stateful.compute(
|
self.stateful.compute(
|
||||||
indexer,
|
indexer,
|
||||||
&self.indexes,
|
&self.indexes,
|
||||||
&self.chain,
|
&self.chain,
|
||||||
self.price.as_ref(),
|
self.price.as_ref(),
|
||||||
&mut starting_indexes,
|
&mut starting_indexes,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
info!("Computed stateful in {:?}", i.elapsed());
|
info!("Computed stateful in {:?}", i.elapsed());
|
||||||
|
|
||||||
// pools.join().unwrap()?;
|
pools.join().unwrap()?;
|
||||||
// Ok(())
|
Ok(())
|
||||||
// })?;
|
})?;
|
||||||
|
|
||||||
info!("Computing cointime...");
|
info!("Computing cointime...");
|
||||||
let i = Instant::now();
|
let i = Instant::now();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use crate::{Sats, TypeIndex};
|
use crate::{Sats, TypeIndex};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Address statistics on the blockchain (confirmed transactions only)
|
/// Address statistics on the blockchain (confirmed transactions only)
|
||||||
///
|
///
|
||||||
/// Based on mempool.space's format with type_index extension.
|
/// Based on mempool.space's format with type_index extension.
|
||||||
#[derive(Debug, Default, Serialize, JsonSchema)]
|
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AddressChainStats {
|
pub struct AddressChainStats {
|
||||||
/// Total number of transaction outputs that funded this address
|
/// Total number of transaction outputs that funded this address
|
||||||
#[schemars(example = 5)]
|
#[schemars(example = 5)]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::{Sats, TxOut};
|
use crate::{Sats, TxOut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Address statistics in the mempool (unconfirmed transactions only)
|
/// Address statistics in the mempool (unconfirmed transactions only)
|
||||||
///
|
///
|
||||||
/// Based on mempool.space's format.
|
/// Based on mempool.space's format.
|
||||||
///
|
///
|
||||||
#[derive(Debug, Default, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AddressMempoolStats {
|
pub struct AddressMempoolStats {
|
||||||
/// Number of unconfirmed transaction outputs funding this address
|
/// Number of unconfirmed transaction outputs funding this address
|
||||||
#[schemars(example = 0)]
|
#[schemars(example = 0)]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use crate::{Address, AddressChainStats, AddressMempoolStats};
|
use crate::{Address, AddressChainStats, AddressMempoolStats};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Address information compatible with mempool.space API format
|
/// Address information compatible with mempool.space API format
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AddressStats {
|
pub struct AddressStats {
|
||||||
/// Bitcoin address string
|
/// Bitcoin address string
|
||||||
#[schemars(
|
#[schemars(
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use bitcoin::hex::DisplayHex;
|
use bitcoin::hex::DisplayHex;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{AddressBytes, OutputType};
|
use crate::{AddressBytes, OutputType};
|
||||||
|
|
||||||
/// Address validation result
|
/// Address validation result
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct AddressValidation {
|
pub struct AddressValidation {
|
||||||
/// Whether the address is valid
|
/// Whether the address is valid
|
||||||
pub isvalid: bool,
|
pub isvalid: bool,
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco};
|
use vecdb::{CheckedSub, Formattable, Pco};
|
||||||
|
|
||||||
use super::{Sats, StoredF64};
|
use super::{Sats, StoredF64};
|
||||||
|
|
||||||
/// Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis)
|
/// Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis)
|
||||||
#[derive(Debug, Default, Clone, Copy, Serialize, Pco, JsonSchema)]
|
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Pco, JsonSchema)]
|
||||||
pub struct Bitcoin(f64);
|
pub struct Bitcoin(f64);
|
||||||
|
|
||||||
impl Add for Bitcoin {
|
impl Add for Bitcoin {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{BlockHash, Height, Timestamp, Weight};
|
use crate::{BlockHash, Height, Timestamp, Weight};
|
||||||
|
|
||||||
/// Block information returned by the API
|
/// Block information returned by the API
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct BlockInfo {
|
pub struct BlockInfo {
|
||||||
/// Block hash
|
/// Block hash
|
||||||
pub id: BlockHash,
|
pub id: BlockHash,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{BlockHash, Height};
|
use crate::{BlockHash, Height};
|
||||||
|
|
||||||
/// Block status indicating whether block is in the best chain
|
/// Block status indicating whether block is in the best chain
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct BlockStatus {
|
pub struct BlockStatus {
|
||||||
/// Whether this block is in the best chain
|
/// Whether this block is in the best chain
|
||||||
pub in_best_chain: bool,
|
pub in_best_chain: bool,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::ser::SerializeTuple;
|
use serde::ser::SerializeTuple;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::{Height, Timestamp};
|
use crate::{Height, Timestamp};
|
||||||
|
|
||||||
/// A single difficulty adjustment entry.
|
/// A single difficulty adjustment entry.
|
||||||
/// Serializes as array: [timestamp, height, difficulty, change_percent]
|
/// Serializes as array: [timestamp, height, difficulty, change_percent]
|
||||||
#[derive(Debug, JsonSchema)]
|
#[derive(Debug, Deserialize, JsonSchema)]
|
||||||
pub struct DifficultyAdjustmentEntry {
|
pub struct DifficultyAdjustmentEntry {
|
||||||
pub timestamp: Timestamp,
|
pub timestamp: Timestamp,
|
||||||
pub height: Height,
|
pub height: Height,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{Height, Timestamp};
|
use super::{Height, Timestamp};
|
||||||
|
|
||||||
/// A single difficulty data point.
|
/// A single difficulty data point.
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct DifficultyEntry {
|
pub struct DifficultyEntry {
|
||||||
/// Unix timestamp of the difficulty adjustment.
|
/// Unix timestamp of the difficulty adjustment.
|
||||||
pub timestamp: Timestamp,
|
pub timestamp: Timestamp,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Bytes, Formattable};
|
use vecdb::{Bytes, Formattable};
|
||||||
|
|
||||||
use crate::{LoadedAddressData, Sats};
|
use crate::{LoadedAddressData, Sats};
|
||||||
|
|
||||||
/// Data of an empty address
|
/// Data of an empty address
|
||||||
#[derive(Debug, Default, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct EmptyAddressData {
|
pub struct EmptyAddressData {
|
||||||
/// Total transaction count
|
/// Total transaction count
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::Timestamp;
|
use super::Timestamp;
|
||||||
|
|
||||||
/// A single hashrate data point.
|
/// A single hashrate data point.
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct HashrateEntry {
|
pub struct HashrateEntry {
|
||||||
/// Unix timestamp.
|
/// Unix timestamp.
|
||||||
pub timestamp: Timestamp,
|
pub timestamp: Timestamp,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{DifficultyEntry, HashrateEntry};
|
use super::{DifficultyEntry, HashrateEntry};
|
||||||
|
|
||||||
/// Summary of network hashrate and difficulty data.
|
/// Summary of network hashrate and difficulty data.
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct HashrateSummary {
|
pub struct HashrateSummary {
|
||||||
/// Historical hashrate data points.
|
/// Historical hashrate data points.
|
||||||
pub hashrates: Vec<HashrateEntry>,
|
pub hashrates: Vec<HashrateEntry>,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Server health status
|
/// Server health status
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct Health {
|
pub struct Health {
|
||||||
pub status: &'static str,
|
pub status: &'static str,
|
||||||
pub service: &'static str,
|
pub service: &'static str,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use brk_error::{Error, Result};
|
use brk_error::{Error, Result};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Bytes, CheckedSub, Formattable};
|
use vecdb::{Bytes, CheckedSub, Formattable};
|
||||||
|
|
||||||
use crate::{Bitcoin, Dollars, EmptyAddressData, Sats};
|
use crate::{Bitcoin, Dollars, EmptyAddressData, Sats};
|
||||||
|
|
||||||
/// Data for a loaded (non-empty) address with current balance
|
/// Data for a loaded (non-empty) address with current balance
|
||||||
#[derive(Debug, Default, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct LoadedAddressData {
|
pub struct LoadedAddressData {
|
||||||
/// Total transaction count
|
/// Total transaction count
|
||||||
@@ -51,13 +51,15 @@ impl LoadedAddressData {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn utxo_count(&self) -> u32 {
|
pub fn utxo_count(&self) -> u32 {
|
||||||
self.funded_txo_count.checked_sub(self.spent_txo_count).unwrap_or_else(|| {
|
self.funded_txo_count
|
||||||
panic!(
|
.checked_sub(self.spent_txo_count)
|
||||||
"LoadedAddressData corruption: spent_txo_count ({}) > funded_txo_count ({}). \
|
.unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"LoadedAddressData corruption: spent_txo_count ({}) > funded_txo_count ({}). \
|
||||||
Address data: {:?}",
|
Address data: {:?}",
|
||||||
self.spent_txo_count, self.funded_txo_count, self
|
self.spent_txo_count, self.funded_txo_count, self
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{Sats, Transaction, VSize};
|
use crate::{Sats, Transaction, VSize};
|
||||||
|
|
||||||
/// Mempool statistics
|
/// Mempool statistics
|
||||||
#[derive(Debug, Default, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct MempoolInfo {
|
pub struct MempoolInfo {
|
||||||
/// Number of transactions in the mempool
|
/// Number of transactions in the mempool
|
||||||
pub count: usize,
|
pub count: usize,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Metric count statistics - distinct metrics and total metric-index combinations
|
/// Metric count statistics - distinct metrics and total metric-index combinations
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct MetricCount {
|
pub struct MetricCount {
|
||||||
/// Number of unique metrics available (e.g., realized_price, market_cap)
|
/// Number of unique metrics available (e.g., realized_price, market_cap)
|
||||||
#[schemars(example = 3141)]
|
#[schemars(example = 3141)]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use vecdb::AnySerializableVec;
|
use vecdb::AnySerializableVec;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ use vecdb::AnySerializableVec;
|
|||||||
///
|
///
|
||||||
/// All metric data endpoints return this structure when format is JSON.
|
/// All metric data endpoints return this structure when format is JSON.
|
||||||
/// This type is not instantiated - use `MetricData::serialize()` to write JSON bytes directly.
|
/// This type is not instantiated - use `MetricData::serialize()` to write JSON bytes directly.
|
||||||
#[derive(JsonSchema)]
|
#[derive(JsonSchema, Deserialize)]
|
||||||
pub struct MetricData {
|
pub struct MetricData {
|
||||||
/// Total number of data points in the metric
|
/// Total number of data points in the metric
|
||||||
pub total: usize,
|
pub total: usize,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{Pool, PoolSlug};
|
use crate::{Pool, PoolSlug};
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ impl From<&'static Pool> for PoolDetailInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Block counts for different time periods
|
/// Block counts for different time periods
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct PoolBlockCounts {
|
pub struct PoolBlockCounts {
|
||||||
/// Total blocks mined (all time)
|
/// Total blocks mined (all time)
|
||||||
pub all: u32,
|
pub all: u32,
|
||||||
@@ -77,7 +77,7 @@ pub struct PoolBlockCounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pool's share of total blocks for different time periods
|
/// Pool's share of total blocks for different time periods
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct PoolBlockShares {
|
pub struct PoolBlockShares {
|
||||||
/// Share of all blocks (0.0 - 1.0)
|
/// Share of all blocks (0.0 - 1.0)
|
||||||
pub all: f64,
|
pub all: f64,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use bitcoin::{absolute::LockTime, locktime::absolute::LOCK_TIME_THRESHOLD};
|
use bitcoin::{absolute::LockTime, locktime::absolute::LOCK_TIME_THRESHOLD};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Formattable, Pco};
|
use vecdb::{Formattable, Pco};
|
||||||
|
|
||||||
/// Transaction locktime
|
/// Transaction locktime
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Pco, JsonSchema)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Pco, JsonSchema)]
|
||||||
pub struct RawLockTime(u32);
|
pub struct RawLockTime(u32);
|
||||||
|
|
||||||
impl From<LockTime> for RawLockTime {
|
impl From<LockTime> for RawLockTime {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{Height, Sats};
|
use super::{Height, Sats};
|
||||||
|
|
||||||
/// Block reward statistics over a range of blocks
|
/// Block reward statistics over a range of blocks
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RewardStats {
|
pub struct RewardStats {
|
||||||
/// First block in the range
|
/// First block in the range
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Formattable, Pco, PrintableIndex};
|
use vecdb::{Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
/// Fixed-size boolean value optimized for on-disk storage (stored as u16)
|
/// Fixed-size boolean value optimized for on-disk storage (stored as u16)
|
||||||
#[derive(Debug, Deref, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Default,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct StoredBool(u16);
|
pub struct StoredBool(u16);
|
||||||
|
|
||||||
impl StoredBool {
|
impl StoredBool {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::{
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use crate::{Close, StoredU32};
|
use crate::{Close, StoredU32};
|
||||||
@@ -16,7 +16,7 @@ use crate::{Close, StoredU32};
|
|||||||
use super::{Dollars, StoredF64};
|
use super::{Dollars, StoredF64};
|
||||||
|
|
||||||
/// Stored 32-bit floating point value
|
/// Stored 32-bit floating point value
|
||||||
#[derive(Debug, Deref, Default, Clone, Copy, Serialize, Pco, JsonSchema)]
|
#[derive(Debug, Deref, Default, Clone, Copy, Serialize, Deserialize, Pco, JsonSchema)]
|
||||||
pub struct StoredF32(f32);
|
pub struct StoredF32(f32);
|
||||||
|
|
||||||
impl StoredF32 {
|
impl StoredF32 {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ use std::{
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use crate::{Bitcoin, Dollars};
|
use crate::{Bitcoin, Dollars};
|
||||||
|
|
||||||
/// Fixed-size 64-bit floating point value optimized for on-disk storage
|
/// Fixed-size 64-bit floating point value optimized for on-disk storage
|
||||||
#[derive(Debug, Deref, Default, Clone, Copy, Serialize, Pco, JsonSchema)]
|
#[derive(Debug, Deref, Default, Clone, Copy, Serialize, Deserialize, Pco, JsonSchema)]
|
||||||
pub struct StoredF64(f64);
|
pub struct StoredF64(f64);
|
||||||
|
|
||||||
impl StoredF64 {
|
impl StoredF64 {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div, Mul};
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@@ -12,7 +12,21 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Fixed-size 32-bit unsigned integer optimized for on-disk storage
|
/// Fixed-size 32-bit unsigned integer optimized for on-disk storage
|
||||||
#[derive(Debug, Deref, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Default,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct StoredU32(u32);
|
pub struct StoredU32(u32);
|
||||||
|
|
||||||
impl StoredU32 {
|
impl StoredU32 {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::ops::{Add, AddAssign, Div};
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@@ -13,7 +13,21 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Fixed-size 64-bit unsigned integer optimized for on-disk storage
|
/// Fixed-size 64-bit unsigned integer optimized for on-disk storage
|
||||||
#[derive(Debug, Default, Deref, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Default,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct StoredU64(u64);
|
pub struct StoredU64(u64);
|
||||||
|
|
||||||
impl StoredU64 {
|
impl StoredU64 {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::Index;
|
use super::Index;
|
||||||
|
|
||||||
/// Leaf node containing metric metadata
|
/// Leaf node containing metric metadata
|
||||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct MetricLeaf {
|
pub struct MetricLeaf {
|
||||||
/// The metric name/identifier
|
/// The metric name/identifier
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -35,7 +35,7 @@ impl MetricLeaf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// MetricLeaf with JSON Schema for client generation
|
/// MetricLeaf with JSON Schema for client generation
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct MetricLeafWithSchema {
|
pub struct MetricLeafWithSchema {
|
||||||
/// The core metric metadata
|
/// The core metric metadata
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
@@ -85,7 +85,7 @@ impl PartialEq for MetricLeafWithSchema {
|
|||||||
impl Eq for MetricLeafWithSchema {}
|
impl Eq for MetricLeafWithSchema {}
|
||||||
|
|
||||||
/// Hierarchical tree node for organizing metrics into categories
|
/// Hierarchical tree node for organizing metrics into categories
|
||||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum TreeNode {
|
pub enum TreeNode {
|
||||||
/// Branch node containing subcategories
|
/// Branch node containing subcategories
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
use crate::{FeeRate, RawLockTime, Sats, TxIn, TxIndex, TxOut, TxStatus, TxVersion, Txid, VSize, Weight};
|
use crate::{
|
||||||
|
FeeRate, RawLockTime, Sats, TxIn, TxIndex, TxOut, TxStatus, TxVersion, Txid, VSize, Weight,
|
||||||
|
};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::CheckedSub;
|
use vecdb::CheckedSub;
|
||||||
|
|
||||||
/// Transaction information compatible with mempool.space API format
|
/// Transaction information compatible with mempool.space API format
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct Transaction {
|
pub struct Transaction {
|
||||||
#[schemars(example = TxIndex::new(0))]
|
#[schemars(example = TxIndex::new(0))]
|
||||||
pub index: Option<TxIndex>,
|
pub index: Option<TxIndex>,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::{TxOut, Txid, Vout};
|
use crate::{TxOut, Txid, Vout};
|
||||||
use bitcoin::{Script, ScriptBuf};
|
use bitcoin::{Script, ScriptBuf};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Serialize, Serializer, ser::SerializeStruct};
|
use serde::{Deserialize, Serialize, Serializer, ser::SerializeStruct};
|
||||||
|
|
||||||
/// Transaction input
|
/// Transaction input
|
||||||
#[derive(Debug, Clone, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, JsonSchema)]
|
||||||
pub struct TxIn {
|
pub struct TxIn {
|
||||||
/// Transaction ID of the output being spent
|
/// Transaction ID of the output being spent
|
||||||
#[schemars(example = "0000000000000000000000000000000000000000000000000000000000000000")]
|
#[schemars(example = "0000000000000000000000000000000000000000000000000000000000000000")]
|
||||||
|
|||||||
@@ -2,13 +2,26 @@ use std::ops::{Add, AddAssign};
|
|||||||
|
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use super::Vin;
|
use super::Vin;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Deref, DerefMut, Default, Serialize, Pco, JsonSchema,
|
Debug,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Deref,
|
||||||
|
DerefMut,
|
||||||
|
Default,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
)]
|
)]
|
||||||
pub struct TxInIndex(u64);
|
pub struct TxInIndex(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::{Address, AddressBytes, OutputType, Sats};
|
use crate::{Address, AddressBytes, OutputType, Sats};
|
||||||
use bitcoin::ScriptBuf;
|
use bitcoin::ScriptBuf;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Serialize, Serializer, ser::SerializeStruct};
|
use serde::{Deserialize, Serialize, Serializer, ser::SerializeStruct};
|
||||||
|
|
||||||
/// Transaction output
|
/// Transaction output
|
||||||
#[derive(Debug, Clone, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize, JsonSchema)]
|
||||||
pub struct TxOut {
|
pub struct TxOut {
|
||||||
/// Script pubkey (locking script)
|
/// Script pubkey (locking script)
|
||||||
#[serde(
|
#[serde(
|
||||||
|
|||||||
@@ -2,13 +2,26 @@ use std::ops::{Add, AddAssign};
|
|||||||
|
|
||||||
use derive_deref::{Deref, DerefMut};
|
use derive_deref::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex};
|
||||||
|
|
||||||
use super::Vout;
|
use super::Vout;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Deref, DerefMut, Default, Serialize, Pco, JsonSchema,
|
Debug,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Deref,
|
||||||
|
DerefMut,
|
||||||
|
Default,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
)]
|
)]
|
||||||
pub struct TxOutIndex(u64);
|
pub struct TxOutIndex(u64);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{BlockHash, Height, Timestamp};
|
use crate::{BlockHash, Height, Timestamp};
|
||||||
|
|
||||||
/// Transaction confirmation status
|
/// Transaction confirmation status
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct TxStatus {
|
pub struct TxStatus {
|
||||||
/// Whether the transaction is confirmed
|
/// Whether the transaction is confirmed
|
||||||
#[schemars(example = true)]
|
#[schemars(example = true)]
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Formattable, Pco};
|
use vecdb::{Formattable, Pco};
|
||||||
|
|
||||||
use super::StoredU16;
|
use super::StoredU16;
|
||||||
|
|
||||||
/// Transaction version number
|
/// Transaction version number
|
||||||
#[derive(Debug, Deref, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct TxVersion(u16);
|
pub struct TxVersion(u16);
|
||||||
|
|
||||||
impl TxVersion {
|
impl TxVersion {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{Sats, TxStatus, Txid, Vout};
|
use crate::{Sats, TxStatus, Txid, Vout};
|
||||||
|
|
||||||
/// Unspent transaction output
|
/// Unspent transaction output
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct Utxo {
|
pub struct Utxo {
|
||||||
pub txid: Txid,
|
pub txid: Txid,
|
||||||
pub vout: Vout,
|
pub vout: Vout,
|
||||||
|
|||||||
@@ -2,13 +2,27 @@ use std::ops::{Add, AddAssign, Div, Sub, SubAssign};
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Formattable, Pco};
|
use vecdb::{Formattable, Pco};
|
||||||
|
|
||||||
use crate::Weight;
|
use crate::Weight;
|
||||||
|
|
||||||
/// Virtual size in vbytes (weight / 4, rounded up)
|
/// Virtual size in vbytes (weight / 4, rounded up)
|
||||||
#[derive(Debug, Default, Deref, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Default,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct VSize(u64);
|
pub struct VSize(u64);
|
||||||
|
|
||||||
impl VSize {
|
impl VSize {
|
||||||
@@ -49,7 +63,10 @@ impl From<usize> for VSize {
|
|||||||
impl From<f64> for VSize {
|
impl From<f64> for VSize {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(value: f64) -> Self {
|
fn from(value: f64) -> Self {
|
||||||
debug_assert!(value >= 0.0 && value.fract() == 0.0, "VSize must be a non-negative integer");
|
debug_assert!(
|
||||||
|
value >= 0.0 && value.fract() == 0.0,
|
||||||
|
"VSize must be a non-negative integer"
|
||||||
|
);
|
||||||
Self(value as u64)
|
Self(value as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,24 @@ use std::ops::{Add, AddAssign, Div};
|
|||||||
|
|
||||||
use derive_deref::Deref;
|
use derive_deref::Deref;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use vecdb::{Formattable, Pco};
|
use vecdb::{Formattable, Pco};
|
||||||
|
|
||||||
/// Transaction or block weight in weight units (WU)
|
/// Transaction or block weight in weight units (WU)
|
||||||
#[derive(Debug, Deref, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Pco, JsonSchema)]
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Deref,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
Serialize,
|
||||||
|
Deserialize,
|
||||||
|
Pco,
|
||||||
|
JsonSchema,
|
||||||
|
)]
|
||||||
pub struct Weight(u64);
|
pub struct Weight(u64);
|
||||||
|
|
||||||
impl Weight {
|
impl Weight {
|
||||||
|
|||||||
Reference in New Issue
Block a user