mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-01 22:39:03 -07:00
global: snapshot
This commit is contained in:
@@ -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()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)?)
|
||||
})?;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
@@ -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,
|
||||
)?,
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
]
|
||||
|
||||
@@ -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'"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user