global: snapshot

This commit is contained in:
nym21
2026-03-14 14:00:03 +01:00
parent d53e533c9f
commit 7bcc32fea1
31 changed files with 413 additions and 287 deletions

View File

@@ -3147,8 +3147,7 @@ impl MetricsTree_Blocks {
/// Metrics tree node.
pub struct MetricsTree_Blocks_Difficulty {
pub raw: MetricPattern18<StoredF64>,
pub base: MetricPattern2<StoredF64>,
pub value: MetricPattern1<StoredF64>,
pub as_hash: MetricPattern1<StoredF64>,
pub adjustment: BpsPercentRatioPattern,
pub epoch: MetricPattern1<Epoch>,
@@ -3159,8 +3158,7 @@ pub struct MetricsTree_Blocks_Difficulty {
impl MetricsTree_Blocks_Difficulty {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
raw: MetricPattern18::new(client.clone(), "difficulty".to_string()),
base: MetricPattern2::new(client.clone(), "difficulty".to_string()),
value: MetricPattern1::new(client.clone(), "difficulty".to_string()),
as_hash: MetricPattern1::new(client.clone(), "difficulty_as_hash".to_string()),
adjustment: BpsPercentRatioPattern::new(client.clone(), "difficulty_adjustment".to_string()),
epoch: MetricPattern1::new(client.clone(), "difficulty_epoch".to_string()),
@@ -3990,7 +3988,7 @@ impl MetricsTree_Scripts {
/// Metrics tree node.
pub struct MetricsTree_Scripts_Raw {
pub empty: MetricsTree_Scripts_Raw_Empty,
pub opreturn: MetricsTree_Scripts_Raw_Opreturn,
pub op_return: MetricsTree_Scripts_Raw_OpReturn,
pub p2ms: MetricsTree_Scripts_Raw_P2ms,
pub unknown: MetricsTree_Scripts_Raw_Unknown,
}
@@ -3999,7 +3997,7 @@ impl MetricsTree_Scripts_Raw {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
empty: MetricsTree_Scripts_Raw_Empty::new(client.clone(), format!("{base_path}_empty")),
opreturn: MetricsTree_Scripts_Raw_Opreturn::new(client.clone(), format!("{base_path}_opreturn")),
op_return: MetricsTree_Scripts_Raw_OpReturn::new(client.clone(), format!("{base_path}_op_return")),
p2ms: MetricsTree_Scripts_Raw_P2ms::new(client.clone(), format!("{base_path}_p2ms")),
unknown: MetricsTree_Scripts_Raw_Unknown::new(client.clone(), format!("{base_path}_unknown")),
}
@@ -4022,12 +4020,12 @@ impl MetricsTree_Scripts_Raw_Empty {
}
/// Metrics tree node.
pub struct MetricsTree_Scripts_Raw_Opreturn {
pub struct MetricsTree_Scripts_Raw_OpReturn {
pub first_index: MetricPattern18<OpReturnIndex>,
pub to_tx_index: MetricPattern23<TxIndex>,
}
impl MetricsTree_Scripts_Raw_Opreturn {
impl MetricsTree_Scripts_Raw_OpReturn {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
first_index: MetricPattern18::new(client.clone(), "first_op_return_index".to_string()),
@@ -4077,7 +4075,7 @@ pub struct MetricsTree_Scripts_Count {
pub p2tr: BaseCumulativeSumPattern<StoredU64>,
pub p2wpkh: BaseCumulativeSumPattern<StoredU64>,
pub p2wsh: BaseCumulativeSumPattern<StoredU64>,
pub opreturn: BaseCumulativeSumPattern<StoredU64>,
pub op_return: BaseCumulativeSumPattern<StoredU64>,
pub empty_output: BaseCumulativeSumPattern<StoredU64>,
pub unknown_output: BaseCumulativeSumPattern<StoredU64>,
pub segwit: BaseCumulativeSumPattern<StoredU64>,
@@ -4095,7 +4093,7 @@ impl MetricsTree_Scripts_Count {
p2tr: BaseCumulativeSumPattern::new(client.clone(), "p2tr_count".to_string()),
p2wpkh: BaseCumulativeSumPattern::new(client.clone(), "p2wpkh_count".to_string()),
p2wsh: BaseCumulativeSumPattern::new(client.clone(), "p2wsh_count".to_string()),
opreturn: BaseCumulativeSumPattern::new(client.clone(), "opreturn_count".to_string()),
op_return: BaseCumulativeSumPattern::new(client.clone(), "op_return_count".to_string()),
empty_output: BaseCumulativeSumPattern::new(client.clone(), "empty_output_count".to_string()),
unknown_output: BaseCumulativeSumPattern::new(client.clone(), "unknown_output_count".to_string()),
segwit: BaseCumulativeSumPattern::new(client.clone(), "segwit_count".to_string()),
@@ -4105,28 +4103,28 @@ impl MetricsTree_Scripts_Count {
/// Metrics tree node.
pub struct MetricsTree_Scripts_Value {
pub opreturn: MetricsTree_Scripts_Value_Opreturn,
pub op_return: MetricsTree_Scripts_Value_OpReturn,
}
impl MetricsTree_Scripts_Value {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
opreturn: MetricsTree_Scripts_Value_Opreturn::new(client.clone(), format!("{base_path}_opreturn")),
op_return: MetricsTree_Scripts_Value_OpReturn::new(client.clone(), format!("{base_path}_op_return")),
}
}
}
/// Metrics tree node.
pub struct MetricsTree_Scripts_Value_Opreturn {
pub struct MetricsTree_Scripts_Value_OpReturn {
pub base: BtcCentsSatsUsdPattern,
pub cumulative: BtcCentsSatsUsdPattern,
}
impl MetricsTree_Scripts_Value_Opreturn {
impl MetricsTree_Scripts_Value_OpReturn {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
base: BtcCentsSatsUsdPattern::new(client.clone(), "opreturn_value".to_string()),
cumulative: BtcCentsSatsUsdPattern::new(client.clone(), "opreturn_value_cumulative".to_string()),
base: BtcCentsSatsUsdPattern::new(client.clone(), "op_return_value".to_string()),
cumulative: BtcCentsSatsUsdPattern::new(client.clone(), "op_return_value_cumulative".to_string()),
}
}
}
@@ -4581,7 +4579,7 @@ pub struct MetricsTree_Indexes_Address {
pub p2ms: MetricsTree_Indexes_Address_P2ms,
pub empty: MetricsTree_Indexes_Address_Empty,
pub unknown: MetricsTree_Indexes_Address_Unknown,
pub opreturn: MetricsTree_Indexes_Address_Opreturn,
pub op_return: MetricsTree_Indexes_Address_OpReturn,
}
impl MetricsTree_Indexes_Address {
@@ -4598,7 +4596,7 @@ impl MetricsTree_Indexes_Address {
p2ms: MetricsTree_Indexes_Address_P2ms::new(client.clone(), format!("{base_path}_p2ms")),
empty: MetricsTree_Indexes_Address_Empty::new(client.clone(), format!("{base_path}_empty")),
unknown: MetricsTree_Indexes_Address_Unknown::new(client.clone(), format!("{base_path}_unknown")),
opreturn: MetricsTree_Indexes_Address_Opreturn::new(client.clone(), format!("{base_path}_opreturn")),
op_return: MetricsTree_Indexes_Address_OpReturn::new(client.clone(), format!("{base_path}_op_return")),
}
}
}
@@ -4606,12 +4604,14 @@ impl MetricsTree_Indexes_Address {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2pk33 {
pub identity: MetricPattern26<P2PK33AddressIndex>,
pub address: MetricPattern26<Address>,
}
impl MetricsTree_Indexes_Address_P2pk33 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern26::new(client.clone(), "p2pk33_address_index".to_string()),
address: MetricPattern26::new(client.clone(), "p2pk33_address".to_string()),
}
}
}
@@ -4619,12 +4619,14 @@ impl MetricsTree_Indexes_Address_P2pk33 {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2pk65 {
pub identity: MetricPattern27<P2PK65AddressIndex>,
pub address: MetricPattern27<Address>,
}
impl MetricsTree_Indexes_Address_P2pk65 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern27::new(client.clone(), "p2pk65_address_index".to_string()),
address: MetricPattern27::new(client.clone(), "p2pk65_address".to_string()),
}
}
}
@@ -4632,12 +4634,14 @@ impl MetricsTree_Indexes_Address_P2pk65 {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2pkh {
pub identity: MetricPattern28<P2PKHAddressIndex>,
pub address: MetricPattern28<Address>,
}
impl MetricsTree_Indexes_Address_P2pkh {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern28::new(client.clone(), "p2pkh_address_index".to_string()),
address: MetricPattern28::new(client.clone(), "p2pkh_address".to_string()),
}
}
}
@@ -4645,12 +4649,14 @@ impl MetricsTree_Indexes_Address_P2pkh {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2sh {
pub identity: MetricPattern29<P2SHAddressIndex>,
pub address: MetricPattern29<Address>,
}
impl MetricsTree_Indexes_Address_P2sh {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern29::new(client.clone(), "p2sh_address_index".to_string()),
address: MetricPattern29::new(client.clone(), "p2sh_address".to_string()),
}
}
}
@@ -4658,12 +4664,14 @@ impl MetricsTree_Indexes_Address_P2sh {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2tr {
pub identity: MetricPattern30<P2TRAddressIndex>,
pub address: MetricPattern30<Address>,
}
impl MetricsTree_Indexes_Address_P2tr {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern30::new(client.clone(), "p2tr_address_index".to_string()),
address: MetricPattern30::new(client.clone(), "p2tr_address".to_string()),
}
}
}
@@ -4671,12 +4679,14 @@ impl MetricsTree_Indexes_Address_P2tr {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2wpkh {
pub identity: MetricPattern31<P2WPKHAddressIndex>,
pub address: MetricPattern31<Address>,
}
impl MetricsTree_Indexes_Address_P2wpkh {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern31::new(client.clone(), "p2wpkh_address_index".to_string()),
address: MetricPattern31::new(client.clone(), "p2wpkh_address".to_string()),
}
}
}
@@ -4684,12 +4694,14 @@ impl MetricsTree_Indexes_Address_P2wpkh {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2wsh {
pub identity: MetricPattern32<P2WSHAddressIndex>,
pub address: MetricPattern32<Address>,
}
impl MetricsTree_Indexes_Address_P2wsh {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern32::new(client.clone(), "p2wsh_address_index".to_string()),
address: MetricPattern32::new(client.clone(), "p2wsh_address".to_string()),
}
}
}
@@ -4697,12 +4709,14 @@ impl MetricsTree_Indexes_Address_P2wsh {
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_P2a {
pub identity: MetricPattern24<P2AAddressIndex>,
pub address: MetricPattern24<Address>,
}
impl MetricsTree_Indexes_Address_P2a {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern24::new(client.clone(), "p2a_address_index".to_string()),
address: MetricPattern24::new(client.clone(), "p2a_address".to_string()),
}
}
}
@@ -4747,11 +4761,11 @@ impl MetricsTree_Indexes_Address_Unknown {
}
/// Metrics tree node.
pub struct MetricsTree_Indexes_Address_Opreturn {
pub struct MetricsTree_Indexes_Address_OpReturn {
pub identity: MetricPattern23<OpReturnIndex>,
}
impl MetricsTree_Indexes_Address_Opreturn {
impl MetricsTree_Indexes_Address_OpReturn {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern23::new(client.clone(), "op_return_index".to_string()),
@@ -4845,8 +4859,8 @@ pub struct MetricsTree_Indexes_Minute10 {
impl MetricsTree_Indexes_Minute10 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern3::new(client.clone(), "minute10".to_string()),
first_height: MetricPattern3::new(client.clone(), "minute10_first_height".to_string()),
identity: MetricPattern3::new(client.clone(), "minute10_index".to_string()),
first_height: MetricPattern3::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4860,8 +4874,8 @@ pub struct MetricsTree_Indexes_Minute30 {
impl MetricsTree_Indexes_Minute30 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern4::new(client.clone(), "minute30".to_string()),
first_height: MetricPattern4::new(client.clone(), "minute30_first_height".to_string()),
identity: MetricPattern4::new(client.clone(), "minute30_index".to_string()),
first_height: MetricPattern4::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4875,8 +4889,8 @@ pub struct MetricsTree_Indexes_Hour1 {
impl MetricsTree_Indexes_Hour1 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern5::new(client.clone(), "hour1".to_string()),
first_height: MetricPattern5::new(client.clone(), "hour1_first_height".to_string()),
identity: MetricPattern5::new(client.clone(), "hour1_index".to_string()),
first_height: MetricPattern5::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4890,8 +4904,8 @@ pub struct MetricsTree_Indexes_Hour4 {
impl MetricsTree_Indexes_Hour4 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern6::new(client.clone(), "hour4".to_string()),
first_height: MetricPattern6::new(client.clone(), "hour4_first_height".to_string()),
identity: MetricPattern6::new(client.clone(), "hour4_index".to_string()),
first_height: MetricPattern6::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4905,8 +4919,8 @@ pub struct MetricsTree_Indexes_Hour12 {
impl MetricsTree_Indexes_Hour12 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern7::new(client.clone(), "hour12".to_string()),
first_height: MetricPattern7::new(client.clone(), "hour12_first_height".to_string()),
identity: MetricPattern7::new(client.clone(), "hour12_index".to_string()),
first_height: MetricPattern7::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4922,7 +4936,7 @@ pub struct MetricsTree_Indexes_Day1 {
impl MetricsTree_Indexes_Day1 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern8::new(client.clone(), "day1".to_string()),
identity: MetricPattern8::new(client.clone(), "day1_index".to_string()),
date: MetricPattern8::new(client.clone(), "date".to_string()),
first_height: MetricPattern8::new(client.clone(), "first_height".to_string()),
height_count: MetricPattern8::new(client.clone(), "height_count".to_string()),
@@ -4939,8 +4953,8 @@ pub struct MetricsTree_Indexes_Day3 {
impl MetricsTree_Indexes_Day3 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern9::new(client.clone(), "day3".to_string()),
first_height: MetricPattern9::new(client.clone(), "day3_first_height".to_string()),
identity: MetricPattern9::new(client.clone(), "day3_index".to_string()),
first_height: MetricPattern9::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4955,9 +4969,9 @@ pub struct MetricsTree_Indexes_Week1 {
impl MetricsTree_Indexes_Week1 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern10::new(client.clone(), "week1".to_string()),
identity: MetricPattern10::new(client.clone(), "week1_index".to_string()),
date: MetricPattern10::new(client.clone(), "date".to_string()),
first_height: MetricPattern10::new(client.clone(), "week1_first_height".to_string()),
first_height: MetricPattern10::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4972,9 +4986,9 @@ pub struct MetricsTree_Indexes_Month1 {
impl MetricsTree_Indexes_Month1 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern11::new(client.clone(), "month1".to_string()),
identity: MetricPattern11::new(client.clone(), "month1_index".to_string()),
date: MetricPattern11::new(client.clone(), "date".to_string()),
first_height: MetricPattern11::new(client.clone(), "month1_first_height".to_string()),
first_height: MetricPattern11::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -4989,9 +5003,9 @@ pub struct MetricsTree_Indexes_Month3 {
impl MetricsTree_Indexes_Month3 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern12::new(client.clone(), "month3".to_string()),
identity: MetricPattern12::new(client.clone(), "month3_index".to_string()),
date: MetricPattern12::new(client.clone(), "date".to_string()),
first_height: MetricPattern12::new(client.clone(), "month3_first_height".to_string()),
first_height: MetricPattern12::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -5006,9 +5020,9 @@ pub struct MetricsTree_Indexes_Month6 {
impl MetricsTree_Indexes_Month6 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern13::new(client.clone(), "month6".to_string()),
identity: MetricPattern13::new(client.clone(), "month6_index".to_string()),
date: MetricPattern13::new(client.clone(), "date".to_string()),
first_height: MetricPattern13::new(client.clone(), "month6_first_height".to_string()),
first_height: MetricPattern13::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -5023,9 +5037,9 @@ pub struct MetricsTree_Indexes_Year1 {
impl MetricsTree_Indexes_Year1 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern14::new(client.clone(), "year1".to_string()),
identity: MetricPattern14::new(client.clone(), "year1_index".to_string()),
date: MetricPattern14::new(client.clone(), "date".to_string()),
first_height: MetricPattern14::new(client.clone(), "year1_first_height".to_string()),
first_height: MetricPattern14::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -5040,9 +5054,9 @@ pub struct MetricsTree_Indexes_Year10 {
impl MetricsTree_Indexes_Year10 {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
identity: MetricPattern15::new(client.clone(), "year10".to_string()),
identity: MetricPattern15::new(client.clone(), "year10_index".to_string()),
date: MetricPattern15::new(client.clone(), "date".to_string()),
first_height: MetricPattern15::new(client.clone(), "year10_first_height".to_string()),
first_height: MetricPattern15::new(client.clone(), "first_height".to_string()),
}
}
}
@@ -6436,14 +6450,14 @@ impl MetricsTree_Supply {
/// Metrics tree node.
pub struct MetricsTree_Supply_Burned {
pub opreturn: BaseCumulativeSumPattern4,
pub op_return: BaseCumulativeSumPattern4,
pub unspendable: BaseCumulativeSumPattern4,
}
impl MetricsTree_Supply_Burned {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
opreturn: BaseCumulativeSumPattern4::new(client.clone(), "opreturn_supply".to_string()),
op_return: BaseCumulativeSumPattern4::new(client.clone(), "op_return_supply".to_string()),
unspendable: BaseCumulativeSumPattern4::new(client.clone(), "unspendable_supply".to_string()),
}
}

View File

@@ -24,7 +24,7 @@ impl<T> ByType<T> {
OutputType::P2A => &self.spendable.p2a,
OutputType::Empty => &self.spendable.empty,
OutputType::Unknown => &self.spendable.unknown,
OutputType::OpReturn => &self.unspendable.opreturn,
OutputType::OpReturn => &self.unspendable.op_return,
}
}
@@ -41,7 +41,7 @@ impl<T> ByType<T> {
OutputType::P2A => &mut self.spendable.p2a,
OutputType::Unknown => &mut self.spendable.unknown,
OutputType::Empty => &mut self.spendable.empty,
OutputType::OpReturn => &mut self.unspendable.opreturn,
OutputType::OpReturn => &mut self.unspendable.op_return,
}
}
}

View File

@@ -4,12 +4,12 @@ use brk_traversable::Traversable;
#[derive(Default, Clone, Debug, Traversable)]
pub struct UnspendableType<T> {
pub opreturn: T,
pub op_return: T,
}
impl<T> UnspendableType<T> {
pub fn as_vec(&self) -> [&T; 1] {
[&self.opreturn]
[&self.op_return]
}
}
@@ -20,7 +20,7 @@ where
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self {
opreturn: self.opreturn + rhs.opreturn,
op_return: self.op_return + rhs.op_return,
}
}
}
@@ -30,6 +30,6 @@ where
T: AddAssign,
{
fn add_assign(&mut self, rhs: Self) {
self.opreturn += rhs.opreturn;
self.op_return += rhs.op_return;
}
}

View File

@@ -42,14 +42,19 @@ impl Vecs {
);
Ok(Self {
base: Resolutions::forced_import(
value: Resolutions::forced_import(
"difficulty",
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
version,
indexes,
),
as_hash,
adjustment: PercentPerBlock::forced_import(db, "difficulty_adjustment", version, indexes)?,
adjustment: PercentPerBlock::forced_import(
db,
"difficulty_adjustment",
version,
indexes,
)?,
epoch: PerBlock::forced_import(db, "difficulty_epoch", version, indexes)?,
blocks_before_next,
days_before_next,

View File

@@ -297,7 +297,7 @@ impl CostBasisFenwick {
if total <= 0 {
0
} else {
(range as f64 / total as f64 * 10000.0) as u16
(range as f64 / total as f64 * 10000.0).round() as u16
}
};

View File

@@ -461,4 +461,34 @@ impl RealizedState {
}
Cents::new((self.peak_regret_raw / Sats::ONE_BTC_U128) as u64)
}
/// Raw profit value created for lossless aggregation.
#[inline]
pub(crate) fn profit_value_created_raw(&self) -> u128 {
self.profit_value_created_raw
}
/// Raw profit value destroyed for lossless aggregation.
#[inline]
pub(crate) fn profit_value_destroyed_raw(&self) -> u128 {
self.profit_value_destroyed_raw
}
/// Raw loss value created for lossless aggregation.
#[inline]
pub(crate) fn loss_value_created_raw(&self) -> u128 {
self.loss_value_created_raw
}
/// Raw loss value destroyed for lossless aggregation.
#[inline]
pub(crate) fn loss_value_destroyed_raw(&self) -> u128 {
self.loss_value_destroyed_raw
}
/// Raw peak regret for lossless aggregation.
#[inline]
pub(crate) fn peak_regret_raw(&self) -> u128 {
self.peak_regret_raw
}
}

View File

@@ -1,10 +1,11 @@
use brk_indexer::Indexer;
use brk_traversable::Traversable;
use brk_types::{
EmptyOutputIndex, OpReturnIndex, P2AAddressIndex, P2ABytes, P2MSOutputIndex,
P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex,
P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex,
P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, TxIndex, UnknownOutputIndex, Version,
Address, AddressBytes, EmptyOutputIndex, OpReturnIndex, P2AAddressIndex, P2ABytes,
P2MSOutputIndex, P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes,
P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes,
P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, TxIndex, UnknownOutputIndex,
Version,
};
use vecdb::{LazyVecFrom1, ReadableCloneableVec};
@@ -21,50 +22,58 @@ pub struct Vecs {
pub p2ms: P2MSVecs,
pub empty: EmptyVecs,
pub unknown: UnknownVecs,
pub opreturn: OpReturnVecs,
pub op_return: OpReturnVecs,
}
#[derive(Clone, Traversable)]
pub struct P2PK33Vecs {
pub identity:
LazyVecFrom1<P2PK33AddressIndex, P2PK33AddressIndex, P2PK33AddressIndex, P2PK33Bytes>,
pub address: LazyVecFrom1<P2PK33AddressIndex, Address, P2PK33AddressIndex, P2PK33Bytes>,
}
#[derive(Clone, Traversable)]
pub struct P2PK65Vecs {
pub identity:
LazyVecFrom1<P2PK65AddressIndex, P2PK65AddressIndex, P2PK65AddressIndex, P2PK65Bytes>,
pub address: LazyVecFrom1<P2PK65AddressIndex, Address, P2PK65AddressIndex, P2PK65Bytes>,
}
#[derive(Clone, Traversable)]
pub struct P2PKHVecs {
pub identity: LazyVecFrom1<P2PKHAddressIndex, P2PKHAddressIndex, P2PKHAddressIndex, P2PKHBytes>,
pub address: LazyVecFrom1<P2PKHAddressIndex, Address, P2PKHAddressIndex, P2PKHBytes>,
}
#[derive(Clone, Traversable)]
pub struct P2SHVecs {
pub identity: LazyVecFrom1<P2SHAddressIndex, P2SHAddressIndex, P2SHAddressIndex, P2SHBytes>,
pub address: LazyVecFrom1<P2SHAddressIndex, Address, P2SHAddressIndex, P2SHBytes>,
}
#[derive(Clone, Traversable)]
pub struct P2TRVecs {
pub identity: LazyVecFrom1<P2TRAddressIndex, P2TRAddressIndex, P2TRAddressIndex, P2TRBytes>,
pub address: LazyVecFrom1<P2TRAddressIndex, Address, P2TRAddressIndex, P2TRBytes>,
}
#[derive(Clone, Traversable)]
pub struct P2WPKHVecs {
pub identity:
LazyVecFrom1<P2WPKHAddressIndex, P2WPKHAddressIndex, P2WPKHAddressIndex, P2WPKHBytes>,
pub address: LazyVecFrom1<P2WPKHAddressIndex, Address, P2WPKHAddressIndex, P2WPKHBytes>,
}
#[derive(Clone, Traversable)]
pub struct P2WSHVecs {
pub identity: LazyVecFrom1<P2WSHAddressIndex, P2WSHAddressIndex, P2WSHAddressIndex, P2WSHBytes>,
pub address: LazyVecFrom1<P2WSHAddressIndex, Address, P2WSHAddressIndex, P2WSHBytes>,
}
#[derive(Clone, Traversable)]
pub struct P2AVecs {
pub identity: LazyVecFrom1<P2AAddressIndex, P2AAddressIndex, P2AAddressIndex, P2ABytes>,
pub address: LazyVecFrom1<P2AAddressIndex, Address, P2AAddressIndex, P2ABytes>,
}
#[derive(Clone, Traversable)]
@@ -97,6 +106,12 @@ impl Vecs {
indexer.vecs.addresses.p2pk33.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2pk33_address",
version,
indexer.vecs.addresses.p2pk33.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2pk65: P2PK65Vecs {
identity: LazyVecFrom1::init(
@@ -105,6 +120,12 @@ impl Vecs {
indexer.vecs.addresses.p2pk65.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2pk65_address",
version,
indexer.vecs.addresses.p2pk65.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2pkh: P2PKHVecs {
identity: LazyVecFrom1::init(
@@ -113,6 +134,12 @@ impl Vecs {
indexer.vecs.addresses.p2pkh.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2pkh_address",
version,
indexer.vecs.addresses.p2pkh.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2sh: P2SHVecs {
identity: LazyVecFrom1::init(
@@ -121,6 +148,12 @@ impl Vecs {
indexer.vecs.addresses.p2sh.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2sh_address",
version,
indexer.vecs.addresses.p2sh.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2tr: P2TRVecs {
identity: LazyVecFrom1::init(
@@ -129,6 +162,12 @@ impl Vecs {
indexer.vecs.addresses.p2tr.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2tr_address",
version,
indexer.vecs.addresses.p2tr.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2wpkh: P2WPKHVecs {
identity: LazyVecFrom1::init(
@@ -137,6 +176,12 @@ impl Vecs {
indexer.vecs.addresses.p2wpkh.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2wpkh_address",
version,
indexer.vecs.addresses.p2wpkh.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2wsh: P2WSHVecs {
identity: LazyVecFrom1::init(
@@ -145,6 +190,12 @@ impl Vecs {
indexer.vecs.addresses.p2wsh.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2wsh_address",
version,
indexer.vecs.addresses.p2wsh.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2a: P2AVecs {
identity: LazyVecFrom1::init(
@@ -153,6 +204,12 @@ impl Vecs {
indexer.vecs.addresses.p2a.bytes.read_only_boxed_clone(),
|index, _| index,
),
address: LazyVecFrom1::init(
"p2a_address",
version,
indexer.vecs.addresses.p2a.bytes.read_only_boxed_clone(),
|_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(),
),
},
p2ms: P2MSVecs {
identity: LazyVecFrom1::init(
@@ -186,14 +243,14 @@ impl Vecs {
|index, _| index,
),
},
opreturn: OpReturnVecs {
op_return: OpReturnVecs {
identity: LazyVecFrom1::init(
"op_return_index",
version,
indexer
.vecs
.scripts
.opreturn.to_tx_index
.op_return.to_tx_index
.read_only_boxed_clone(),
|index, _| index,
),

View File

@@ -35,12 +35,12 @@ impl Vecs {
starting_indexes.height,
&self.total.full.cumulative,
&inputs_count.full.cumulative,
&scripts_count.opreturn.cumulative.height,
|(h, output_count, input_count, opreturn_count, ..)| {
&scripts_count.op_return.cumulative.height,
|(h, output_count, input_count, op_return_count, ..)| {
let block_count = u64::from(h + 1_usize);
// -1 > genesis output is unspendable
let mut utxo_count =
*output_count - (*input_count - block_count) - *opreturn_count - 1;
*output_count - (*input_count - block_count) - *op_return_count - 1;
// txid dup: e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468
// Block 91_722 https://mempool.space/block/00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e

View File

@@ -102,12 +102,12 @@ impl Vecs {
)?)
})?;
self.opreturn
self.op_return
.compute(starting_indexes.height, exit, |v| {
Ok(v.compute_count_from_indexes(
starting_indexes.height,
&indexer.vecs.scripts.opreturn.first_index,
&indexer.vecs.scripts.opreturn.to_tx_index,
&indexer.vecs.scripts.op_return.first_index,
&indexer.vecs.scripts.op_return.to_tx_index,
exit,
)?)
})?;

View File

@@ -46,9 +46,9 @@ impl Vecs {
p2tr,
p2wpkh,
p2wsh,
opreturn: PerBlockCumulativeWithSums::forced_import(
op_return: PerBlockCumulativeWithSums::forced_import(
db,
"opreturn_count",
"op_return_count",
version,
indexes,
cached_starts,

View File

@@ -15,7 +15,7 @@ pub struct Vecs<M: StorageMode = Rw> {
pub p2tr: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub p2wpkh: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub p2wsh: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub opreturn: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub op_return: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub empty_output: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
pub unknown_output: PerBlockCumulativeWithSums<StoredU64, StoredU64, M>,

View File

@@ -14,7 +14,7 @@ impl Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
self.opreturn.compute_with(
self.op_return.compute_with(
starting_indexes.height,
prices,
exit,
@@ -81,14 +81,14 @@ impl Vecs {
.value
.collect_range_into_at(out_start, out_end, &mut values_buf);
let mut opreturn_value = Sats::ZERO;
let mut op_return_value = Sats::ZERO;
for (ot, val) in output_types_buf.iter().zip(values_buf.iter()) {
if *ot == OutputType::OpReturn {
opreturn_value += *val;
op_return_value += *val;
}
}
height_vec.truncate_push(height, opreturn_value)?;
height_vec.truncate_push(height, op_return_value)?;
}
height_vec.write()?;

View File

@@ -12,9 +12,9 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
opreturn: AmountPerBlockCumulative::forced_import(
op_return: AmountPerBlockCumulative::forced_import(
db,
"opreturn_value",
"op_return_value",
version,
indexes,
)?,

View File

@@ -5,5 +5,5 @@ use crate::internal::AmountPerBlockCumulative;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub opreturn: AmountPerBlockCumulative<M>,
pub op_return: AmountPerBlockCumulative<M>,
}

View File

@@ -14,18 +14,18 @@ impl Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
self.opreturn.compute(
self.op_return.compute(
starting_indexes.height,
prices,
exit,
|height_vec| {
// Validate computed versions against dependencies
let opreturn_dep_version = scripts.value.opreturn.base.sats.height.version();
height_vec.validate_computed_version_or_reset(opreturn_dep_version)?;
let op_return_dep_version = scripts.value.op_return.base.sats.height.version();
height_vec.validate_computed_version_or_reset(op_return_dep_version)?;
// Copy per-block opreturn values from scripts
let scripts_target = scripts.value.opreturn.base.sats.height.len();
// Copy per-block op_return values from scripts
let scripts_target = scripts.value.op_return.base.sats.height.len();
if scripts_target > 0 {
let target_height = Height::from(scripts_target - 1);
let current_len = height_vec.len();
@@ -35,7 +35,7 @@ impl Vecs {
if starting_height <= target_height {
let start = starting_height.to_usize();
let end = target_height.to_usize() + 1;
scripts.value.opreturn.base.sats.height.fold_range_at(
scripts.value.op_return.base.sats.height.fold_range_at(
start,
end,
start,
@@ -52,9 +52,9 @@ impl Vecs {
},
)?;
// 2. Compute unspendable supply = opreturn + unclaimed_rewards + genesis (at height 0)
// Get reference to opreturn height vec for computing unspendable
let opreturn_height = &self.opreturn.base.sats.height;
// 2. Compute unspendable supply = op_return + unclaimed_rewards + genesis (at height 0)
// Get reference to op_return height vec for computing unspendable
let op_return_height = &self.op_return.base.sats.height;
let unclaimed_height = &mining.rewards.unclaimed.base.sats.height;
self.unspendable.compute(
@@ -63,12 +63,12 @@ impl Vecs {
exit,
|height_vec| {
let unspendable_dep_version =
opreturn_height.version() + unclaimed_height.version();
op_return_height.version() + unclaimed_height.version();
height_vec.validate_computed_version_or_reset(unspendable_dep_version)?;
let opreturn_target = opreturn_height.len();
if opreturn_target > 0 {
let target_height = Height::from(opreturn_target - 1);
let op_return_target = op_return_height.len();
if op_return_target > 0 {
let target_height = Height::from(op_return_target - 1);
let current_len = height_vec.len();
let starting_height =
Height::from(current_len.min(starting_indexes.height.to_usize()));
@@ -77,14 +77,14 @@ impl Vecs {
let start = starting_height.to_usize();
let end = target_height.to_usize() + 1;
let unclaimed_data = unclaimed_height.collect_range_at(start, end);
opreturn_height.fold_range_at(start, end, start, |idx, opreturn| {
op_return_height.fold_range_at(start, end, start, |idx, op_return| {
let unclaimed = unclaimed_data[idx - start];
let genesis = if idx == 0 {
Sats::FIFTY_BTC
} else {
Sats::ZERO
};
let unspendable = genesis + opreturn + unclaimed;
let unspendable = genesis + op_return + unclaimed;
height_vec
.truncate_push(Height::from(idx), unspendable)
.unwrap();

View File

@@ -13,9 +13,9 @@ impl Vecs {
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
Ok(Self {
opreturn: AmountPerBlockCumulativeWithSums::forced_import(
op_return: AmountPerBlockCumulativeWithSums::forced_import(
db,
"opreturn_supply",
"op_return_supply",
version,
indexes,
cached_starts,

View File

@@ -5,6 +5,6 @@ use crate::internal::AmountPerBlockCumulativeWithSums;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub opreturn: AmountPerBlockCumulativeWithSums<M>,
pub op_return: AmountPerBlockCumulativeWithSums<M>,
pub unspendable: AmountPerBlockCumulativeWithSums<M>,
}

View File

@@ -36,7 +36,7 @@ impl IndexesExt for Indexes {
.p2ms.first_index
.checked_push(height, self.p2ms_output_index)?;
vecs.scripts
.opreturn.first_index
.op_return.first_index
.checked_push(height, self.op_return_index)?;
vecs.addresses
.p2a.first_index
@@ -110,8 +110,8 @@ impl IndexesExt for Indexes {
)?;
let op_return_index = starting_index(
&vecs.scripts.opreturn.first_index,
&vecs.scripts.opreturn.to_tx_index,
&vecs.scripts.op_return.first_index,
&vecs.scripts.op_return.to_tx_index,
starting_height,
)?;

View File

@@ -174,7 +174,7 @@ pub(super) fn finalize_outputs(
}
OutputType::OpReturn => {
scripts
.opreturn.to_tx_index
.op_return.to_tx_index
.checked_push(indexes.op_return_index, tx_index)?;
indexes.op_return_index.copy_then_increment()
}

View File

@@ -22,7 +22,7 @@ pub struct ScriptTypeVecs<I: VecIndex + PcoVecValue + Formattable + Serialize +
#[derive(Traversable)]
pub struct ScriptsVecs<M: StorageMode = Rw> {
pub empty: ScriptTypeVecs<EmptyOutputIndex, M>,
pub opreturn: ScriptTypeVecs<OpReturnIndex, M>,
pub op_return: ScriptTypeVecs<OpReturnIndex, M>,
pub p2ms: ScriptTypeVecs<P2MSOutputIndex, M>,
pub unknown: ScriptTypeVecs<UnknownOutputIndex, M>,
}
@@ -50,7 +50,7 @@ impl ScriptsVecs {
};
Ok(Self {
empty: ScriptTypeVecs { first_index: first_empty_output_index, to_tx_index: empty_output_index_to_tx_index },
opreturn: ScriptTypeVecs { first_index: first_op_return_index, to_tx_index: op_return_index_to_tx_index },
op_return: ScriptTypeVecs { first_index: first_op_return_index, to_tx_index: op_return_index_to_tx_index },
p2ms: ScriptTypeVecs { first_index: first_p2ms_output_index, to_tx_index: p2ms_output_index_to_tx_index },
unknown: ScriptTypeVecs { first_index: first_unknown_output_index, to_tx_index: unknown_output_index_to_tx_index },
})
@@ -67,7 +67,7 @@ impl ScriptsVecs {
) -> Result<()> {
self.empty.first_index
.truncate_if_needed_with_stamp(height, stamp)?;
self.opreturn.first_index
self.op_return.first_index
.truncate_if_needed_with_stamp(height, stamp)?;
self.p2ms.first_index
.truncate_if_needed_with_stamp(height, stamp)?;
@@ -75,7 +75,7 @@ impl ScriptsVecs {
.truncate_if_needed_with_stamp(height, stamp)?;
self.empty.to_tx_index
.truncate_if_needed_with_stamp(empty_output_index, stamp)?;
self.opreturn.to_tx_index
self.op_return.to_tx_index
.truncate_if_needed_with_stamp(op_return_index, stamp)?;
self.p2ms.to_tx_index
.truncate_if_needed_with_stamp(p2ms_output_index, stamp)?;
@@ -87,11 +87,11 @@ impl ScriptsVecs {
pub fn par_iter_mut_any(&mut self) -> impl ParallelIterator<Item = &mut dyn AnyStoredVec> {
[
&mut self.empty.first_index as &mut dyn AnyStoredVec,
&mut self.opreturn.first_index,
&mut self.op_return.first_index,
&mut self.p2ms.first_index,
&mut self.unknown.first_index,
&mut self.empty.to_tx_index,
&mut self.opreturn.to_tx_index,
&mut self.op_return.to_tx_index,
&mut self.p2ms.to_tx_index,
&mut self.unknown.to_tx_index,
]

View File

@@ -5,13 +5,14 @@ use brk_error::Error;
use derive_more::Deref;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize, Serializer};
use vecdb::Formattable;
use crate::AddressBytes;
use super::OutputType;
/// Bitcoin address string
#[derive(Debug, Deref, Deserialize, JsonSchema)]
#[derive(Debug, Clone, Deref, Deserialize, JsonSchema)]
#[serde(transparent)]
#[schemars(
example = &"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f",
@@ -99,3 +100,15 @@ impl Address {
AddressBytes::address_to_script(&self.0)
}
}
impl Formattable for Address {
fn write_to(&self, buf: &mut Vec<u8>) {
buf.extend_from_slice(self.0.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
}

View File

@@ -1,5 +1,5 @@
use derive_more::{Deref, DerefMut};
use schemars::JsonSchema;
use schemars::{JsonSchema, SchemaGenerator};
use serde::{Deserialize, Serialize};
use vecdb::Bytes;
@@ -99,9 +99,8 @@ impl JsonSchema for U8x33 {
"U8x33".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
// Represent as a byte string
String::json_schema(_gen)
fn json_schema(generator: &mut SchemaGenerator) -> schemars::Schema {
Vec::<u8>::json_schema(generator)
}
}
@@ -135,9 +134,8 @@ impl JsonSchema for U8x65 {
"U8x65".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
// Represent as a byte string
String::json_schema(_gen)
fn json_schema(generator: &mut SchemaGenerator) -> schemars::Schema {
Vec::<u8>::json_schema(generator)
}
}

View File

@@ -72,7 +72,7 @@ impl PrintableIndex for OpReturnIndex {
}
fn to_possible_strings() -> &'static [&'static str] {
&["op", "opreturn", "op_return_index"]
&["op", "opreturn", "op_return", "op_return_index"]
}
}

View File

@@ -900,8 +900,8 @@
/** @typedef {number[]} U8x2 */
/** @typedef {number[]} U8x20 */
/** @typedef {number[]} U8x32 */
/** @typedef {string} U8x33 */
/** @typedef {string} U8x65 */
/** @typedef {number[]} U8x33 */
/** @typedef {number[]} U8x65 */
/** @typedef {TypeIndex} UnknownOutputIndex */
/**
* Unspent transaction output
@@ -4075,8 +4075,7 @@ function createUnspentPattern(client, acc) {
/**
* @typedef {Object} MetricsTree_Blocks_Difficulty
* @property {MetricPattern18<StoredF64>} raw
* @property {MetricPattern2<StoredF64>} base
* @property {MetricPattern1<StoredF64>} value
* @property {MetricPattern1<StoredF64>} asHash
* @property {BpsPercentRatioPattern} adjustment
* @property {MetricPattern1<Epoch>} epoch
@@ -4440,7 +4439,7 @@ function createUnspentPattern(client, acc) {
/**
* @typedef {Object} MetricsTree_Scripts_Raw
* @property {MetricsTree_Scripts_Raw_Empty} empty
* @property {MetricsTree_Scripts_Raw_Opreturn} opreturn
* @property {MetricsTree_Scripts_Raw_OpReturn} opReturn
* @property {MetricsTree_Scripts_Raw_P2ms} p2ms
* @property {MetricsTree_Scripts_Raw_Unknown} unknown
*/
@@ -4452,7 +4451,7 @@ function createUnspentPattern(client, acc) {
*/
/**
* @typedef {Object} MetricsTree_Scripts_Raw_Opreturn
* @typedef {Object} MetricsTree_Scripts_Raw_OpReturn
* @property {MetricPattern18<OpReturnIndex>} firstIndex
* @property {MetricPattern23<TxIndex>} toTxIndex
*/
@@ -4480,7 +4479,7 @@ function createUnspentPattern(client, acc) {
* @property {BaseCumulativeSumPattern<StoredU64>} p2tr
* @property {BaseCumulativeSumPattern<StoredU64>} p2wpkh
* @property {BaseCumulativeSumPattern<StoredU64>} p2wsh
* @property {BaseCumulativeSumPattern<StoredU64>} opreturn
* @property {BaseCumulativeSumPattern<StoredU64>} opReturn
* @property {BaseCumulativeSumPattern<StoredU64>} emptyOutput
* @property {BaseCumulativeSumPattern<StoredU64>} unknownOutput
* @property {BaseCumulativeSumPattern<StoredU64>} segwit
@@ -4488,11 +4487,11 @@ function createUnspentPattern(client, acc) {
/**
* @typedef {Object} MetricsTree_Scripts_Value
* @property {MetricsTree_Scripts_Value_Opreturn} opreturn
* @property {MetricsTree_Scripts_Value_OpReturn} opReturn
*/
/**
* @typedef {Object} MetricsTree_Scripts_Value_Opreturn
* @typedef {Object} MetricsTree_Scripts_Value_OpReturn
* @property {BtcCentsSatsUsdPattern} base
* @property {BtcCentsSatsUsdPattern} cumulative
*/
@@ -4700,47 +4699,55 @@ function createUnspentPattern(client, acc) {
* @property {MetricsTree_Indexes_Address_P2ms} p2ms
* @property {MetricsTree_Indexes_Address_Empty} empty
* @property {MetricsTree_Indexes_Address_Unknown} unknown
* @property {MetricsTree_Indexes_Address_Opreturn} opreturn
* @property {MetricsTree_Indexes_Address_OpReturn} opReturn
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2pk33
* @property {MetricPattern26<P2PK33AddressIndex>} identity
* @property {MetricPattern26<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2pk65
* @property {MetricPattern27<P2PK65AddressIndex>} identity
* @property {MetricPattern27<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2pkh
* @property {MetricPattern28<P2PKHAddressIndex>} identity
* @property {MetricPattern28<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2sh
* @property {MetricPattern29<P2SHAddressIndex>} identity
* @property {MetricPattern29<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2tr
* @property {MetricPattern30<P2TRAddressIndex>} identity
* @property {MetricPattern30<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2wpkh
* @property {MetricPattern31<P2WPKHAddressIndex>} identity
* @property {MetricPattern31<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2wsh
* @property {MetricPattern32<P2WSHAddressIndex>} identity
* @property {MetricPattern32<Address>} address
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_P2a
* @property {MetricPattern24<P2AAddressIndex>} identity
* @property {MetricPattern24<Address>} address
*/
/**
@@ -4759,7 +4766,7 @@ function createUnspentPattern(client, acc) {
*/
/**
* @typedef {Object} MetricsTree_Indexes_Address_Opreturn
* @typedef {Object} MetricsTree_Indexes_Address_OpReturn
* @property {MetricPattern23<OpReturnIndex>} identity
*/
@@ -5508,7 +5515,7 @@ function createUnspentPattern(client, acc) {
/**
* @typedef {Object} MetricsTree_Supply_Burned
* @property {BaseCumulativeSumPattern4} opreturn
* @property {BaseCumulativeSumPattern4} opReturn
* @property {BaseCumulativeSumPattern4} unspendable
*/
@@ -6909,8 +6916,7 @@ class BrkClient extends BrkClientBase {
blocks: {
blockhash: createMetricPattern18(this, 'blockhash'),
difficulty: {
raw: createMetricPattern18(this, 'difficulty'),
base: createMetricPattern2(this, 'difficulty'),
value: createMetricPattern1(this, 'difficulty'),
asHash: createMetricPattern1(this, 'difficulty_as_hash'),
adjustment: createBpsPercentRatioPattern(this, 'difficulty_adjustment'),
epoch: createMetricPattern1(this, 'difficulty_epoch'),
@@ -7174,7 +7180,7 @@ class BrkClient extends BrkClientBase {
firstIndex: createMetricPattern18(this, 'first_empty_output_index'),
toTxIndex: createMetricPattern22(this, 'tx_index'),
},
opreturn: {
opReturn: {
firstIndex: createMetricPattern18(this, 'first_op_return_index'),
toTxIndex: createMetricPattern23(this, 'tx_index'),
},
@@ -7197,15 +7203,15 @@ class BrkClient extends BrkClientBase {
p2tr: createBaseCumulativeSumPattern(this, 'p2tr_count'),
p2wpkh: createBaseCumulativeSumPattern(this, 'p2wpkh_count'),
p2wsh: createBaseCumulativeSumPattern(this, 'p2wsh_count'),
opreturn: createBaseCumulativeSumPattern(this, 'opreturn_count'),
opReturn: createBaseCumulativeSumPattern(this, 'op_return_count'),
emptyOutput: createBaseCumulativeSumPattern(this, 'empty_output_count'),
unknownOutput: createBaseCumulativeSumPattern(this, 'unknown_output_count'),
segwit: createBaseCumulativeSumPattern(this, 'segwit_count'),
},
value: {
opreturn: {
base: createBtcCentsSatsUsdPattern(this, 'opreturn_value'),
cumulative: createBtcCentsSatsUsdPattern(this, 'opreturn_value_cumulative'),
opReturn: {
base: createBtcCentsSatsUsdPattern(this, 'op_return_value'),
cumulative: createBtcCentsSatsUsdPattern(this, 'op_return_value_cumulative'),
},
},
adoption: {
@@ -7329,27 +7335,35 @@ class BrkClient extends BrkClientBase {
address: {
p2pk33: {
identity: createMetricPattern26(this, 'p2pk33_address_index'),
address: createMetricPattern26(this, 'p2pk33_address'),
},
p2pk65: {
identity: createMetricPattern27(this, 'p2pk65_address_index'),
address: createMetricPattern27(this, 'p2pk65_address'),
},
p2pkh: {
identity: createMetricPattern28(this, 'p2pkh_address_index'),
address: createMetricPattern28(this, 'p2pkh_address'),
},
p2sh: {
identity: createMetricPattern29(this, 'p2sh_address_index'),
address: createMetricPattern29(this, 'p2sh_address'),
},
p2tr: {
identity: createMetricPattern30(this, 'p2tr_address_index'),
address: createMetricPattern30(this, 'p2tr_address'),
},
p2wpkh: {
identity: createMetricPattern31(this, 'p2wpkh_address_index'),
address: createMetricPattern31(this, 'p2wpkh_address'),
},
p2wsh: {
identity: createMetricPattern32(this, 'p2wsh_address_index'),
address: createMetricPattern32(this, 'p2wsh_address'),
},
p2a: {
identity: createMetricPattern24(this, 'p2a_address_index'),
address: createMetricPattern24(this, 'p2a_address'),
},
p2ms: {
identity: createMetricPattern25(this, 'p2ms_output_index'),
@@ -7360,7 +7374,7 @@ class BrkClient extends BrkClientBase {
unknown: {
identity: createMetricPattern33(this, 'unknown_output_index'),
},
opreturn: {
opReturn: {
identity: createMetricPattern23(this, 'op_return_index'),
},
},
@@ -7393,64 +7407,64 @@ class BrkClient extends BrkClientBase {
firstHeight: createMetricPattern16(this, 'first_height'),
},
minute10: {
identity: createMetricPattern3(this, 'minute10'),
firstHeight: createMetricPattern3(this, 'minute10_first_height'),
identity: createMetricPattern3(this, 'minute10_index'),
firstHeight: createMetricPattern3(this, 'first_height'),
},
minute30: {
identity: createMetricPattern4(this, 'minute30'),
firstHeight: createMetricPattern4(this, 'minute30_first_height'),
identity: createMetricPattern4(this, 'minute30_index'),
firstHeight: createMetricPattern4(this, 'first_height'),
},
hour1: {
identity: createMetricPattern5(this, 'hour1'),
firstHeight: createMetricPattern5(this, 'hour1_first_height'),
identity: createMetricPattern5(this, 'hour1_index'),
firstHeight: createMetricPattern5(this, 'first_height'),
},
hour4: {
identity: createMetricPattern6(this, 'hour4'),
firstHeight: createMetricPattern6(this, 'hour4_first_height'),
identity: createMetricPattern6(this, 'hour4_index'),
firstHeight: createMetricPattern6(this, 'first_height'),
},
hour12: {
identity: createMetricPattern7(this, 'hour12'),
firstHeight: createMetricPattern7(this, 'hour12_first_height'),
identity: createMetricPattern7(this, 'hour12_index'),
firstHeight: createMetricPattern7(this, 'first_height'),
},
day1: {
identity: createMetricPattern8(this, 'day1'),
identity: createMetricPattern8(this, 'day1_index'),
date: createMetricPattern8(this, 'date'),
firstHeight: createMetricPattern8(this, 'first_height'),
heightCount: createMetricPattern8(this, 'height_count'),
},
day3: {
identity: createMetricPattern9(this, 'day3'),
firstHeight: createMetricPattern9(this, 'day3_first_height'),
identity: createMetricPattern9(this, 'day3_index'),
firstHeight: createMetricPattern9(this, 'first_height'),
},
week1: {
identity: createMetricPattern10(this, 'week1'),
identity: createMetricPattern10(this, 'week1_index'),
date: createMetricPattern10(this, 'date'),
firstHeight: createMetricPattern10(this, 'week1_first_height'),
firstHeight: createMetricPattern10(this, 'first_height'),
},
month1: {
identity: createMetricPattern11(this, 'month1'),
identity: createMetricPattern11(this, 'month1_index'),
date: createMetricPattern11(this, 'date'),
firstHeight: createMetricPattern11(this, 'month1_first_height'),
firstHeight: createMetricPattern11(this, 'first_height'),
},
month3: {
identity: createMetricPattern12(this, 'month3'),
identity: createMetricPattern12(this, 'month3_index'),
date: createMetricPattern12(this, 'date'),
firstHeight: createMetricPattern12(this, 'month3_first_height'),
firstHeight: createMetricPattern12(this, 'first_height'),
},
month6: {
identity: createMetricPattern13(this, 'month6'),
identity: createMetricPattern13(this, 'month6_index'),
date: createMetricPattern13(this, 'date'),
firstHeight: createMetricPattern13(this, 'month6_first_height'),
firstHeight: createMetricPattern13(this, 'first_height'),
},
year1: {
identity: createMetricPattern14(this, 'year1'),
identity: createMetricPattern14(this, 'year1_index'),
date: createMetricPattern14(this, 'date'),
firstHeight: createMetricPattern14(this, 'year1_first_height'),
firstHeight: createMetricPattern14(this, 'first_height'),
},
year10: {
identity: createMetricPattern15(this, 'year10'),
identity: createMetricPattern15(this, 'year10_index'),
date: createMetricPattern15(this, 'date'),
firstHeight: createMetricPattern15(this, 'year10_first_height'),
firstHeight: createMetricPattern15(this, 'first_height'),
},
txIndex: {
identity: createMetricPattern19(this, 'tx_index'),
@@ -7936,7 +7950,7 @@ class BrkClient extends BrkClientBase {
supply: {
circulating: createBtcCentsSatsUsdPattern(this, 'circulating_supply'),
burned: {
opreturn: createBaseCumulativeSumPattern4(this, 'opreturn_supply'),
opReturn: createBaseCumulativeSumPattern4(this, 'op_return_supply'),
unspendable: createBaseCumulativeSumPattern4(this, 'unspendable_supply'),
},
inflationRate: createBpsPercentRatioPattern(this, 'inflation_rate'),

View File

@@ -134,10 +134,10 @@ U8x2 = List[int]
P2ABytes = U8x2
P2MSOutputIndex = TypeIndex
P2PK33AddressIndex = TypeIndex
U8x33 = str
U8x33 = List[int]
P2PK33Bytes = U8x33
P2PK65AddressIndex = TypeIndex
U8x65 = str
U8x65 = List[int]
P2PK65Bytes = U8x65
P2PKHAddressIndex = TypeIndex
U8x20 = List[int]
@@ -3190,8 +3190,7 @@ class MetricsTree_Blocks_Difficulty:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.raw: MetricPattern18[StoredF64] = MetricPattern18(client, 'difficulty')
self.base: MetricPattern2[StoredF64] = MetricPattern2(client, 'difficulty')
self.value: MetricPattern1[StoredF64] = MetricPattern1(client, 'difficulty')
self.as_hash: MetricPattern1[StoredF64] = MetricPattern1(client, 'difficulty_as_hash')
self.adjustment: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'difficulty_adjustment')
self.epoch: MetricPattern1[Epoch] = MetricPattern1(client, 'difficulty_epoch')
@@ -3602,7 +3601,7 @@ class MetricsTree_Scripts_Raw_Empty:
self.first_index: MetricPattern18[EmptyOutputIndex] = MetricPattern18(client, 'first_empty_output_index')
self.to_tx_index: MetricPattern22[TxIndex] = MetricPattern22(client, 'tx_index')
class MetricsTree_Scripts_Raw_Opreturn:
class MetricsTree_Scripts_Raw_OpReturn:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -3628,7 +3627,7 @@ class MetricsTree_Scripts_Raw:
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.empty: MetricsTree_Scripts_Raw_Empty = MetricsTree_Scripts_Raw_Empty(client)
self.opreturn: MetricsTree_Scripts_Raw_Opreturn = MetricsTree_Scripts_Raw_Opreturn(client)
self.op_return: MetricsTree_Scripts_Raw_OpReturn = MetricsTree_Scripts_Raw_OpReturn(client)
self.p2ms: MetricsTree_Scripts_Raw_P2ms = MetricsTree_Scripts_Raw_P2ms(client)
self.unknown: MetricsTree_Scripts_Raw_Unknown = MetricsTree_Scripts_Raw_Unknown(client)
@@ -3645,23 +3644,23 @@ class MetricsTree_Scripts_Count:
self.p2tr: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2tr_count')
self.p2wpkh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wpkh_count')
self.p2wsh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wsh_count')
self.opreturn: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'opreturn_count')
self.op_return: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'op_return_count')
self.empty_output: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'empty_output_count')
self.unknown_output: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'unknown_output_count')
self.segwit: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'segwit_count')
class MetricsTree_Scripts_Value_Opreturn:
class MetricsTree_Scripts_Value_OpReturn:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'opreturn_value')
self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'opreturn_value_cumulative')
self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'op_return_value')
self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'op_return_value_cumulative')
class MetricsTree_Scripts_Value:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.opreturn: MetricsTree_Scripts_Value_Opreturn = MetricsTree_Scripts_Value_Opreturn(client)
self.op_return: MetricsTree_Scripts_Value_OpReturn = MetricsTree_Scripts_Value_OpReturn(client)
class MetricsTree_Scripts_Adoption:
"""Metrics tree node."""
@@ -3861,48 +3860,56 @@ class MetricsTree_Indexes_Address_P2pk33:
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern26[P2PK33AddressIndex] = MetricPattern26(client, 'p2pk33_address_index')
self.address: MetricPattern26[Address] = MetricPattern26(client, 'p2pk33_address')
class MetricsTree_Indexes_Address_P2pk65:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern27[P2PK65AddressIndex] = MetricPattern27(client, 'p2pk65_address_index')
self.address: MetricPattern27[Address] = MetricPattern27(client, 'p2pk65_address')
class MetricsTree_Indexes_Address_P2pkh:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern28[P2PKHAddressIndex] = MetricPattern28(client, 'p2pkh_address_index')
self.address: MetricPattern28[Address] = MetricPattern28(client, 'p2pkh_address')
class MetricsTree_Indexes_Address_P2sh:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern29[P2SHAddressIndex] = MetricPattern29(client, 'p2sh_address_index')
self.address: MetricPattern29[Address] = MetricPattern29(client, 'p2sh_address')
class MetricsTree_Indexes_Address_P2tr:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern30[P2TRAddressIndex] = MetricPattern30(client, 'p2tr_address_index')
self.address: MetricPattern30[Address] = MetricPattern30(client, 'p2tr_address')
class MetricsTree_Indexes_Address_P2wpkh:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern31[P2WPKHAddressIndex] = MetricPattern31(client, 'p2wpkh_address_index')
self.address: MetricPattern31[Address] = MetricPattern31(client, 'p2wpkh_address')
class MetricsTree_Indexes_Address_P2wsh:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern32[P2WSHAddressIndex] = MetricPattern32(client, 'p2wsh_address_index')
self.address: MetricPattern32[Address] = MetricPattern32(client, 'p2wsh_address')
class MetricsTree_Indexes_Address_P2a:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern24[P2AAddressIndex] = MetricPattern24(client, 'p2a_address_index')
self.address: MetricPattern24[Address] = MetricPattern24(client, 'p2a_address')
class MetricsTree_Indexes_Address_P2ms:
"""Metrics tree node."""
@@ -3922,7 +3929,7 @@ class MetricsTree_Indexes_Address_Unknown:
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern33[UnknownOutputIndex] = MetricPattern33(client, 'unknown_output_index')
class MetricsTree_Indexes_Address_Opreturn:
class MetricsTree_Indexes_Address_OpReturn:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
@@ -3943,7 +3950,7 @@ class MetricsTree_Indexes_Address:
self.p2ms: MetricsTree_Indexes_Address_P2ms = MetricsTree_Indexes_Address_P2ms(client)
self.empty: MetricsTree_Indexes_Address_Empty = MetricsTree_Indexes_Address_Empty(client)
self.unknown: MetricsTree_Indexes_Address_Unknown = MetricsTree_Indexes_Address_Unknown(client)
self.opreturn: MetricsTree_Indexes_Address_Opreturn = MetricsTree_Indexes_Address_Opreturn(client)
self.op_return: MetricsTree_Indexes_Address_OpReturn = MetricsTree_Indexes_Address_OpReturn(client)
class MetricsTree_Indexes_Height:
"""Metrics tree node."""
@@ -3986,42 +3993,42 @@ class MetricsTree_Indexes_Minute10:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern3[Minute10] = MetricPattern3(client, 'minute10')
self.first_height: MetricPattern3[Height] = MetricPattern3(client, 'minute10_first_height')
self.identity: MetricPattern3[Minute10] = MetricPattern3(client, 'minute10_index')
self.first_height: MetricPattern3[Height] = MetricPattern3(client, 'first_height')
class MetricsTree_Indexes_Minute30:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern4[Minute30] = MetricPattern4(client, 'minute30')
self.first_height: MetricPattern4[Height] = MetricPattern4(client, 'minute30_first_height')
self.identity: MetricPattern4[Minute30] = MetricPattern4(client, 'minute30_index')
self.first_height: MetricPattern4[Height] = MetricPattern4(client, 'first_height')
class MetricsTree_Indexes_Hour1:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern5[Hour1] = MetricPattern5(client, 'hour1')
self.first_height: MetricPattern5[Height] = MetricPattern5(client, 'hour1_first_height')
self.identity: MetricPattern5[Hour1] = MetricPattern5(client, 'hour1_index')
self.first_height: MetricPattern5[Height] = MetricPattern5(client, 'first_height')
class MetricsTree_Indexes_Hour4:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern6[Hour4] = MetricPattern6(client, 'hour4')
self.first_height: MetricPattern6[Height] = MetricPattern6(client, 'hour4_first_height')
self.identity: MetricPattern6[Hour4] = MetricPattern6(client, 'hour4_index')
self.first_height: MetricPattern6[Height] = MetricPattern6(client, 'first_height')
class MetricsTree_Indexes_Hour12:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern7[Hour12] = MetricPattern7(client, 'hour12')
self.first_height: MetricPattern7[Height] = MetricPattern7(client, 'hour12_first_height')
self.identity: MetricPattern7[Hour12] = MetricPattern7(client, 'hour12_index')
self.first_height: MetricPattern7[Height] = MetricPattern7(client, 'first_height')
class MetricsTree_Indexes_Day1:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern8[Day1] = MetricPattern8(client, 'day1')
self.identity: MetricPattern8[Day1] = MetricPattern8(client, 'day1_index')
self.date: MetricPattern8[Date] = MetricPattern8(client, 'date')
self.first_height: MetricPattern8[Height] = MetricPattern8(client, 'first_height')
self.height_count: MetricPattern8[StoredU64] = MetricPattern8(client, 'height_count')
@@ -4030,56 +4037,56 @@ class MetricsTree_Indexes_Day3:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern9[Day3] = MetricPattern9(client, 'day3')
self.first_height: MetricPattern9[Height] = MetricPattern9(client, 'day3_first_height')
self.identity: MetricPattern9[Day3] = MetricPattern9(client, 'day3_index')
self.first_height: MetricPattern9[Height] = MetricPattern9(client, 'first_height')
class MetricsTree_Indexes_Week1:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern10[Week1] = MetricPattern10(client, 'week1')
self.identity: MetricPattern10[Week1] = MetricPattern10(client, 'week1_index')
self.date: MetricPattern10[Date] = MetricPattern10(client, 'date')
self.first_height: MetricPattern10[Height] = MetricPattern10(client, 'week1_first_height')
self.first_height: MetricPattern10[Height] = MetricPattern10(client, 'first_height')
class MetricsTree_Indexes_Month1:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern11[Month1] = MetricPattern11(client, 'month1')
self.identity: MetricPattern11[Month1] = MetricPattern11(client, 'month1_index')
self.date: MetricPattern11[Date] = MetricPattern11(client, 'date')
self.first_height: MetricPattern11[Height] = MetricPattern11(client, 'month1_first_height')
self.first_height: MetricPattern11[Height] = MetricPattern11(client, 'first_height')
class MetricsTree_Indexes_Month3:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern12[Month3] = MetricPattern12(client, 'month3')
self.identity: MetricPattern12[Month3] = MetricPattern12(client, 'month3_index')
self.date: MetricPattern12[Date] = MetricPattern12(client, 'date')
self.first_height: MetricPattern12[Height] = MetricPattern12(client, 'month3_first_height')
self.first_height: MetricPattern12[Height] = MetricPattern12(client, 'first_height')
class MetricsTree_Indexes_Month6:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern13[Month6] = MetricPattern13(client, 'month6')
self.identity: MetricPattern13[Month6] = MetricPattern13(client, 'month6_index')
self.date: MetricPattern13[Date] = MetricPattern13(client, 'date')
self.first_height: MetricPattern13[Height] = MetricPattern13(client, 'month6_first_height')
self.first_height: MetricPattern13[Height] = MetricPattern13(client, 'first_height')
class MetricsTree_Indexes_Year1:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern14[Year1] = MetricPattern14(client, 'year1')
self.identity: MetricPattern14[Year1] = MetricPattern14(client, 'year1_index')
self.date: MetricPattern14[Date] = MetricPattern14(client, 'date')
self.first_height: MetricPattern14[Height] = MetricPattern14(client, 'year1_first_height')
self.first_height: MetricPattern14[Height] = MetricPattern14(client, 'first_height')
class MetricsTree_Indexes_Year10:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.identity: MetricPattern15[Year10] = MetricPattern15(client, 'year10')
self.identity: MetricPattern15[Year10] = MetricPattern15(client, 'year10_index')
self.date: MetricPattern15[Date] = MetricPattern15(client, 'date')
self.first_height: MetricPattern15[Height] = MetricPattern15(client, 'year10_first_height')
self.first_height: MetricPattern15[Height] = MetricPattern15(client, 'first_height')
class MetricsTree_Indexes_TxIndex:
"""Metrics tree node."""
@@ -4767,7 +4774,7 @@ class MetricsTree_Supply_Burned:
"""Metrics tree node."""
def __init__(self, client: BrkClientBase, base_path: str = ''):
self.opreturn: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'opreturn_supply')
self.op_return: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'op_return_supply')
self.unspendable: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'unspendable_supply')
class MetricsTree_Supply_Velocity:

View File

@@ -2,8 +2,7 @@
import { colors } from "../utils/colors.js";
import { brk } from "../client.js";
import { Unit } from "../utils/units.js";
import { baseline, price } from "./series.js";
import { percentRatioBaseline, price } from "./series.js";
import { satsBtcUsd } from "./shared.js";
import { periodIdToName } from "./utils.js";
@@ -31,7 +30,7 @@ const LONG_PERIODS = /** @type {const} */ ([
/**
* Add CAGR to a base entry item
* @param {BaseEntryItem} entry
* @param {AnyMetricPattern} cagr
* @param {PercentRatioPattern} cagr
* @returns {LongEntryItem}
*/
const withCagr = (entry, cagr) => ({ ...entry, cagr });
@@ -47,19 +46,23 @@ const YEARS_2010S = /** @type {const} */ ([2019, 2018, 2017, 2016, 2015]);
/** @param {AllPeriodKey} key */
const periodName = (key) => periodIdToName(key.slice(1), true);
/**
* @typedef {{ percent: AnyMetricPattern, ratio: AnyMetricPattern }} PercentRatioPattern
*/
/**
* Base entry item for compare and single-entry charts
* @typedef {Object} BaseEntryItem
* @property {string} name - Display name
* @property {Color} color - Item color
* @property {AnyPricePattern} costBasis - Cost basis metric
* @property {AnyMetricPattern} returns - Returns metric
* @property {PercentRatioPattern} returns - Returns metric
* @property {AnyValuePattern} stack - Stack pattern
*/
/**
* Long-term entry item with CAGR
* @typedef {BaseEntryItem & { cagr: AnyMetricPattern }} LongEntryItem
* @typedef {BaseEntryItem & { cagr: PercentRatioPattern }} LongEntryItem
*/
const ALL_YEARS = /** @type {const} */ ([...YEARS_2020S, ...YEARS_2010S]);
@@ -77,7 +80,7 @@ function buildYearEntry(dca, year, i) {
name: `${year}`,
color: colors.at(i, ALL_YEARS.length),
costBasis: dca.class.costBasis[key],
returns: dca.class.return[key].ratio,
returns: dca.class.return[key],
stack: dca.class.stack[key],
};
}
@@ -122,12 +125,11 @@ function createCompareFolder(context, items) {
name: "Returns",
title: `Returns: ${context}`,
top: topPane,
bottom: items.map(({ name, color, returns }) =>
baseline({
metric: returns,
bottom: items.flatMap(({ name, color, returns }) =>
percentRatioBaseline({
pattern: returns,
name,
color: [color, color],
unit: Unit.percentage,
}),
),
},
@@ -176,9 +178,7 @@ function createSingleEntryTree(item, returnsBottom) {
* @param {BaseEntryItem & { titlePrefix?: string }} item
*/
function createShortSingleEntry(item) {
return createSingleEntryTree(item, [
baseline({ metric: item.returns, name: "Current", unit: Unit.percentage }),
]);
return createSingleEntryTree(item, percentRatioBaseline({ pattern: item.returns, name: "Current" }));
}
/**
@@ -187,8 +187,8 @@ function createShortSingleEntry(item) {
*/
function createLongSingleEntry(item) {
return createSingleEntryTree(item, [
baseline({ metric: item.returns, name: "Current", unit: Unit.percentage }),
baseline({ metric: item.cagr, name: "CAGR", unit: Unit.cagr }),
...percentRatioBaseline({ pattern: item.returns, name: "Current" }),
...percentRatioBaseline({ pattern: item.cagr, name: "CAGR" }),
]);
}
@@ -223,16 +223,14 @@ export function createDcaVsLumpSumSection({ dca, lookback, returns }) {
title: `Returns: ${name} DCA vs Lump Sum`,
top: topPane(key),
bottom: [
baseline({
metric: dca.period.return[key].ratio,
...percentRatioBaseline({
pattern: dca.period.return[key],
name: "DCA",
unit: Unit.percentage,
}),
baseline({
metric: dca.period.lumpSumReturn[key].ratio,
...percentRatioBaseline({
pattern: dca.period.lumpSumReturn[key],
name: "Lump Sum",
color: colors.bi.p2,
unit: Unit.percentage,
}),
],
});
@@ -243,27 +241,23 @@ export function createDcaVsLumpSumSection({ dca, lookback, returns }) {
title: `Returns: ${name} DCA vs Lump Sum`,
top: topPane(key),
bottom: [
baseline({
metric: dca.period.return[key].ratio,
...percentRatioBaseline({
pattern: dca.period.return[key],
name: "DCA",
unit: Unit.percentage,
}),
baseline({
metric: dca.period.lumpSumReturn[key].ratio,
...percentRatioBaseline({
pattern: dca.period.lumpSumReturn[key],
name: "Lump Sum",
color: colors.bi.p2,
unit: Unit.percentage,
}),
baseline({
metric: dca.period.cagr[key].ratio,
...percentRatioBaseline({
pattern: dca.period.cagr[key],
name: "DCA CAGR",
unit: Unit.cagr,
}),
baseline({
metric: returns.cagr[key].ratio,
...percentRatioBaseline({
pattern: returns.cagr[key],
name: "Lump Sum CAGR",
color: colors.bi.p2,
unit: Unit.cagr,
}),
],
});
@@ -350,8 +344,8 @@ function createPeriodSection({ dca, lookback, returns }) {
color: colors.at(i, allPeriods.length),
costBasis: isLumpSum ? lookback[key] : dca.period.costBasis[key],
returns: isLumpSum
? dca.period.lumpSumReturn[key].ratio
: dca.period.return[key].ratio,
? dca.period.lumpSumReturn[key]
: dca.period.return[key],
stack: isLumpSum
? dca.period.lumpSumStack[key]
: dca.period.stack[key],
@@ -361,7 +355,7 @@ function createPeriodSection({ dca, lookback, returns }) {
const buildLongEntry = (key, i) =>
withCagr(
buildBaseEntry(key, i),
isLumpSum ? returns.cagr[key].ratio : dca.period.cagr[key].ratio,
isLumpSum ? returns.cagr[key] : dca.period.cagr[key],
);
/** @param {BaseEntryItem} entry */

View File

@@ -122,21 +122,18 @@ function returnsSubSection(name, periods) {
{
name: "Compare",
title: `${name} Returns`,
bottom: periods.map((p) =>
baseline({
metric: p.returns,
bottom: periods.flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
name: p.id,
color: p.color,
unit: Unit.percentage,
}),
),
},
...periods.map((p) => ({
name: periodIdToName(p.id, true),
title: `${periodIdToName(p.id, true)} Returns`,
bottom: [
baseline({ metric: p.returns, name: "Total", unit: Unit.percentage }),
],
bottom: percentRatioBaseline({ pattern: p.returns, name: "Total" }),
})),
],
};
@@ -153,12 +150,11 @@ function returnsSubSectionWithCagr(name, periods) {
{
name: "Compare",
title: `${name} Returns`,
bottom: periods.map((p) =>
baseline({
metric: p.returns,
bottom: periods.flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
name: p.id,
color: p.color,
unit: Unit.percentage,
}),
),
},
@@ -166,8 +162,8 @@ function returnsSubSectionWithCagr(name, periods) {
name: periodIdToName(p.id, true),
title: `${periodIdToName(p.id, true)} Returns`,
bottom: [
baseline({ metric: p.returns, name: "Total", unit: Unit.percentage }),
baseline({ metric: p.cagr, name: "annual", unit: Unit.cagr }),
...percentRatioBaseline({ pattern: p.returns, name: "Total" }),
...percentRatioBaseline({ pattern: p.cagr, name: "annual" }),
],
})),
],
@@ -216,70 +212,70 @@ export function createMarketSection() {
} = market;
const shortPeriodsBase = [
{ id: "24h", returns: returns.periods._24h.ratio, lookback: lookback._24h },
{ id: "1w", returns: returns.periods._1w.ratio, lookback: lookback._1w },
{ id: "1m", returns: returns.periods._1m.ratio, lookback: lookback._1m },
{ id: "24h", returns: returns.periods._24h, lookback: lookback._24h },
{ id: "1w", returns: returns.periods._1w, lookback: lookback._1w },
{ id: "1m", returns: returns.periods._1m, lookback: lookback._1m },
{
id: "3m",
returns: returns.periods._3m.ratio,
returns: returns.periods._3m,
lookback: lookback._3m,
defaultActive: false,
},
{
id: "6m",
returns: returns.periods._6m.ratio,
returns: returns.periods._6m,
lookback: lookback._6m,
defaultActive: false,
},
{ id: "1y", returns: returns.periods._1y.ratio, lookback: lookback._1y },
{ id: "1y", returns: returns.periods._1y, lookback: lookback._1y },
];
const longPeriodsBase = [
{
id: "2y",
returns: returns.periods._2y.ratio,
cagr: returns.cagr._2y.ratio,
returns: returns.periods._2y,
cagr: returns.cagr._2y,
lookback: lookback._2y,
defaultActive: false,
},
{
id: "3y",
returns: returns.periods._3y.ratio,
cagr: returns.cagr._3y.ratio,
returns: returns.periods._3y,
cagr: returns.cagr._3y,
lookback: lookback._3y,
defaultActive: false,
},
{
id: "4y",
returns: returns.periods._4y.ratio,
cagr: returns.cagr._4y.ratio,
returns: returns.periods._4y,
cagr: returns.cagr._4y,
lookback: lookback._4y,
},
{
id: "5y",
returns: returns.periods._5y.ratio,
cagr: returns.cagr._5y.ratio,
returns: returns.periods._5y,
cagr: returns.cagr._5y,
lookback: lookback._5y,
defaultActive: false,
},
{
id: "6y",
returns: returns.periods._6y.ratio,
cagr: returns.cagr._6y.ratio,
returns: returns.periods._6y,
cagr: returns.cagr._6y,
lookback: lookback._6y,
defaultActive: false,
},
{
id: "8y",
returns: returns.periods._8y.ratio,
cagr: returns.cagr._8y.ratio,
returns: returns.periods._8y,
cagr: returns.cagr._8y,
lookback: lookback._8y,
defaultActive: false,
},
{
id: "10y",
returns: returns.periods._10y.ratio,
cagr: returns.cagr._10y.ratio,
returns: returns.periods._10y,
cagr: returns.cagr._10y,
lookback: lookback._10y,
defaultActive: false,
},
@@ -426,11 +422,10 @@ export function createMarketSection() {
name: "Growth Rate",
title: "Capitalization Growth Rate",
bottom: [
line({
metric: supply.marketCap.delta.rate._24h.percent,
...percentRatio({
pattern: supply.marketCap.delta.rate._24h,
name: "Market Cap (24h)",
color: colors.bitcoin,
unit: Unit.percentage,
}),
baseline({
metric: supply.marketMinusRealizedCapGrowthRate._24h,
@@ -493,12 +488,11 @@ export function createMarketSection() {
{
name: "Compare",
title: "Returns Comparison",
bottom: [...shortPeriods, ...longPeriods].map((p) =>
baseline({
metric: p.returns,
bottom: [...shortPeriods, ...longPeriods].flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
name: p.id,
color: p.color,
unit: Unit.percentage,
defaultActive: p.defaultActive,
}),
),

View File

@@ -320,7 +320,7 @@ export function createMiningSection() {
title: "Mining Difficulty",
bottom: [
line({
metric: blocks.difficulty.raw,
metric: blocks.difficulty.value,
name: "Difficulty",
unit: Unit.difficulty,
}),

View File

@@ -58,9 +58,9 @@ export function createNetworkSection() {
const nonAddressableTypes = /** @type {const} */ ([
{ key: "p2ms", name: "P2MS", color: st.p2ms, defaultActive: false },
{
key: "opreturn",
key: "opReturn",
name: "OP_RETURN",
color: st.opreturn,
color: st.opReturn,
defaultActive: false,
},
{
@@ -568,7 +568,7 @@ export function createNetworkSection() {
name: "Base",
title: "OP_RETURN Burned",
bottom: satsBtcUsd({
pattern: supply.burned.opreturn.base,
pattern: supply.burned.opReturn.base,
name: "sum",
}),
},
@@ -580,7 +580,7 @@ export function createNetworkSection() {
title: "OP_RETURN Burned Rolling",
bottom: ROLLING_WINDOWS.flatMap((w) =>
satsBtcUsd({
pattern: supply.burned.opreturn.sum[w.key],
pattern: supply.burned.opReturn.sum[w.key],
name: w.name,
color: w.color,
}),
@@ -590,7 +590,7 @@ export function createNetworkSection() {
name: w.name,
title: `OP_RETURN Burned ${w.name}`,
bottom: satsBtcUsd({
pattern: supply.burned.opreturn.sum[w.key],
pattern: supply.burned.opReturn.sum[w.key],
name: w.name,
color: w.color,
}),
@@ -601,7 +601,7 @@ export function createNetworkSection() {
name: "Cumulative",
title: "OP_RETURN Burned (Total)",
bottom: satsBtcUsd({
pattern: supply.burned.opreturn.cumulative,
pattern: supply.burned.opReturn.cumulative,
name: "all-time",
}),
},
@@ -1035,7 +1035,7 @@ export function createNetworkSection() {
title: "Mining Difficulty",
bottom: [
line({
metric: blocks.difficulty.base,
metric: blocks.difficulty.value,
name: "Difficulty",
unit: Unit.count,
}),

View File

@@ -640,7 +640,7 @@ export function percentRatioDots({ pattern, name, color, defaultActive }) {
* @param {Object} args
* @param {{ percent: AnyMetricPattern, ratio: AnyMetricPattern }} args.pattern
* @param {string} args.name
* @param {Color} [args.color]
* @param {Color | [Color, Color]} [args.color]
* @param {boolean} [args.defaultActive]
* @returns {AnyFetchedSeriesBlueprint[]}
*/

View File

@@ -254,7 +254,7 @@ export const colors = {
p2wsh: palette.yellow,
p2tr: palette.cyan,
p2a: palette.indigo,
opreturn: palette.purple,
opReturn: palette.purple,
unknown: palette.violet,
empty: palette.fuchsia,
},