diff --git a/Cargo.lock b/Cargo.lock index 84fd85adb..39667a140 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -799,9 +799,9 @@ checksum = "1c53ba0f290bfc610084c05582d9c5d421662128fc69f4bf236707af6fd321b9" [[package]] name = "cc" -version = "1.2.56" +version = "1.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" dependencies = [ "find-msvc-tools", "jobserver", @@ -1292,9 +1292,9 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fjall" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40cb1eb0cef3792900897b32c8282f6417bc978f6af46400a2f14bf0e649ae30" +checksum = "48cf071a6f6090e99f3e095aaca9d38f78ad6fcf40bca736dc4cf7cbe15e4438" dependencies = [ "byteorder-lite", "byteview", @@ -1302,7 +1302,7 @@ dependencies = [ "flume", "log", "lsm-tree", - "lz4_flex 0.11.5", + "lz4_flex 0.11.6", "tempfile", "xxhash-rust", ] @@ -2000,9 +2000,9 @@ checksum = "803ec87c9cfb29b9d2633f20cba1f488db3fd53f2158b1024cbefb47ba05d413" [[package]] name = "libc" -version = "0.2.182" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libloading" @@ -2080,9 +2080,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lsm-tree" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5fa40c207eed45c811085aaa1b0a25fead22e298e286081cd4b98785fe759b" +checksum = "e97484b43ad0b232eaaeb83ee6edbf5d2e3602a389eee4205997b4ad3f6d3ace" dependencies = [ "byteorder-lite", "byteview", @@ -2090,7 +2090,7 @@ dependencies = [ "enum_dispatch", "interval-heap", "log", - "lz4_flex 0.11.5", + "lz4_flex 0.11.6", "quick_cache", "rustc-hash", "self_cell", @@ -2102,18 +2102,18 @@ dependencies = [ [[package]] name = "lz4_flex" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ab2867e3eeeca90e844d1940eab391c9dc5228783db2ed999acbc0a9ed375a" +checksum = "373f5eceeeab7925e0c1098212f2fbc4d416adec9d35051a6ab251e824c1854a" dependencies = [ "twox-hash", ] [[package]] name = "lz4_flex" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab6473172471198271ff72e9379150e9dfd70d8e533e0752a27e515b48dd375e" +checksum = "db9a0d582c2874f68138a16ce1867e0ffde6c0bb0a0df85e1f36d04146db488a" [[package]] name = "matchit" @@ -2241,9 +2241,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "option-ext" @@ -2402,9 +2402,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" +checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" dependencies = [ "portable-atomic", ] @@ -2976,12 +2976,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3056,9 +3056,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.26.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom 0.4.2", @@ -3318,9 +3318,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ "sharded-slab", "thread_local", @@ -3439,7 +3439,7 @@ dependencies = [ "itoa", "libc", "log", - "lz4_flex 0.12.0", + "lz4_flex 0.13.0", "parking_lot", "pco", "rawdb", @@ -3701,16 +3701,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -3728,31 +3719,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -3761,96 +3735,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "0.7.15" @@ -4002,18 +3928,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.40" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.40" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4d1eac46a..998bc6234 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ color-eyre = "0.6.5" corepc-client = { path = "/Users/k/Developer/corepc/client", features = ["client-sync"] } corepc-jsonrpc = { package = "jsonrpc", path = "/Users/k/Developer/corepc/jsonrpc", features = ["simple_http"], default-features = false } derive_more = { version = "2.1.1", features = ["deref", "deref_mut"] } -fjall = "3.1.0" +fjall = "3.1.1" indexmap = { version = "2.13.0", features = ["serde"] } jiff = { version = "0.2.23", features = ["perf-inline", "tz-system"], default-features = false } owo-colors = "4.3.0" diff --git a/crates/brk_client/examples/tree.rs b/crates/brk_client/examples/tree.rs index 2de441f94..9293ba02e 100644 --- a/crates/brk_client/examples/tree.rs +++ b/crates/brk_client/examples/tree.rs @@ -45,7 +45,7 @@ fn main() -> brk_client::Result<()> { let client = BrkClient::new("http://localhost:3110"); // Get the metrics catalog tree - let tree = client.get_metrics_tree()?; + let tree = client.get_series_tree()?; // Recursively collect all metrics let metrics = collect_metrics(&tree, ""); @@ -58,7 +58,7 @@ fn main() -> brk_client::Result<()> { let index_str = index.name(); let full_path = format!("{}.by.{}", metric.path, index_str); - match client.get_metric( + match client.get_series( metric.name.as_str().into(), *index, None, diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index f8aeda3ea..46d93afb3 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -382,18 +382,18 @@ const _I20: &[Index] = &[Index::TxInIndex]; const _I21: &[Index] = &[Index::TxOutIndex]; const _I22: &[Index] = &[Index::EmptyOutputIndex]; const _I23: &[Index] = &[Index::OpReturnIndex]; -const _I24: &[Index] = &[Index::P2AAddressIndex]; +const _I24: &[Index] = &[Index::P2AAddrIndex]; const _I25: &[Index] = &[Index::P2MSOutputIndex]; -const _I26: &[Index] = &[Index::P2PK33AddressIndex]; -const _I27: &[Index] = &[Index::P2PK65AddressIndex]; -const _I28: &[Index] = &[Index::P2PKHAddressIndex]; -const _I29: &[Index] = &[Index::P2SHAddressIndex]; -const _I30: &[Index] = &[Index::P2TRAddressIndex]; -const _I31: &[Index] = &[Index::P2WPKHAddressIndex]; -const _I32: &[Index] = &[Index::P2WSHAddressIndex]; +const _I26: &[Index] = &[Index::P2PK33AddrIndex]; +const _I27: &[Index] = &[Index::P2PK65AddrIndex]; +const _I28: &[Index] = &[Index::P2PKHAddrIndex]; +const _I29: &[Index] = &[Index::P2SHAddrIndex]; +const _I30: &[Index] = &[Index::P2TRAddrIndex]; +const _I31: &[Index] = &[Index::P2WPKHAddrIndex]; +const _I32: &[Index] = &[Index::P2WSHAddrIndex]; const _I33: &[Index] = &[Index::UnknownOutputIndex]; -const _I34: &[Index] = &[Index::FundedAddressIndex]; -const _I35: &[Index] = &[Index::EmptyAddressIndex]; +const _I34: &[Index] = &[Index::FundedAddrIndex]; +const _I35: &[Index] = &[Index::EmptyAddrIndex]; #[inline] fn _ep(c: &Arc, n: &Arc, i: Index) -> SeriesEndpoint { @@ -760,7 +760,7 @@ impl SeriesPattern for SeriesPattern23 { fn get(&self pub struct SeriesPattern24By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern24By { - pub fn p2a_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2AAddressIndex) } + pub fn p2a_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2AAddrIndex) } } pub struct SeriesPattern24 { name: Arc, pub by: SeriesPattern24By } @@ -788,7 +788,7 @@ impl SeriesPattern for SeriesPattern25 { fn get(&self pub struct SeriesPattern26By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern26By { - pub fn p2pk33_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK33AddressIndex) } + pub fn p2pk33_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK33AddrIndex) } } pub struct SeriesPattern26 { name: Arc, pub by: SeriesPattern26By } @@ -802,7 +802,7 @@ impl SeriesPattern for SeriesPattern26 { fn get(&self pub struct SeriesPattern27By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern27By { - pub fn p2pk65_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK65AddressIndex) } + pub fn p2pk65_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PK65AddrIndex) } } pub struct SeriesPattern27 { name: Arc, pub by: SeriesPattern27By } @@ -816,7 +816,7 @@ impl SeriesPattern for SeriesPattern27 { fn get(&self pub struct SeriesPattern28By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern28By { - pub fn p2pkh_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PKHAddressIndex) } + pub fn p2pkh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2PKHAddrIndex) } } pub struct SeriesPattern28 { name: Arc, pub by: SeriesPattern28By } @@ -830,7 +830,7 @@ impl SeriesPattern for SeriesPattern28 { fn get(&self pub struct SeriesPattern29By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern29By { - pub fn p2sh_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2SHAddressIndex) } + pub fn p2sh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2SHAddrIndex) } } pub struct SeriesPattern29 { name: Arc, pub by: SeriesPattern29By } @@ -844,7 +844,7 @@ impl SeriesPattern for SeriesPattern29 { fn get(&self pub struct SeriesPattern30By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern30By { - pub fn p2tr_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2TRAddressIndex) } + pub fn p2tr_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2TRAddrIndex) } } pub struct SeriesPattern30 { name: Arc, pub by: SeriesPattern30By } @@ -858,7 +858,7 @@ impl SeriesPattern for SeriesPattern30 { fn get(&self pub struct SeriesPattern31By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern31By { - pub fn p2wpkh_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WPKHAddressIndex) } + pub fn p2wpkh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WPKHAddrIndex) } } pub struct SeriesPattern31 { name: Arc, pub by: SeriesPattern31By } @@ -872,7 +872,7 @@ impl SeriesPattern for SeriesPattern31 { fn get(&self pub struct SeriesPattern32By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern32By { - pub fn p2wsh_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WSHAddressIndex) } + pub fn p2wsh_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::P2WSHAddrIndex) } } pub struct SeriesPattern32 { name: Arc, pub by: SeriesPattern32By } @@ -900,7 +900,7 @@ impl SeriesPattern for SeriesPattern33 { fn get(&self pub struct SeriesPattern34By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern34By { - pub fn funded_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::FundedAddressIndex) } + pub fn funded_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::FundedAddrIndex) } } pub struct SeriesPattern34 { name: Arc, pub by: SeriesPattern34By } @@ -914,7 +914,7 @@ impl SeriesPattern for SeriesPattern34 { fn get(&self pub struct SeriesPattern35By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl SeriesPattern35By { - pub fn empty_address_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::EmptyAddressIndex) } + pub fn empty_addr_index(&self) -> SeriesEndpoint { _ep(&self.client, &self.name, Index::EmptyAddrIndex) } } pub struct SeriesPattern35 { name: Arc, pub by: SeriesPattern35By } @@ -1677,19 +1677,19 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern { } /// Pattern struct for repeated tree structure. -pub struct AddressOutputsRealizedSupplyUnrealizedPattern { - pub address_count: BaseDeltaPattern, +pub struct AddrOutputsRealizedSupplyUnrealizedPattern { + pub addr_count: BaseDeltaPattern, pub outputs: UnspentPattern, pub realized: CapLossMvrvPriceProfitSoprPattern, pub supply: DeltaHalfTotalPattern, pub unrealized: NuplPattern, } -impl AddressOutputsRealizedSupplyUnrealizedPattern { +impl AddrOutputsRealizedSupplyUnrealizedPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - address_count: BaseDeltaPattern::new(client.clone(), _m(&acc, "address_count")), + addr_count: BaseDeltaPattern::new(client.clone(), _m(&acc, "addr_count")), outputs: UnspentPattern::new(client.clone(), _m(&acc, "utxo_count")), realized: CapLossMvrvPriceProfitSoprPattern::new(client.clone(), acc.clone()), supply: DeltaHalfTotalPattern::new(client.clone(), _m(&acc, "supply")), @@ -1700,22 +1700,22 @@ impl AddressOutputsRealizedSupplyUnrealizedPattern { /// Pattern struct for repeated tree structure. pub struct BaseCumulativeInSumPattern { - pub base: SeriesPattern1, - pub cumulative: SeriesPattern1, + pub base: BtcCentsSatsUsdPattern, + pub cumulative: BtcCentsSatsUsdPattern, pub in_loss: BaseCumulativeSumPattern4, pub in_profit: BaseCumulativeSumPattern4, - pub sum: _1m1w1y24hPattern, + pub sum: _1m1w1y24hPattern5, } impl BaseCumulativeInSumPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: SeriesPattern1::new(client.clone(), acc.clone()), - cumulative: SeriesPattern1::new(client.clone(), _m(&acc, "cumulative")), + base: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + cumulative: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "cumulative")), in_loss: BaseCumulativeSumPattern4::new(client.clone(), _m(&acc, "in_loss")), in_profit: BaseCumulativeSumPattern4::new(client.clone(), _m(&acc, "in_profit")), - sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sum")), + sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "sum")), } } } @@ -2906,9 +2906,10 @@ pub struct SeriesTree { pub transactions: SeriesTree_Transactions, pub inputs: SeriesTree_Inputs, pub outputs: SeriesTree_Outputs, - pub addresses: SeriesTree_Addresses, + pub addrs: SeriesTree_Addrs, pub scripts: SeriesTree_Scripts, pub mining: SeriesTree_Mining, + pub positions: SeriesTree_Positions, pub cointime: SeriesTree_Cointime, pub constants: SeriesTree_Constants, pub indexes: SeriesTree_Indexes, @@ -2927,9 +2928,10 @@ impl SeriesTree { transactions: SeriesTree_Transactions::new(client.clone(), format!("{base_path}_transactions")), inputs: SeriesTree_Inputs::new(client.clone(), format!("{base_path}_inputs")), outputs: SeriesTree_Outputs::new(client.clone(), format!("{base_path}_outputs")), - addresses: SeriesTree_Addresses::new(client.clone(), format!("{base_path}_addresses")), + addrs: SeriesTree_Addrs::new(client.clone(), format!("{base_path}_addrs")), scripts: SeriesTree_Scripts::new(client.clone(), format!("{base_path}_scripts")), mining: SeriesTree_Mining::new(client.clone(), format!("{base_path}_mining")), + positions: SeriesTree_Positions::new(client.clone(), format!("{base_path}_positions")), cointime: SeriesTree_Cointime::new(client.clone(), format!("{base_path}_cointime")), constants: SeriesTree_Constants::new(client.clone(), format!("{base_path}_constants")), indexes: SeriesTree_Indexes::new(client.clone(), format!("{base_path}_indexes")), @@ -3360,7 +3362,7 @@ pub struct SeriesTree_Transactions_Volume { impl SeriesTree_Transactions_Volume { pub fn new(client: Arc, base_path: String) -> Self { Self { - transfer_volume: BaseCumulativeSumPattern4::new(client.clone(), "exact_transfer_volume".to_string()), + transfer_volume: BaseCumulativeSumPattern4::new(client.clone(), "transfer_volume_bis".to_string()), output_volume: BaseCumulativeSumPattern4::new(client.clone(), "output_volume".to_string()), tx_per_sec: SeriesPattern1::new(client.clone(), "tx_per_sec".to_string()), outputs_per_sec: SeriesPattern1::new(client.clone(), "outputs_per_sec".to_string()), @@ -3483,235 +3485,235 @@ impl SeriesTree_Outputs_Count { pub fn new(client: Arc, base_path: String) -> Self { Self { total: AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern::new(client.clone(), "output_count".to_string()), - unspent: SeriesPattern1::new(client.clone(), "exact_utxo_count".to_string()), + unspent: SeriesPattern1::new(client.clone(), "utxo_count_bis".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses { - pub raw: SeriesTree_Addresses_Raw, - pub indexes: SeriesTree_Addresses_Indexes, - pub data: SeriesTree_Addresses_Data, +pub struct SeriesTree_Addrs { + pub raw: SeriesTree_Addrs_Raw, + pub indexes: SeriesTree_Addrs_Indexes, + pub data: SeriesTree_Addrs_Data, pub funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, pub empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, - pub activity: SeriesTree_Addresses_Activity, + pub activity: SeriesTree_Addrs_Activity, pub total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3, - pub new: SeriesTree_Addresses_New, - pub delta: SeriesTree_Addresses_Delta, + pub new: SeriesTree_Addrs_New, + pub delta: SeriesTree_Addrs_Delta, } -impl SeriesTree_Addresses { +impl SeriesTree_Addrs { pub fn new(client: Arc, base_path: String) -> Self { Self { - raw: SeriesTree_Addresses_Raw::new(client.clone(), format!("{base_path}_raw")), - indexes: SeriesTree_Addresses_Indexes::new(client.clone(), format!("{base_path}_indexes")), - data: SeriesTree_Addresses_Data::new(client.clone(), format!("{base_path}_data")), - funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "address_count".to_string()), - empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "empty_address_count".to_string()), - activity: SeriesTree_Addresses_Activity::new(client.clone(), format!("{base_path}_activity")), - total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "total_address_count".to_string()), - new: SeriesTree_Addresses_New::new(client.clone(), format!("{base_path}_new")), - delta: SeriesTree_Addresses_Delta::new(client.clone(), format!("{base_path}_delta")), + raw: SeriesTree_Addrs_Raw::new(client.clone(), format!("{base_path}_raw")), + indexes: SeriesTree_Addrs_Indexes::new(client.clone(), format!("{base_path}_indexes")), + data: SeriesTree_Addrs_Data::new(client.clone(), format!("{base_path}_data")), + funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "addr_count".to_string()), + empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "empty_addr_count".to_string()), + activity: SeriesTree_Addrs_Activity::new(client.clone(), format!("{base_path}_activity")), + total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3::new(client.clone(), "total_addr_count".to_string()), + new: SeriesTree_Addrs_New::new(client.clone(), format!("{base_path}_new")), + delta: SeriesTree_Addrs_Delta::new(client.clone(), format!("{base_path}_delta")), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw { - pub p2pk65: SeriesTree_Addresses_Raw_P2pk65, - pub p2pk33: SeriesTree_Addresses_Raw_P2pk33, - pub p2pkh: SeriesTree_Addresses_Raw_P2pkh, - pub p2sh: SeriesTree_Addresses_Raw_P2sh, - pub p2wpkh: SeriesTree_Addresses_Raw_P2wpkh, - pub p2wsh: SeriesTree_Addresses_Raw_P2wsh, - pub p2tr: SeriesTree_Addresses_Raw_P2tr, - pub p2a: SeriesTree_Addresses_Raw_P2a, +pub struct SeriesTree_Addrs_Raw { + pub p2pk65: SeriesTree_Addrs_Raw_P2pk65, + pub p2pk33: SeriesTree_Addrs_Raw_P2pk33, + pub p2pkh: SeriesTree_Addrs_Raw_P2pkh, + pub p2sh: SeriesTree_Addrs_Raw_P2sh, + pub p2wpkh: SeriesTree_Addrs_Raw_P2wpkh, + pub p2wsh: SeriesTree_Addrs_Raw_P2wsh, + pub p2tr: SeriesTree_Addrs_Raw_P2tr, + pub p2a: SeriesTree_Addrs_Raw_P2a, } -impl SeriesTree_Addresses_Raw { +impl SeriesTree_Addrs_Raw { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: SeriesTree_Addresses_Raw_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), - p2pk33: SeriesTree_Addresses_Raw_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), - p2pkh: SeriesTree_Addresses_Raw_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), - p2sh: SeriesTree_Addresses_Raw_P2sh::new(client.clone(), format!("{base_path}_p2sh")), - p2wpkh: SeriesTree_Addresses_Raw_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), - p2wsh: SeriesTree_Addresses_Raw_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), - p2tr: SeriesTree_Addresses_Raw_P2tr::new(client.clone(), format!("{base_path}_p2tr")), - p2a: SeriesTree_Addresses_Raw_P2a::new(client.clone(), format!("{base_path}_p2a")), + p2pk65: SeriesTree_Addrs_Raw_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), + p2pk33: SeriesTree_Addrs_Raw_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), + p2pkh: SeriesTree_Addrs_Raw_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), + p2sh: SeriesTree_Addrs_Raw_P2sh::new(client.clone(), format!("{base_path}_p2sh")), + p2wpkh: SeriesTree_Addrs_Raw_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), + p2wsh: SeriesTree_Addrs_Raw_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), + p2tr: SeriesTree_Addrs_Raw_P2tr::new(client.clone(), format!("{base_path}_p2tr")), + p2a: SeriesTree_Addrs_Raw_P2a::new(client.clone(), format!("{base_path}_p2a")), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2pk65 { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2pk65 { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern27, } -impl SeriesTree_Addresses_Raw_P2pk65 { +impl SeriesTree_Addrs_Raw_P2pk65 { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2pk65_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2pk65_addr_index".to_string()), bytes: SeriesPattern27::new(client.clone(), "p2pk65_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2pk33 { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2pk33 { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern26, } -impl SeriesTree_Addresses_Raw_P2pk33 { +impl SeriesTree_Addrs_Raw_P2pk33 { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2pk33_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2pk33_addr_index".to_string()), bytes: SeriesPattern26::new(client.clone(), "p2pk33_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2pkh { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2pkh { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern28, } -impl SeriesTree_Addresses_Raw_P2pkh { +impl SeriesTree_Addrs_Raw_P2pkh { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2pkh_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2pkh_addr_index".to_string()), bytes: SeriesPattern28::new(client.clone(), "p2pkh_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2sh { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2sh { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern29, } -impl SeriesTree_Addresses_Raw_P2sh { +impl SeriesTree_Addrs_Raw_P2sh { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2sh_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2sh_addr_index".to_string()), bytes: SeriesPattern29::new(client.clone(), "p2sh_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2wpkh { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2wpkh { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern31, } -impl SeriesTree_Addresses_Raw_P2wpkh { +impl SeriesTree_Addrs_Raw_P2wpkh { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2wpkh_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2wpkh_addr_index".to_string()), bytes: SeriesPattern31::new(client.clone(), "p2wpkh_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2wsh { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2wsh { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern32, } -impl SeriesTree_Addresses_Raw_P2wsh { +impl SeriesTree_Addrs_Raw_P2wsh { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2wsh_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2wsh_addr_index".to_string()), bytes: SeriesPattern32::new(client.clone(), "p2wsh_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2tr { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2tr { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern30, } -impl SeriesTree_Addresses_Raw_P2tr { +impl SeriesTree_Addrs_Raw_P2tr { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2tr_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2tr_addr_index".to_string()), bytes: SeriesPattern30::new(client.clone(), "p2tr_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Raw_P2a { - pub first_index: SeriesPattern18, +pub struct SeriesTree_Addrs_Raw_P2a { + pub first_index: SeriesPattern18, pub bytes: SeriesPattern24, } -impl SeriesTree_Addresses_Raw_P2a { +impl SeriesTree_Addrs_Raw_P2a { pub fn new(client: Arc, base_path: String) -> Self { Self { - first_index: SeriesPattern18::new(client.clone(), "first_p2a_address_index".to_string()), + first_index: SeriesPattern18::new(client.clone(), "first_p2a_addr_index".to_string()), bytes: SeriesPattern24::new(client.clone(), "p2a_bytes".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Indexes { - pub p2a: SeriesPattern24, - pub p2pk33: SeriesPattern26, - pub p2pk65: SeriesPattern27, - pub p2pkh: SeriesPattern28, - pub p2sh: SeriesPattern29, - pub p2tr: SeriesPattern30, - pub p2wpkh: SeriesPattern31, - pub p2wsh: SeriesPattern32, - pub funded: SeriesPattern34, - pub empty: SeriesPattern35, +pub struct SeriesTree_Addrs_Indexes { + pub p2a: SeriesPattern24, + pub p2pk33: SeriesPattern26, + pub p2pk65: SeriesPattern27, + pub p2pkh: SeriesPattern28, + pub p2sh: SeriesPattern29, + pub p2tr: SeriesPattern30, + pub p2wpkh: SeriesPattern31, + pub p2wsh: SeriesPattern32, + pub funded: SeriesPattern34, + pub empty: SeriesPattern35, } -impl SeriesTree_Addresses_Indexes { +impl SeriesTree_Addrs_Indexes { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2a: SeriesPattern24::new(client.clone(), "any_address_index".to_string()), - p2pk33: SeriesPattern26::new(client.clone(), "any_address_index".to_string()), - p2pk65: SeriesPattern27::new(client.clone(), "any_address_index".to_string()), - p2pkh: SeriesPattern28::new(client.clone(), "any_address_index".to_string()), - p2sh: SeriesPattern29::new(client.clone(), "any_address_index".to_string()), - p2tr: SeriesPattern30::new(client.clone(), "any_address_index".to_string()), - p2wpkh: SeriesPattern31::new(client.clone(), "any_address_index".to_string()), - p2wsh: SeriesPattern32::new(client.clone(), "any_address_index".to_string()), - funded: SeriesPattern34::new(client.clone(), "funded_address_index".to_string()), - empty: SeriesPattern35::new(client.clone(), "empty_address_index".to_string()), + p2a: SeriesPattern24::new(client.clone(), "any_addr_index".to_string()), + p2pk33: SeriesPattern26::new(client.clone(), "any_addr_index".to_string()), + p2pk65: SeriesPattern27::new(client.clone(), "any_addr_index".to_string()), + p2pkh: SeriesPattern28::new(client.clone(), "any_addr_index".to_string()), + p2sh: SeriesPattern29::new(client.clone(), "any_addr_index".to_string()), + p2tr: SeriesPattern30::new(client.clone(), "any_addr_index".to_string()), + p2wpkh: SeriesPattern31::new(client.clone(), "any_addr_index".to_string()), + p2wsh: SeriesPattern32::new(client.clone(), "any_addr_index".to_string()), + funded: SeriesPattern34::new(client.clone(), "funded_addr_index".to_string()), + empty: SeriesPattern35::new(client.clone(), "empty_addr_index".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Data { - pub funded: SeriesPattern34, - pub empty: SeriesPattern35, +pub struct SeriesTree_Addrs_Data { + pub funded: SeriesPattern34, + pub empty: SeriesPattern35, } -impl SeriesTree_Addresses_Data { +impl SeriesTree_Addrs_Data { pub fn new(client: Arc, base_path: String) -> Self { Self { - funded: SeriesPattern34::new(client.clone(), "funded_address_data".to_string()), - empty: SeriesPattern35::new(client.clone(), "empty_address_data".to_string()), + funded: SeriesPattern34::new(client.clone(), "funded_addr_data".to_string()), + empty: SeriesPattern35::new(client.clone(), "empty_addr_data".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Activity { +pub struct SeriesTree_Addrs_Activity { pub all: BothReactivatedReceivingSendingPattern, pub p2pk65: BothReactivatedReceivingSendingPattern, pub p2pk33: BothReactivatedReceivingSendingPattern, @@ -3723,24 +3725,24 @@ pub struct SeriesTree_Addresses_Activity { pub p2a: BothReactivatedReceivingSendingPattern, } -impl SeriesTree_Addresses_Activity { +impl SeriesTree_Addrs_Activity { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: BothReactivatedReceivingSendingPattern::new(client.clone(), "address_activity".to_string()), - p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_address_activity".to_string()), - p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_address_activity".to_string()), - p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_address_activity".to_string()), - p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_address_activity".to_string()), - p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_address_activity".to_string()), - p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_address_activity".to_string()), - p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_address_activity".to_string()), - p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_address_activity".to_string()), + all: BothReactivatedReceivingSendingPattern::new(client.clone(), "addr_activity".to_string()), + p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_addr_activity".to_string()), + p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_addr_activity".to_string()), + p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_addr_activity".to_string()), + p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_addr_activity".to_string()), + p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_addr_activity".to_string()), + p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_addr_activity".to_string()), + p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_addr_activity".to_string()), + p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_addr_activity".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_New { +pub struct SeriesTree_Addrs_New { pub all: BaseCumulativeSumPattern, pub p2pk65: BaseCumulativeSumPattern, pub p2pk33: BaseCumulativeSumPattern, @@ -3752,24 +3754,24 @@ pub struct SeriesTree_Addresses_New { pub p2a: BaseCumulativeSumPattern, } -impl SeriesTree_Addresses_New { +impl SeriesTree_Addrs_New { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: BaseCumulativeSumPattern::new(client.clone(), "new_address_count".to_string()), - p2pk65: BaseCumulativeSumPattern::new(client.clone(), "p2pk65_new_address_count".to_string()), - p2pk33: BaseCumulativeSumPattern::new(client.clone(), "p2pk33_new_address_count".to_string()), - p2pkh: BaseCumulativeSumPattern::new(client.clone(), "p2pkh_new_address_count".to_string()), - p2sh: BaseCumulativeSumPattern::new(client.clone(), "p2sh_new_address_count".to_string()), - p2wpkh: BaseCumulativeSumPattern::new(client.clone(), "p2wpkh_new_address_count".to_string()), - p2wsh: BaseCumulativeSumPattern::new(client.clone(), "p2wsh_new_address_count".to_string()), - p2tr: BaseCumulativeSumPattern::new(client.clone(), "p2tr_new_address_count".to_string()), - p2a: BaseCumulativeSumPattern::new(client.clone(), "p2a_new_address_count".to_string()), + all: BaseCumulativeSumPattern::new(client.clone(), "new_addr_count".to_string()), + p2pk65: BaseCumulativeSumPattern::new(client.clone(), "p2pk65_new_addr_count".to_string()), + p2pk33: BaseCumulativeSumPattern::new(client.clone(), "p2pk33_new_addr_count".to_string()), + p2pkh: BaseCumulativeSumPattern::new(client.clone(), "p2pkh_new_addr_count".to_string()), + p2sh: BaseCumulativeSumPattern::new(client.clone(), "p2sh_new_addr_count".to_string()), + p2wpkh: BaseCumulativeSumPattern::new(client.clone(), "p2wpkh_new_addr_count".to_string()), + p2wsh: BaseCumulativeSumPattern::new(client.clone(), "p2wsh_new_addr_count".to_string()), + p2tr: BaseCumulativeSumPattern::new(client.clone(), "p2tr_new_addr_count".to_string()), + p2a: BaseCumulativeSumPattern::new(client.clone(), "p2a_new_addr_count".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Addresses_Delta { +pub struct SeriesTree_Addrs_Delta { pub all: AbsoluteRatePattern, pub p2pk65: AbsoluteRatePattern, pub p2pk33: AbsoluteRatePattern, @@ -3781,18 +3783,18 @@ pub struct SeriesTree_Addresses_Delta { pub p2a: AbsoluteRatePattern, } -impl SeriesTree_Addresses_Delta { +impl SeriesTree_Addrs_Delta { pub fn new(client: Arc, base_path: String) -> Self { Self { - all: AbsoluteRatePattern::new(client.clone(), "address_count".to_string()), - p2pk65: AbsoluteRatePattern::new(client.clone(), "p2pk65_address_count".to_string()), - p2pk33: AbsoluteRatePattern::new(client.clone(), "p2pk33_address_count".to_string()), - p2pkh: AbsoluteRatePattern::new(client.clone(), "p2pkh_address_count".to_string()), - p2sh: AbsoluteRatePattern::new(client.clone(), "p2sh_address_count".to_string()), - p2wpkh: AbsoluteRatePattern::new(client.clone(), "p2wpkh_address_count".to_string()), - p2wsh: AbsoluteRatePattern::new(client.clone(), "p2wsh_address_count".to_string()), - p2tr: AbsoluteRatePattern::new(client.clone(), "p2tr_address_count".to_string()), - p2a: AbsoluteRatePattern::new(client.clone(), "p2a_address_count".to_string()), + all: AbsoluteRatePattern::new(client.clone(), "addr_count".to_string()), + p2pk65: AbsoluteRatePattern::new(client.clone(), "p2pk65_addr_count".to_string()), + p2pk33: AbsoluteRatePattern::new(client.clone(), "p2pk33_addr_count".to_string()), + p2pkh: AbsoluteRatePattern::new(client.clone(), "p2pkh_addr_count".to_string()), + p2sh: AbsoluteRatePattern::new(client.clone(), "p2sh_addr_count".to_string()), + p2wpkh: AbsoluteRatePattern::new(client.clone(), "p2wpkh_addr_count".to_string()), + p2wsh: AbsoluteRatePattern::new(client.clone(), "p2wsh_addr_count".to_string()), + p2tr: AbsoluteRatePattern::new(client.clone(), "p2tr_addr_count".to_string()), + p2a: AbsoluteRatePattern::new(client.clone(), "p2a_addr_count".to_string()), } } } @@ -4124,6 +4126,21 @@ impl SeriesTree_Mining_Hashrate_Rate_Sma { } } +/// Series tree node. +pub struct SeriesTree_Positions { + pub block: SeriesPattern18, + pub tx: SeriesPattern19, +} + +impl SeriesTree_Positions { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + block: SeriesPattern18::new(client.clone(), "position".to_string()), + tx: SeriesPattern19::new(client.clone(), "position".to_string()), + } + } +} + /// Series tree node. pub struct SeriesTree_Cointime { pub activity: SeriesTree_Cointime_Activity, @@ -4339,7 +4356,7 @@ impl SeriesTree_Constants { /// Series tree node. pub struct SeriesTree_Indexes { - pub address: SeriesTree_Indexes_Address, + pub addr: SeriesTree_Indexes_Addr, pub height: SeriesTree_Indexes_Height, pub epoch: SeriesTree_Indexes_Epoch, pub halving: SeriesTree_Indexes_Halving, @@ -4364,7 +4381,7 @@ pub struct SeriesTree_Indexes { impl SeriesTree_Indexes { pub fn new(client: Arc, base_path: String) -> Self { Self { - address: SeriesTree_Indexes_Address::new(client.clone(), format!("{base_path}_address")), + addr: SeriesTree_Indexes_Addr::new(client.clone(), format!("{base_path}_addr")), height: SeriesTree_Indexes_Height::new(client.clone(), format!("{base_path}_height")), epoch: SeriesTree_Indexes_Epoch::new(client.clone(), format!("{base_path}_epoch")), halving: SeriesTree_Indexes_Halving::new(client.clone(), format!("{base_path}_halving")), @@ -4389,166 +4406,166 @@ impl SeriesTree_Indexes { } /// Series tree node. -pub struct SeriesTree_Indexes_Address { - pub p2pk33: SeriesTree_Indexes_Address_P2pk33, - pub p2pk65: SeriesTree_Indexes_Address_P2pk65, - pub p2pkh: SeriesTree_Indexes_Address_P2pkh, - pub p2sh: SeriesTree_Indexes_Address_P2sh, - pub p2tr: SeriesTree_Indexes_Address_P2tr, - pub p2wpkh: SeriesTree_Indexes_Address_P2wpkh, - pub p2wsh: SeriesTree_Indexes_Address_P2wsh, - pub p2a: SeriesTree_Indexes_Address_P2a, - pub p2ms: SeriesTree_Indexes_Address_P2ms, - pub empty: SeriesTree_Indexes_Address_Empty, - pub unknown: SeriesTree_Indexes_Address_Unknown, - pub op_return: SeriesTree_Indexes_Address_OpReturn, +pub struct SeriesTree_Indexes_Addr { + pub p2pk33: SeriesTree_Indexes_Addr_P2pk33, + pub p2pk65: SeriesTree_Indexes_Addr_P2pk65, + pub p2pkh: SeriesTree_Indexes_Addr_P2pkh, + pub p2sh: SeriesTree_Indexes_Addr_P2sh, + pub p2tr: SeriesTree_Indexes_Addr_P2tr, + pub p2wpkh: SeriesTree_Indexes_Addr_P2wpkh, + pub p2wsh: SeriesTree_Indexes_Addr_P2wsh, + pub p2a: SeriesTree_Indexes_Addr_P2a, + pub p2ms: SeriesTree_Indexes_Addr_P2ms, + pub empty: SeriesTree_Indexes_Addr_Empty, + pub unknown: SeriesTree_Indexes_Addr_Unknown, + pub op_return: SeriesTree_Indexes_Addr_OpReturn, } -impl SeriesTree_Indexes_Address { +impl SeriesTree_Indexes_Addr { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk33: SeriesTree_Indexes_Address_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), - p2pk65: SeriesTree_Indexes_Address_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), - p2pkh: SeriesTree_Indexes_Address_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), - p2sh: SeriesTree_Indexes_Address_P2sh::new(client.clone(), format!("{base_path}_p2sh")), - p2tr: SeriesTree_Indexes_Address_P2tr::new(client.clone(), format!("{base_path}_p2tr")), - p2wpkh: SeriesTree_Indexes_Address_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), - p2wsh: SeriesTree_Indexes_Address_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), - p2a: SeriesTree_Indexes_Address_P2a::new(client.clone(), format!("{base_path}_p2a")), - p2ms: SeriesTree_Indexes_Address_P2ms::new(client.clone(), format!("{base_path}_p2ms")), - empty: SeriesTree_Indexes_Address_Empty::new(client.clone(), format!("{base_path}_empty")), - unknown: SeriesTree_Indexes_Address_Unknown::new(client.clone(), format!("{base_path}_unknown")), - op_return: SeriesTree_Indexes_Address_OpReturn::new(client.clone(), format!("{base_path}_op_return")), + p2pk33: SeriesTree_Indexes_Addr_P2pk33::new(client.clone(), format!("{base_path}_p2pk33")), + p2pk65: SeriesTree_Indexes_Addr_P2pk65::new(client.clone(), format!("{base_path}_p2pk65")), + p2pkh: SeriesTree_Indexes_Addr_P2pkh::new(client.clone(), format!("{base_path}_p2pkh")), + p2sh: SeriesTree_Indexes_Addr_P2sh::new(client.clone(), format!("{base_path}_p2sh")), + p2tr: SeriesTree_Indexes_Addr_P2tr::new(client.clone(), format!("{base_path}_p2tr")), + p2wpkh: SeriesTree_Indexes_Addr_P2wpkh::new(client.clone(), format!("{base_path}_p2wpkh")), + p2wsh: SeriesTree_Indexes_Addr_P2wsh::new(client.clone(), format!("{base_path}_p2wsh")), + p2a: SeriesTree_Indexes_Addr_P2a::new(client.clone(), format!("{base_path}_p2a")), + p2ms: SeriesTree_Indexes_Addr_P2ms::new(client.clone(), format!("{base_path}_p2ms")), + empty: SeriesTree_Indexes_Addr_Empty::new(client.clone(), format!("{base_path}_empty")), + unknown: SeriesTree_Indexes_Addr_Unknown::new(client.clone(), format!("{base_path}_unknown")), + op_return: SeriesTree_Indexes_Addr_OpReturn::new(client.clone(), format!("{base_path}_op_return")), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2pk33 { - pub identity: SeriesPattern26, - pub address: SeriesPattern26
, +pub struct SeriesTree_Indexes_Addr_P2pk33 { + pub identity: SeriesPattern26, + pub addr: SeriesPattern26, } -impl SeriesTree_Indexes_Address_P2pk33 { +impl SeriesTree_Indexes_Addr_P2pk33 { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern26::new(client.clone(), "p2pk33_address_index".to_string()), - address: SeriesPattern26::new(client.clone(), "p2pk33_address".to_string()), + identity: SeriesPattern26::new(client.clone(), "p2pk33_addr_index".to_string()), + addr: SeriesPattern26::new(client.clone(), "p2pk33_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2pk65 { - pub identity: SeriesPattern27, - pub address: SeriesPattern27
, +pub struct SeriesTree_Indexes_Addr_P2pk65 { + pub identity: SeriesPattern27, + pub addr: SeriesPattern27, } -impl SeriesTree_Indexes_Address_P2pk65 { +impl SeriesTree_Indexes_Addr_P2pk65 { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern27::new(client.clone(), "p2pk65_address_index".to_string()), - address: SeriesPattern27::new(client.clone(), "p2pk65_address".to_string()), + identity: SeriesPattern27::new(client.clone(), "p2pk65_addr_index".to_string()), + addr: SeriesPattern27::new(client.clone(), "p2pk65_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2pkh { - pub identity: SeriesPattern28, - pub address: SeriesPattern28
, +pub struct SeriesTree_Indexes_Addr_P2pkh { + pub identity: SeriesPattern28, + pub addr: SeriesPattern28, } -impl SeriesTree_Indexes_Address_P2pkh { +impl SeriesTree_Indexes_Addr_P2pkh { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern28::new(client.clone(), "p2pkh_address_index".to_string()), - address: SeriesPattern28::new(client.clone(), "p2pkh_address".to_string()), + identity: SeriesPattern28::new(client.clone(), "p2pkh_addr_index".to_string()), + addr: SeriesPattern28::new(client.clone(), "p2pkh_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2sh { - pub identity: SeriesPattern29, - pub address: SeriesPattern29
, +pub struct SeriesTree_Indexes_Addr_P2sh { + pub identity: SeriesPattern29, + pub addr: SeriesPattern29, } -impl SeriesTree_Indexes_Address_P2sh { +impl SeriesTree_Indexes_Addr_P2sh { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern29::new(client.clone(), "p2sh_address_index".to_string()), - address: SeriesPattern29::new(client.clone(), "p2sh_address".to_string()), + identity: SeriesPattern29::new(client.clone(), "p2sh_addr_index".to_string()), + addr: SeriesPattern29::new(client.clone(), "p2sh_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2tr { - pub identity: SeriesPattern30, - pub address: SeriesPattern30
, +pub struct SeriesTree_Indexes_Addr_P2tr { + pub identity: SeriesPattern30, + pub addr: SeriesPattern30, } -impl SeriesTree_Indexes_Address_P2tr { +impl SeriesTree_Indexes_Addr_P2tr { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern30::new(client.clone(), "p2tr_address_index".to_string()), - address: SeriesPattern30::new(client.clone(), "p2tr_address".to_string()), + identity: SeriesPattern30::new(client.clone(), "p2tr_addr_index".to_string()), + addr: SeriesPattern30::new(client.clone(), "p2tr_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2wpkh { - pub identity: SeriesPattern31, - pub address: SeriesPattern31
, +pub struct SeriesTree_Indexes_Addr_P2wpkh { + pub identity: SeriesPattern31, + pub addr: SeriesPattern31, } -impl SeriesTree_Indexes_Address_P2wpkh { +impl SeriesTree_Indexes_Addr_P2wpkh { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern31::new(client.clone(), "p2wpkh_address_index".to_string()), - address: SeriesPattern31::new(client.clone(), "p2wpkh_address".to_string()), + identity: SeriesPattern31::new(client.clone(), "p2wpkh_addr_index".to_string()), + addr: SeriesPattern31::new(client.clone(), "p2wpkh_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2wsh { - pub identity: SeriesPattern32, - pub address: SeriesPattern32
, +pub struct SeriesTree_Indexes_Addr_P2wsh { + pub identity: SeriesPattern32, + pub addr: SeriesPattern32, } -impl SeriesTree_Indexes_Address_P2wsh { +impl SeriesTree_Indexes_Addr_P2wsh { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern32::new(client.clone(), "p2wsh_address_index".to_string()), - address: SeriesPattern32::new(client.clone(), "p2wsh_address".to_string()), + identity: SeriesPattern32::new(client.clone(), "p2wsh_addr_index".to_string()), + addr: SeriesPattern32::new(client.clone(), "p2wsh_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2a { - pub identity: SeriesPattern24, - pub address: SeriesPattern24
, +pub struct SeriesTree_Indexes_Addr_P2a { + pub identity: SeriesPattern24, + pub addr: SeriesPattern24, } -impl SeriesTree_Indexes_Address_P2a { +impl SeriesTree_Indexes_Addr_P2a { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: SeriesPattern24::new(client.clone(), "p2a_address_index".to_string()), - address: SeriesPattern24::new(client.clone(), "p2a_address".to_string()), + identity: SeriesPattern24::new(client.clone(), "p2a_addr_index".to_string()), + addr: SeriesPattern24::new(client.clone(), "p2a_addr".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Indexes_Address_P2ms { +pub struct SeriesTree_Indexes_Addr_P2ms { pub identity: SeriesPattern25, } -impl SeriesTree_Indexes_Address_P2ms { +impl SeriesTree_Indexes_Addr_P2ms { pub fn new(client: Arc, base_path: String) -> Self { Self { identity: SeriesPattern25::new(client.clone(), "p2ms_output_index".to_string()), @@ -4557,11 +4574,11 @@ impl SeriesTree_Indexes_Address_P2ms { } /// Series tree node. -pub struct SeriesTree_Indexes_Address_Empty { +pub struct SeriesTree_Indexes_Addr_Empty { pub identity: SeriesPattern22, } -impl SeriesTree_Indexes_Address_Empty { +impl SeriesTree_Indexes_Addr_Empty { pub fn new(client: Arc, base_path: String) -> Self { Self { identity: SeriesPattern22::new(client.clone(), "empty_output_index".to_string()), @@ -4570,11 +4587,11 @@ impl SeriesTree_Indexes_Address_Empty { } /// Series tree node. -pub struct SeriesTree_Indexes_Address_Unknown { +pub struct SeriesTree_Indexes_Addr_Unknown { pub identity: SeriesPattern33, } -impl SeriesTree_Indexes_Address_Unknown { +impl SeriesTree_Indexes_Addr_Unknown { pub fn new(client: Arc, base_path: String) -> Self { Self { identity: SeriesPattern33::new(client.clone(), "unknown_output_index".to_string()), @@ -4583,11 +4600,11 @@ impl SeriesTree_Indexes_Address_Unknown { } /// Series tree node. -pub struct SeriesTree_Indexes_Address_OpReturn { +pub struct SeriesTree_Indexes_Addr_OpReturn { pub identity: SeriesPattern23, } -impl SeriesTree_Indexes_Address_OpReturn { +impl SeriesTree_Indexes_Addr_OpReturn { pub fn new(client: Arc, base_path: String) -> Self { Self { identity: SeriesPattern23::new(client.clone(), "op_return_index".to_string()), @@ -6180,14 +6197,14 @@ impl SeriesTree_Supply_Velocity { /// Series tree node. pub struct SeriesTree_Cohorts { pub utxo: SeriesTree_Cohorts_Utxo, - pub address: SeriesTree_Cohorts_Address, + pub addr: SeriesTree_Cohorts_Addr, } impl SeriesTree_Cohorts { pub fn new(client: Arc, base_path: String) -> Self { Self { utxo: SeriesTree_Cohorts_Utxo::new(client.clone(), format!("{base_path}_utxo")), - address: SeriesTree_Cohorts_Address::new(client.clone(), format!("{base_path}_address")), + addr: SeriesTree_Cohorts_Addr::new(client.clone(), format!("{base_path}_addr")), } } } @@ -8171,133 +8188,133 @@ impl SeriesTree_Cohorts_Utxo_Matured { } /// Series tree node. -pub struct SeriesTree_Cohorts_Address { - pub over_amount: SeriesTree_Cohorts_Address_OverAmount, - pub amount_range: SeriesTree_Cohorts_Address_AmountRange, - pub under_amount: SeriesTree_Cohorts_Address_UnderAmount, +pub struct SeriesTree_Cohorts_Addr { + pub over_amount: SeriesTree_Cohorts_Addr_OverAmount, + pub amount_range: SeriesTree_Cohorts_Addr_AmountRange, + pub under_amount: SeriesTree_Cohorts_Addr_UnderAmount, } -impl SeriesTree_Cohorts_Address { +impl SeriesTree_Cohorts_Addr { pub fn new(client: Arc, base_path: String) -> Self { Self { - over_amount: SeriesTree_Cohorts_Address_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), - amount_range: SeriesTree_Cohorts_Address_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), - under_amount: SeriesTree_Cohorts_Address_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), + over_amount: SeriesTree_Cohorts_Addr_OverAmount::new(client.clone(), format!("{base_path}_over_amount")), + amount_range: SeriesTree_Cohorts_Addr_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), + under_amount: SeriesTree_Cohorts_Addr_UnderAmount::new(client.clone(), format!("{base_path}_under_amount")), } } } /// Series tree node. -pub struct SeriesTree_Cohorts_Address_OverAmount { - pub _1sat: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, +pub struct SeriesTree_Cohorts_Addr_OverAmount { + pub _1sat: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, } -impl SeriesTree_Cohorts_Address_OverAmount { +impl SeriesTree_Cohorts_Addr_OverAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1sat".to_string()), - _10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10sats".to_string()), - _100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100sats".to_string()), - _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), - _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), - _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), - _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), - _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), - _1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1btc".to_string()), - _10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10btc".to_string()), - _100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100btc".to_string()), - _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), - _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), + _1sat: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1sat".to_string()), + _10sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10sats".to_string()), + _100sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100sats".to_string()), + _1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), + _10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), + _100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), + _1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), + _10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), + _1btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1btc".to_string()), + _10btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10btc".to_string()), + _100btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100btc".to_string()), + _1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), + _10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Cohorts_Address_AmountRange { - pub _0sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, +pub struct SeriesTree_Cohorts_Addr_AmountRange { + pub _0sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1sat_to_10sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10sats_to_100sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100sats_to_1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats_to_10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats_to_100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats_to_1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats_to_10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats_to_1btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1btc_to_10btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10btc_to_100btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100btc_to_1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc_to_10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc_to_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub over_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, } -impl SeriesTree_Cohorts_Address_AmountRange { +impl SeriesTree_Cohorts_Addr_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_0sats".to_string()), - _1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1sat_to_10sats".to_string()), - _10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10sats_to_100sats".to_string()), - _100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100sats_to_1k_sats".to_string()), - _1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_sats_to_10k_sats".to_string()), - _10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_sats_to_100k_sats".to_string()), - _100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100k_sats_to_1m_sats".to_string()), - _1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1m_sats_to_10m_sats".to_string()), - _10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10m_sats_to_1btc".to_string()), - _1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1btc_to_10btc".to_string()), - _10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10btc_to_100btc".to_string()), - _100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100btc_to_1k_btc".to_string()), - _1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_btc_to_10k_btc".to_string()), - _10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_btc_to_100k_btc".to_string()), - over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_btc".to_string()), + _0sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_0sats".to_string()), + _1sat_to_10sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1sat_to_10sats".to_string()), + _10sats_to_100sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10sats_to_100sats".to_string()), + _100sats_to_1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100sats_to_1k_sats".to_string()), + _1k_sats_to_10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_sats_to_10k_sats".to_string()), + _10k_sats_to_100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_sats_to_100k_sats".to_string()), + _100k_sats_to_1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100k_sats_to_1m_sats".to_string()), + _1m_sats_to_10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1m_sats_to_10m_sats".to_string()), + _10m_sats_to_1btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10m_sats_to_1btc".to_string()), + _1btc_to_10btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1btc_to_10btc".to_string()), + _10btc_to_100btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10btc_to_100btc".to_string()), + _100btc_to_1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_100btc_to_1k_btc".to_string()), + _1k_btc_to_10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_1k_btc_to_10k_btc".to_string()), + _10k_btc_to_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_10k_btc_to_100k_btc".to_string()), + over_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_btc".to_string()), } } } /// Series tree node. -pub struct SeriesTree_Cohorts_Address_UnderAmount { - pub _10sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, - pub _100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern, +pub struct SeriesTree_Cohorts_Addr_UnderAmount { + pub _10sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, + pub _100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern, } -impl SeriesTree_Cohorts_Address_UnderAmount { +impl SeriesTree_Cohorts_Addr_UnderAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10sats".to_string()), - _100sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100sats".to_string()), - _1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), - _10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), - _100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), - _1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), - _10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), - _1btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1btc".to_string()), - _10btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10btc".to_string()), - _100btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100btc".to_string()), - _1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), - _10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), - _100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), + _10sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10sats".to_string()), + _100sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100sats".to_string()), + _1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), + _10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), + _100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), + _1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), + _10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), + _1btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1btc".to_string()), + _10btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10btc".to_string()), + _100btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100btc".to_string()), + _1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), + _10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), + _100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), } } } @@ -8380,7 +8397,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address)* /// /// Endpoint: `GET /api/address/{address}` - pub fn get_address(&self, address: Address) -> Result { + pub fn get_address(&self, address: Addr) -> Result { self.base.get_json(&format!("/api/address/{address}")) } @@ -8391,7 +8408,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions)* /// /// Endpoint: `GET /api/address/{address}/txs` - pub fn get_address_txs(&self, address: Address, after_txid: Option) -> Result> { + pub fn get_address_txs(&self, address: Addr, after_txid: Option) -> Result> { let mut query = Vec::new(); if let Some(v) = after_txid { query.push(format!("after_txid={}", v)); } let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; @@ -8406,7 +8423,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-chain)* /// /// Endpoint: `GET /api/address/{address}/txs/chain` - pub fn get_address_confirmed_txs(&self, address: Address, after_txid: Option) -> Result> { + pub fn get_address_confirmed_txs(&self, address: Addr, after_txid: Option) -> Result> { let mut query = Vec::new(); if let Some(v) = after_txid { query.push(format!("after_txid={}", v)); } let query_str = if query.is_empty() { String::new() } else { format!("?{}", query.join("&")) }; @@ -8421,7 +8438,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-mempool)* /// /// Endpoint: `GET /api/address/{address}/txs/mempool` - pub fn get_address_mempool_txs(&self, address: Address) -> Result> { + pub fn get_address_mempool_txs(&self, address: Addr) -> Result> { self.base.get_json(&format!("/api/address/{address}/txs/mempool")) } @@ -8432,7 +8449,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-utxo)* /// /// Endpoint: `GET /api/address/{address}/utxo` - pub fn get_address_utxos(&self, address: Address) -> Result> { + pub fn get_address_utxos(&self, address: Addr) -> Result> { self.base.get_json(&format!("/api/address/{address}/utxo")) } @@ -9011,7 +9028,7 @@ impl BrkClient { /// *[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-validate)* /// /// Endpoint: `GET /api/v1/validate-address/{address}` - pub fn validate_address(&self, address: &str) -> Result { + pub fn validate_address(&self, address: &str) -> Result { self.base.get_json(&format!("/api/v1/validate-address/{address}")) } diff --git a/crates/brk_cohort/src/address.rs b/crates/brk_cohort/src/addr.rs similarity index 97% rename from crates/brk_cohort/src/address.rs rename to crates/brk_cohort/src/addr.rs index 3e3f4d6b3..f74bcd2b3 100644 --- a/crates/brk_cohort/src/address.rs +++ b/crates/brk_cohort/src/addr.rs @@ -6,13 +6,13 @@ use crate::Filter; use super::{AmountRange, OverAmount, UnderAmount}; #[derive(Default, Clone, Traversable)] -pub struct AddressGroups { +pub struct AddrGroups { pub over_amount: OverAmount, pub amount_range: AmountRange, pub under_amount: UnderAmount, } -impl AddressGroups { +impl AddrGroups { pub fn new(mut create: F) -> Self where F: FnMut(Filter, &'static str) -> T, diff --git a/crates/brk_cohort/src/by_address_type.rs b/crates/brk_cohort/src/by_addr_type.rs similarity index 88% rename from crates/brk_cohort/src/by_address_type.rs rename to crates/brk_cohort/src/by_addr_type.rs index 4b449d20e..0436e8187 100644 --- a/crates/brk_cohort/src/by_address_type.rs +++ b/crates/brk_cohort/src/by_addr_type.rs @@ -17,7 +17,7 @@ pub const P2TR: &str = "p2tr"; pub const P2A: &str = "p2a"; #[derive(Default, Clone, Debug, Traversable)] -pub struct ByAddressType { +pub struct ByAddrType { pub p2pk65: T, pub p2pk33: T, pub p2pkh: T, @@ -28,7 +28,7 @@ pub struct ByAddressType { pub p2a: T, } -impl ByAddressType { +impl ByAddrType { pub fn new(mut create: F) -> Self where F: FnMut(Filter) -> T, @@ -61,8 +61,8 @@ impl ByAddressType { }) } - pub fn map_with_name(&self, f: impl Fn(&'static str, &T) -> U) -> ByAddressType { - ByAddressType { + pub fn map_with_name(&self, f: impl Fn(&'static str, &T) -> U) -> ByAddrType { + ByAddrType { p2pk65: f(P2PK65, &self.p2pk65), p2pk33: f(P2PK33, &self.p2pk33), p2pkh: f(P2PKH, &self.p2pkh), @@ -91,13 +91,13 @@ impl ByAddressType { } #[inline] - pub fn get_unwrap(&self, addresstype: OutputType) -> &T { - self.get(addresstype).unwrap() + pub fn get_unwrap(&self, addr_type: OutputType) -> &T { + self.get(addr_type).unwrap() } #[inline] - pub fn get(&self, address_type: OutputType) -> Option<&T> { - match address_type { + pub fn get(&self, addr_type: OutputType) -> Option<&T> { + match addr_type { OutputType::P2PK65 => Some(&self.p2pk65), OutputType::P2PK33 => Some(&self.p2pk33), OutputType::P2PKH => Some(&self.p2pkh), @@ -111,13 +111,13 @@ impl ByAddressType { } #[inline] - pub fn get_mut_unwrap(&mut self, addresstype: OutputType) -> &mut T { - self.get_mut(addresstype).unwrap() + pub fn get_mut_unwrap(&mut self, addr_type: OutputType) -> &mut T { + self.get_mut(addr_type).unwrap() } #[inline] - pub fn get_mut(&mut self, address_type: OutputType) -> Option<&mut T> { - match address_type { + pub fn get_mut(&mut self, addr_type: OutputType) -> Option<&mut T> { + match addr_type { OutputType::P2PK65 => Some(&mut self.p2pk65), OutputType::P2PK33 => Some(&mut self.p2pk33), OutputType::P2PKH => Some(&mut self.p2pkh), @@ -243,7 +243,7 @@ impl ByAddressType { } } -impl Add for ByAddressType +impl Add for ByAddrType where T: Add, { @@ -262,7 +262,7 @@ where } } -impl AddAssign for ByAddressType +impl AddAssign for ByAddrType where T: AddAssign, { @@ -278,7 +278,7 @@ where } } -impl ByAddressType> { +impl ByAddrType> { pub fn take(&mut self) { self.values_mut().for_each(|opt| { opt.take(); @@ -286,12 +286,12 @@ impl ByAddressType> { } } -/// Zip one ByAddressType with a function, producing a new ByAddressType. -pub fn zip_by_addresstype(source: &ByAddressType, f: F) -> Result> +/// Zip one ByAddrType with a function, producing a new ByAddrType. +pub fn zip_by_addr_type(source: &ByAddrType, f: F) -> Result> where F: Fn(&'static str, &S) -> Result, { - Ok(ByAddressType { + Ok(ByAddrType { p2pk65: f(P2PK65, &source.p2pk65)?, p2pk33: f(P2PK33, &source.p2pk33)?, p2pkh: f(P2PKH, &source.p2pkh)?, @@ -303,16 +303,16 @@ where }) } -/// Zip two ByAddressTypes with a function, producing a new ByAddressType. -pub fn zip2_by_addresstype( - a: &ByAddressType, - b: &ByAddressType, +/// Zip two ByAddrTypes with a function, producing a new ByAddrType. +pub fn zip2_by_addr_type( + a: &ByAddrType, + b: &ByAddrType, f: F, -) -> Result> +) -> Result> where F: Fn(&'static str, &S1, &S2) -> Result, { - Ok(ByAddressType { + Ok(ByAddrType { p2pk65: f(P2PK65, &a.p2pk65, &b.p2pk65)?, p2pk33: f(P2PK33, &a.p2pk33, &b.p2pk33)?, p2pkh: f(P2PKH, &a.p2pkh, &b.p2pkh)?, diff --git a/crates/brk_cohort/src/by_any_address.rs b/crates/brk_cohort/src/by_any_addr.rs similarity index 76% rename from crates/brk_cohort/src/by_any_address.rs rename to crates/brk_cohort/src/by_any_addr.rs index 997f51839..11b8cf7b0 100644 --- a/crates/brk_cohort/src/by_any_address.rs +++ b/crates/brk_cohort/src/by_any_addr.rs @@ -1,12 +1,12 @@ use brk_traversable::Traversable; #[derive(Debug, Default, Traversable)] -pub struct ByAnyAddress { +pub struct ByAnyAddr { pub funded: T, pub empty: T, } -impl ByAnyAddress> { +impl ByAnyAddr> { pub fn take(&mut self) { self.funded.take(); self.empty.take(); diff --git a/crates/brk_cohort/src/cohort_context.rs b/crates/brk_cohort/src/cohort_context.rs index 3b8706954..ae7b043ef 100644 --- a/crates/brk_cohort/src/cohort_context.rs +++ b/crates/brk_cohort/src/cohort_context.rs @@ -6,14 +6,14 @@ pub enum CohortContext { /// UTXO-based cohorts: uses "utxos_" prefix for Time/Amount filters Utxo, /// Address-based cohorts: uses "addrs_" prefix for Amount filters - Address, + Addr, } impl CohortContext { pub fn prefix(&self) -> &'static str { match self { CohortContext::Utxo => "utxos", - CohortContext::Address => "addrs", + CohortContext::Addr => "addrs", } } diff --git a/crates/brk_cohort/src/filter.rs b/crates/brk_cohort/src/filter.rs index a158e2ec0..6a7adcd9a 100644 --- a/crates/brk_cohort/src/filter.rs +++ b/crates/brk_cohort/src/filter.rs @@ -69,10 +69,10 @@ impl Filter { /// Whether to compute extended metrics (realized cap ratios, profit/loss ratios, percentiles) /// For UTXO context: true only for age range cohorts (Range) and aggregate cohorts (All, Term) - /// For Address context: always false + /// For address context: always false pub fn is_extended(&self, context: CohortContext) -> bool { match context { - CohortContext::Address => false, + CohortContext::Addr => false, CohortContext::Utxo => { matches!( self, @@ -90,12 +90,12 @@ impl Filter { /// Whether to compute adjusted metrics (adjusted SOPR, adjusted value created/destroyed) /// For UTXO context: true for All, STH, and under_age (LowerThan) - /// For Address context: always false + /// For address context: always false /// Note: LTH doesn't need adjusted (everything >= 5 months is already > 1 hour) /// Note: age ranges don't need adjusted (0-1h data lives in its own cohort) pub fn compute_adjusted(&self, context: CohortContext) -> bool { match context { - CohortContext::Address => false, + CohortContext::Addr => false, CohortContext::Utxo => matches!( self, Filter::All | Filter::Term(Term::Sth) | Filter::Time(TimeFilter::LowerThan(_)) diff --git a/crates/brk_cohort/src/lib.rs b/crates/brk_cohort/src/lib.rs index b0dfd95a8..303230653 100644 --- a/crates/brk_cohort/src/lib.rs +++ b/crates/brk_cohort/src/lib.rs @@ -1,11 +1,11 @@ #![doc = include_str!("../README.md")] -mod address; +mod addr; mod amount_filter; mod age_range; mod amount_range; -mod by_address_type; -mod by_any_address; +mod by_addr_type; +mod by_any_addr; mod by_epoch; mod by_term; mod by_type; @@ -29,12 +29,12 @@ mod utxo; pub use brk_types::{Age, Term}; -pub use address::*; +pub use addr::*; pub use amount_filter::*; pub use age_range::*; pub use amount_range::*; -pub use by_address_type::*; -pub use by_any_address::*; +pub use by_addr_type::*; +pub use by_any_addr::*; pub use by_epoch::*; pub use by_term::*; pub use by_type::*; diff --git a/crates/brk_computer/examples/computer_read.rs b/crates/brk_computer/examples/computer_read.rs index 2c3e4331b..e7270158e 100644 --- a/crates/brk_computer/examples/computer_read.rs +++ b/crates/brk_computer/examples/computer_read.rs @@ -14,23 +14,23 @@ pub fn main() -> Result<()> { let computer = Computer::forced_import(&outputs_dir, &indexer)?; - // Test empty_address_data (underlying BytesVec) - direct access - let empty_data = &computer.distribution.addresses_data.empty; - println!("empty_address_data (BytesVec) len: {}", empty_data.len()); + // Test empty_addr_data (underlying BytesVec) - direct access + let empty_data = &computer.distribution.addrs_data.empty; + println!("empty_addr_data (BytesVec) len: {}", empty_data.len()); let start = Instant::now(); let mut buf = Vec::new(); empty_data.write_json(Some(empty_data.len() - 1), Some(empty_data.len()), &mut buf)?; println!( - "empty_address_data last item JSON: {}", + "empty_addr_data last item JSON: {}", String::from_utf8_lossy(&buf) ); println!("Time for BytesVec write_json: {:?}", start.elapsed()); - // Test empty_address_index (LazyVecFrom1 wrapper) - computed access - let empty_index = &computer.distribution.addresses.empty_index; + // Test empty_addr_index (LazyVecFrom1 wrapper) - computed access + let empty_index = &computer.distribution.addrs.empty_index; println!( - "\nempty_address_index (LazyVecFrom1) len: {}", + "\nempty_addr_index (LazyVecFrom1) len: {}", empty_index.len() ); @@ -42,14 +42,14 @@ pub fn main() -> Result<()> { &mut buf, )?; println!( - "empty_address_index last item JSON: {}", + "empty_addr_index last item JSON: {}", String::from_utf8_lossy(&buf) ); println!("Time for LazyVecFrom1 write_json: {:?}", start.elapsed()); // Compare with funded versions - let funded_data = &computer.distribution.addresses_data.funded; - println!("\nfunded_address_data (BytesVec) len: {}", funded_data.len()); + let funded_data = &computer.distribution.addrs_data.funded; + println!("\nfunded_addr_data (BytesVec) len: {}", funded_data.len()); let start = Instant::now(); let mut buf = Vec::new(); @@ -59,7 +59,7 @@ pub fn main() -> Result<()> { &mut buf, )?; println!( - "funded_address_data last item JSON: {}", + "funded_addr_data last item JSON: {}", String::from_utf8_lossy(&buf) ); println!("Time for BytesVec write_json: {:?}", start.elapsed()); diff --git a/crates/brk_computer/src/distribution/address/activity.rs b/crates/brk_computer/src/distribution/addr/activity.rs similarity index 87% rename from crates/brk_computer/src/distribution/address/activity.rs rename to crates/brk_computer/src/distribution/addr/activity.rs index 72e08b5aa..7a0528392 100644 --- a/crates/brk_computer/src/distribution/address/activity.rs +++ b/crates/brk_computer/src/distribution/addr/activity.rs @@ -9,7 +9,7 @@ //! | `reactivated` | Addresses that were empty and now have funds | //! | `both` | Addresses that both sent AND received same block | -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, StoredU32, Version}; @@ -41,9 +41,9 @@ impl BlockActivityCounts { /// Per-address-type activity counts - aggregated during block processing. #[derive(Debug, Default, Deref, DerefMut)] -pub struct AddressTypeToActivityCounts(pub ByAddressType); +pub struct AddrTypeToActivityCounts(pub ByAddrType); -impl AddressTypeToActivityCounts { +impl AddrTypeToActivityCounts { /// Reset all per-type counts. pub(crate) fn reset(&mut self) { self.0.values_mut().for_each(|v| v.reset()); @@ -163,16 +163,16 @@ impl ActivityCountVecs { /// Per-address-type activity count vecs. #[derive(Deref, DerefMut, Traversable)] -pub struct AddressTypeToActivityCountVecs(ByAddressType>); +pub struct AddrTypeToActivityCountVecs(ByAddrType>); -impl From> for AddressTypeToActivityCountVecs { +impl From> for AddrTypeToActivityCountVecs { #[inline] - fn from(value: ByAddressType) -> Self { + fn from(value: ByAddrType) -> Self { Self(value) } } -impl AddressTypeToActivityCountVecs { +impl AddrTypeToActivityCountVecs { pub(crate) fn forced_import( db: &Database, name: &str, @@ -181,7 +181,7 @@ impl AddressTypeToActivityCountVecs { cached_starts: &CachedWindowStarts, ) -> Result { Ok(Self::from( - ByAddressType::::new_with_name(|type_name| { + ByAddrType::::new_with_name(|type_name| { ActivityCountVecs::forced_import( db, &format!("{type_name}_{name}"), @@ -233,7 +233,7 @@ impl AddressTypeToActivityCountVecs { } #[inline(always)] - pub(crate) fn push_height(&mut self, counts: &AddressTypeToActivityCounts) { + pub(crate) fn push_height(&mut self, counts: &AddrTypeToActivityCounts) { for (vecs, c) in self.0.values_mut().zip(counts.0.values()) { vecs.push_height(c); } @@ -242,13 +242,13 @@ impl AddressTypeToActivityCountVecs { /// Storage for activity metrics (global + per type). #[derive(Traversable)] -pub struct AddressActivityVecs { +pub struct AddrActivityVecs { pub all: ActivityCountVecs, #[traversable(flatten)] - pub by_address_type: AddressTypeToActivityCountVecs, + pub by_addr_type: AddrTypeToActivityCountVecs, } -impl AddressActivityVecs { +impl AddrActivityVecs { pub(crate) fn forced_import( db: &Database, name: &str, @@ -258,7 +258,7 @@ impl AddressActivityVecs { ) -> Result { Ok(Self { all: ActivityCountVecs::forced_import(db, name, version, indexes, cached_starts)?, - by_address_type: AddressTypeToActivityCountVecs::forced_import( + by_addr_type: AddrTypeToActivityCountVecs::forced_import( db, name, version, indexes, cached_starts, )?, }) @@ -267,7 +267,7 @@ impl AddressActivityVecs { pub(crate) fn min_stateful_len(&self) -> usize { self.all .min_stateful_len() - .min(self.by_address_type.min_stateful_len()) + .min(self.by_addr_type.min_stateful_len()) } pub(crate) fn par_iter_height_mut( @@ -275,12 +275,12 @@ impl AddressActivityVecs { ) -> impl ParallelIterator { self.all .par_iter_height_mut() - .chain(self.by_address_type.par_iter_height_mut()) + .chain(self.by_addr_type.par_iter_height_mut()) } pub(crate) fn reset_height(&mut self) -> Result<()> { self.all.reset_height()?; - self.by_address_type.reset_height()?; + self.by_addr_type.reset_height()?; Ok(()) } @@ -290,14 +290,14 @@ impl AddressActivityVecs { exit: &Exit, ) -> Result<()> { self.all.compute_rest(max_from, exit)?; - self.by_address_type.compute_rest(max_from, exit)?; + self.by_addr_type.compute_rest(max_from, exit)?; Ok(()) } #[inline(always)] - pub(crate) fn push_height(&mut self, counts: &AddressTypeToActivityCounts) { + pub(crate) fn push_height(&mut self, counts: &AddrTypeToActivityCounts) { let totals = counts.totals(); self.all.push_height(&totals); - self.by_address_type.push_height(counts); + self.by_addr_type.push_height(counts); } } diff --git a/crates/brk_computer/src/distribution/address/address_count.rs b/crates/brk_computer/src/distribution/addr/addr_count.rs similarity index 72% rename from crates/brk_computer/src/distribution/address/address_count.rs rename to crates/brk_computer/src/distribution/addr/addr_count.rs index acec2b208..a0c6677f7 100644 --- a/crates/brk_computer/src/distribution/address/address_count.rs +++ b/crates/brk_computer/src/distribution/addr/addr_count.rs @@ -1,4 +1,4 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, Indexes, StoredU64, Version}; @@ -12,11 +12,11 @@ use vecdb::{ use crate::{indexes, internal::PerBlock}; #[derive(Deref, DerefMut, Traversable)] -pub struct AddressCountVecs( +pub struct AddrCountVecs( #[traversable(flatten)] pub PerBlock, ); -impl AddressCountVecs { +impl AddrCountVecs { pub(crate) fn forced_import( db: &Database, name: &str, @@ -31,20 +31,20 @@ impl AddressCountVecs { /// Address count per address type (runtime state). #[derive(Debug, Default, Deref, DerefMut)] -pub struct AddressTypeToAddressCount(ByAddressType); +pub struct AddrTypeToAddrCount(ByAddrType); -impl AddressTypeToAddressCount { +impl AddrTypeToAddrCount { #[inline] pub(crate) fn sum(&self) -> u64 { self.0.values().sum() } } -impl From<(&AddressTypeToAddressCountVecs, Height)> for AddressTypeToAddressCount { +impl From<(&AddrTypeToAddrCountVecs, Height)> for AddrTypeToAddrCount { #[inline] - fn from((groups, starting_height): (&AddressTypeToAddressCountVecs, Height)) -> Self { + fn from((groups, starting_height): (&AddrTypeToAddrCountVecs, Height)) -> Self { if let Some(prev_height) = starting_height.decremented() { - Self(ByAddressType { + Self(ByAddrType { p2pk65: groups .p2pk65 .height @@ -102,25 +102,25 @@ impl From<(&AddressTypeToAddressCountVecs, Height)> for AddressTypeToAddressCoun /// Address count per address type, with height + derived indexes. #[derive(Deref, DerefMut, Traversable)] -pub struct AddressTypeToAddressCountVecs(ByAddressType>); +pub struct AddrTypeToAddrCountVecs(ByAddrType>); -impl From> for AddressTypeToAddressCountVecs { +impl From> for AddrTypeToAddrCountVecs { #[inline] - fn from(value: ByAddressType) -> Self { + fn from(value: ByAddrType) -> Self { Self(value) } } -impl AddressTypeToAddressCountVecs { +impl AddrTypeToAddrCountVecs { pub(crate) fn forced_import( db: &Database, name: &str, version: Version, indexes: &indexes::Vecs, ) -> Result { - Ok(Self::from(ByAddressType::::new_with_name( + Ok(Self::from(ByAddrType::::new_with_name( |type_name| { - AddressCountVecs::forced_import(db, &format!("{type_name}_{name}"), version, indexes) + AddrCountVecs::forced_import(db, &format!("{type_name}_{name}"), version, indexes) }, )?)) } @@ -138,8 +138,8 @@ impl AddressTypeToAddressCountVecs { } #[inline(always)] - pub(crate) fn push_height(&mut self, address_counts: &AddressTypeToAddressCount) { - for (vecs, &count) in self.0.values_mut().zip(address_counts.values()) { + pub(crate) fn push_height(&mut self, addr_counts: &AddrTypeToAddrCount) { + for (vecs, &count) in self.0.values_mut().zip(addr_counts.values()) { vecs.height.push(count.into()); } } @@ -157,13 +157,13 @@ impl AddressTypeToAddressCountVecs { } #[derive(Traversable)] -pub struct AddressCountsVecs { - pub all: AddressCountVecs, +pub struct AddrCountsVecs { + pub all: AddrCountVecs, #[traversable(flatten)] - pub by_address_type: AddressTypeToAddressCountVecs, + pub by_addr_type: AddrTypeToAddrCountVecs, } -impl AddressCountsVecs { +impl AddrCountsVecs { pub(crate) fn forced_import( db: &Database, name: &str, @@ -171,32 +171,32 @@ impl AddressCountsVecs { indexes: &indexes::Vecs, ) -> Result { Ok(Self { - all: AddressCountVecs::forced_import(db, name, version, indexes)?, - by_address_type: AddressTypeToAddressCountVecs::forced_import(db, name, version, indexes)?, + all: AddrCountVecs::forced_import(db, name, version, indexes)?, + by_addr_type: AddrTypeToAddrCountVecs::forced_import(db, name, version, indexes)?, }) } pub(crate) fn min_stateful_len(&self) -> usize { - self.all.height.len().min(self.by_address_type.min_stateful_len()) + self.all.height.len().min(self.by_addr_type.min_stateful_len()) } pub(crate) fn par_iter_height_mut( &mut self, ) -> impl ParallelIterator { rayon::iter::once(&mut self.all.height as &mut dyn AnyStoredVec) - .chain(self.by_address_type.par_iter_height_mut()) + .chain(self.by_addr_type.par_iter_height_mut()) } pub(crate) fn reset_height(&mut self) -> Result<()> { self.all.height.reset()?; - self.by_address_type.reset_height()?; + self.by_addr_type.reset_height()?; Ok(()) } #[inline(always)] - pub(crate) fn push_height(&mut self, total: u64, address_counts: &AddressTypeToAddressCount) { + pub(crate) fn push_height(&mut self, total: u64, addr_counts: &AddrTypeToAddrCount) { self.all.height.push(total.into()); - self.by_address_type.push_height(address_counts); + self.by_addr_type.push_height(addr_counts); } pub(crate) fn compute_rest( @@ -204,7 +204,7 @@ impl AddressCountsVecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let sources = self.by_address_type.by_height(); + let sources = self.by_addr_type.by_height(); self.all .height .compute_sum_of_others(starting_indexes.height, &sources, exit)?; diff --git a/crates/brk_computer/src/distribution/address/data.rs b/crates/brk_computer/src/distribution/addr/data.rs similarity index 80% rename from crates/brk_computer/src/distribution/address/data.rs rename to crates/brk_computer/src/distribution/addr/data.rs index c23cbacb6..260268df1 100644 --- a/crates/brk_computer/src/distribution/address/data.rs +++ b/crates/brk_computer/src/distribution/addr/data.rs @@ -1,19 +1,19 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - EmptyAddressData, EmptyAddressIndex, FundedAddressData, FundedAddressIndex, Height, + EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, Height, }; use rayon::prelude::*; use vecdb::{AnyStoredVec, BytesVec, Rw, Stamp, StorageMode, WritableVec}; /// Storage for both funded and empty address data. #[derive(Traversable)] -pub struct AddressesDataVecs { - pub funded: M::Stored>, - pub empty: M::Stored>, +pub struct AddrsDataVecs { + pub funded: M::Stored>, + pub empty: M::Stored>, } -impl AddressesDataVecs { +impl AddrsDataVecs { /// Get minimum stamped height across funded and empty data. pub(crate) fn min_stamped_len(&self) -> Height { Height::from(self.funded.stamp()) diff --git a/crates/brk_computer/src/distribution/address/delta.rs b/crates/brk_computer/src/distribution/addr/delta.rs similarity index 71% rename from crates/brk_computer/src/distribution/address/delta.rs rename to crates/brk_computer/src/distribution/addr/delta.rs index fd9670567..07c52329c 100644 --- a/crates/brk_computer/src/distribution/address/delta.rs +++ b/crates/brk_computer/src/distribution/addr/delta.rs @@ -1,4 +1,4 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_traversable::Traversable; use brk_types::{BasisPointsSigned32, StoredI64, StoredU64, Version}; @@ -7,7 +7,7 @@ use crate::{ internal::{CachedWindowStarts, LazyRollingDeltasFromHeight}, }; -use super::AddressCountsVecs; +use super::AddrCountsVecs; type AddrDelta = LazyRollingDeltasFromHeight; @@ -15,29 +15,29 @@ type AddrDelta = LazyRollingDeltasFromHeight, + pub by_addr_type: ByAddrType, } impl DeltaVecs { pub(crate) fn new( version: Version, - address_count: &AddressCountsVecs, + addr_count: &AddrCountsVecs, cached_starts: &CachedWindowStarts, indexes: &indexes::Vecs, ) -> Self { let version = version + Version::TWO; let all = LazyRollingDeltasFromHeight::new( - "address_count", + "addr_count", version, - &address_count.all.0.height, + &addr_count.all.0.height, cached_starts, indexes, ); - let by_address_type = address_count.by_address_type.map_with_name(|name, addr| { + let by_addr_type = addr_count.by_addr_type.map_with_name(|name, addr| { LazyRollingDeltasFromHeight::new( - &format!("{name}_address_count"), + &format!("{name}_addr_count"), version, &addr.0.height, cached_starts, @@ -47,7 +47,7 @@ impl DeltaVecs { Self { all, - by_address_type, + by_addr_type, } } } diff --git a/crates/brk_computer/src/distribution/address/indexes/any.rs b/crates/brk_computer/src/distribution/addr/indexes/any.rs similarity index 74% rename from crates/brk_computer/src/distribution/address/indexes/any.rs rename to crates/brk_computer/src/distribution/addr/indexes/any.rs index 2a0a08a22..88cdb3dcb 100644 --- a/crates/brk_computer/src/distribution/address/indexes/any.rs +++ b/crates/brk_computer/src/distribution/addr/indexes/any.rs @@ -1,11 +1,11 @@ use std::thread; -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::{Error, Result}; use brk_traversable::Traversable; use brk_types::{ - AnyAddressIndex, Height, OutputType, P2AAddressIndex, P2PK33AddressIndex, P2PK65AddressIndex, - P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, + AnyAddrIndex, Height, OutputType, P2AAddrIndex, P2PK33AddrIndex, P2PK65AddrIndex, + P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, TypeIndex, Version, }; use rayon::prelude::*; @@ -15,24 +15,24 @@ use vecdb::{ Rw, Stamp, StorageMode, WritableVec, }; -use super::super::AddressTypeToTypeIndexMap; +use super::super::AddrTypeToTypeIndexMap; const SAVED_STAMPED_CHANGES: u16 = 10; -/// Macro to define AnyAddressIndexesVecs and its methods. -macro_rules! define_any_address_indexes_vecs { +/// Macro to define AnyAddrIndexesVecs and its methods. +macro_rules! define_any_addr_indexes_vecs { ($(($field:ident, $variant:ident, $index:ty)),* $(,)?) => { #[derive(Traversable)] - pub struct AnyAddressIndexesVecs { - $(pub $field: M::Stored>,)* + pub struct AnyAddrIndexesVecs { + $(pub $field: M::Stored>,)* } - impl AnyAddressIndexesVecs { + impl AnyAddrIndexesVecs { /// Import from database. pub(crate) fn forced_import(db: &Database, version: Version) -> Result { Ok(Self { $($field: BytesVec::forced_import_with( - ImportOptions::new(db, "any_address_index", version) + ImportOptions::new(db, "any_addr_index", version) .with_saved_stamped_changes(SAVED_STAMPED_CHANGES), )?,)* }) @@ -59,10 +59,10 @@ macro_rules! define_any_address_indexes_vecs { /// Get address index for a given type and type_index. /// Uses get_any_or_read_at to check updated layer (needed after rollback). - pub(crate) fn get(&self, address_type: OutputType, type_index: TypeIndex, reader: &Reader) -> Result { - match address_type { + pub(crate) fn get(&self, addr_type: OutputType, type_index: TypeIndex, reader: &Reader) -> Result { + match addr_type { $(OutputType::$variant => Ok(self.$field.get_any_or_read_at(type_index.into(), reader)?.unwrap()),)* - _ => unreachable!("Invalid address type: {:?}", address_type), + _ => unreachable!("Invalid addr type: {:?}", addr_type), } } @@ -72,14 +72,14 @@ macro_rules! define_any_address_indexes_vecs { } } - impl AnyAddressIndexesVecs { + impl AnyAddrIndexesVecs { /// Get address index with single read (no caching). - pub fn get_once(&self, address_type: OutputType, type_index: TypeIndex) -> Result { - match address_type { + pub fn get_once(&self, addr_type: OutputType, type_index: TypeIndex) -> Result { + match addr_type { $(OutputType::$variant => self.$field .collect_one(<$index>::from(usize::from(type_index))) - .ok_or_else(|| Error::UnsupportedType(address_type.to_string())),)* - _ => Err(Error::UnsupportedType(address_type.to_string())), + .ok_or_else(|| Error::UnsupportedType(addr_type.to_string())),)* + _ => Err(Error::UnsupportedType(addr_type.to_string())), } } } @@ -87,28 +87,28 @@ macro_rules! define_any_address_indexes_vecs { } // Generate the struct and methods -define_any_address_indexes_vecs!( - (p2a, P2A, P2AAddressIndex), - (p2pk33, P2PK33, P2PK33AddressIndex), - (p2pk65, P2PK65, P2PK65AddressIndex), - (p2pkh, P2PKH, P2PKHAddressIndex), - (p2sh, P2SH, P2SHAddressIndex), - (p2tr, P2TR, P2TRAddressIndex), - (p2wpkh, P2WPKH, P2WPKHAddressIndex), - (p2wsh, P2WSH, P2WSHAddressIndex), +define_any_addr_indexes_vecs!( + (p2a, P2A, P2AAddrIndex), + (p2pk33, P2PK33, P2PK33AddrIndex), + (p2pk65, P2PK65, P2PK65AddrIndex), + (p2pkh, P2PKH, P2PKHAddrIndex), + (p2sh, P2SH, P2SHAddrIndex), + (p2tr, P2TR, P2TRAddrIndex), + (p2wpkh, P2WPKH, P2WPKHAddrIndex), + (p2wsh, P2WSH, P2WSHAddrIndex), ); -impl AnyAddressIndexesVecs { +impl AnyAddrIndexesVecs { /// Process index updates in parallel by address type. /// Accepts two maps (e.g. from empty and funded processing) and merges per-thread. /// Updates existing entries and pushes new ones (sorted). /// Returns (update_count, push_count). pub(crate) fn par_batch_update( &mut self, - updates1: AddressTypeToTypeIndexMap, - updates2: AddressTypeToTypeIndexMap, + updates1: AddrTypeToTypeIndexMap, + updates2: AddrTypeToTypeIndexMap, ) -> Result<(usize, usize)> { - let ByAddressType { + let ByAddrType { p2a: u1_p2a, p2pk33: u1_p2pk33, p2pk65: u1_p2pk65, @@ -119,7 +119,7 @@ impl AnyAddressIndexesVecs { p2wsh: u1_p2wsh, } = updates1.into_inner(); - let ByAddressType { + let ByAddrType { p2a: u2_p2a, p2pk33: u2_p2pk33, p2pk65: u2_p2pk65, @@ -169,9 +169,9 @@ impl AnyAddressIndexesVecs { /// Process updates for a single address type's BytesVec, merging two maps. fn process_single_type_merged( - vec: &mut BytesVec, - map1: FxHashMap, - map2: FxHashMap, + vec: &mut BytesVec, + map1: FxHashMap, + map2: FxHashMap, ) -> Result<(usize, usize)> { let current_len = vec.len(); let mut pushes = Vec::with_capacity(map1.len() + map2.len()); diff --git a/crates/brk_computer/src/distribution/address/indexes/mod.rs b/crates/brk_computer/src/distribution/addr/indexes/mod.rs similarity index 100% rename from crates/brk_computer/src/distribution/address/indexes/mod.rs rename to crates/brk_computer/src/distribution/addr/indexes/mod.rs diff --git a/crates/brk_computer/src/distribution/addr/mod.rs b/crates/brk_computer/src/distribution/addr/mod.rs new file mode 100644 index 000000000..64d997fa4 --- /dev/null +++ b/crates/brk_computer/src/distribution/addr/mod.rs @@ -0,0 +1,17 @@ +mod activity; +mod addr_count; +mod data; +mod delta; +mod indexes; +mod new_addr_count; +mod total_addr_count; +mod type_map; + +pub use activity::{AddrActivityVecs, AddrTypeToActivityCounts}; +pub use addr_count::{AddrCountsVecs, AddrTypeToAddrCount}; +pub use data::AddrsDataVecs; +pub use delta::DeltaVecs; +pub use indexes::AnyAddrIndexesVecs; +pub use new_addr_count::NewAddrCountVecs; +pub use total_addr_count::TotalAddrCountVecs; +pub use type_map::{AddrTypeToTypeIndexMap, AddrTypeToVec, HeightToAddrTypeToVec}; diff --git a/crates/brk_computer/src/distribution/address/new_address_count.rs b/crates/brk_computer/src/distribution/addr/new_addr_count.rs similarity index 68% rename from crates/brk_computer/src/distribution/address/new_address_count.rs rename to crates/brk_computer/src/distribution/addr/new_addr_count.rs index bd89489dc..ee8221894 100644 --- a/crates/brk_computer/src/distribution/address/new_address_count.rs +++ b/crates/brk_computer/src/distribution/addr/new_addr_count.rs @@ -1,4 +1,4 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, StoredU64, Version}; @@ -9,17 +9,17 @@ use crate::{ internal::{CachedWindowStarts, PerBlockCumulativeWithSums}, }; -use super::TotalAddressCountVecs; +use super::TotalAddrCountVecs; /// New address count per block (global + per-type) #[derive(Traversable)] -pub struct NewAddressCountVecs { +pub struct NewAddrCountVecs { pub all: PerBlockCumulativeWithSums, #[traversable(flatten)] - pub by_address_type: ByAddressType>, + pub by_addr_type: ByAddrType>, } -impl NewAddressCountVecs { +impl NewAddrCountVecs { pub(crate) fn forced_import( db: &Database, version: Version, @@ -28,16 +28,16 @@ impl NewAddressCountVecs { ) -> Result { let all = PerBlockCumulativeWithSums::forced_import( db, - "new_address_count", + "new_addr_count", version, indexes, cached_starts, )?; - let by_address_type = ByAddressType::new_with_name(|name| { + let by_addr_type = ByAddrType::new_with_name(|name| { PerBlockCumulativeWithSums::forced_import( db, - &format!("{name}_new_address_count"), + &format!("{name}_new_addr_count"), version, indexes, cached_starts, @@ -46,24 +46,24 @@ impl NewAddressCountVecs { Ok(Self { all, - by_address_type, + by_addr_type, }) } pub(crate) fn compute( &mut self, max_from: Height, - total_address_count: &TotalAddressCountVecs, + total_addr_count: &TotalAddrCountVecs, exit: &Exit, ) -> Result<()> { self.all.compute(max_from, exit, |height_vec| { - Ok(height_vec.compute_change(max_from, &total_address_count.all.height, 1, exit)?) + Ok(height_vec.compute_change(max_from, &total_addr_count.all.height, 1, exit)?) })?; for ((_, new), (_, total)) in self - .by_address_type + .by_addr_type .iter_mut() - .zip(total_address_count.by_address_type.iter()) + .zip(total_addr_count.by_addr_type.iter()) { new.compute(max_from, exit, |height_vec| { Ok(height_vec.compute_change(max_from, &total.height, 1, exit)?) diff --git a/crates/brk_computer/src/distribution/address/total_address_count.rs b/crates/brk_computer/src/distribution/addr/total_addr_count.rs similarity index 56% rename from crates/brk_computer/src/distribution/address/total_address_count.rs rename to crates/brk_computer/src/distribution/addr/total_addr_count.rs index 97c168e9e..55d50081a 100644 --- a/crates/brk_computer/src/distribution/address/total_address_count.rs +++ b/crates/brk_computer/src/distribution/addr/total_addr_count.rs @@ -1,4 +1,4 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Height, StoredU64, Version}; @@ -6,29 +6,29 @@ use vecdb::{Database, Exit, Rw, StorageMode}; use crate::{indexes, internal::PerBlock}; -use super::AddressCountsVecs; +use super::AddrCountsVecs; /// Total address count (global + per-type) with all derived indexes #[derive(Traversable)] -pub struct TotalAddressCountVecs { +pub struct TotalAddrCountVecs { pub all: PerBlock, #[traversable(flatten)] - pub by_address_type: ByAddressType>, + pub by_addr_type: ByAddrType>, } -impl TotalAddressCountVecs { +impl TotalAddrCountVecs { pub(crate) fn forced_import( db: &Database, version: Version, indexes: &indexes::Vecs, ) -> Result { - let all = PerBlock::forced_import(db, "total_address_count", version, indexes)?; + let all = PerBlock::forced_import(db, "total_addr_count", version, indexes)?; - let by_address_type: ByAddressType> = - ByAddressType::new_with_name(|name| { + let by_addr_type: ByAddrType> = + ByAddrType::new_with_name(|name| { PerBlock::forced_import( db, - &format!("{name}_total_address_count"), + &format!("{name}_total_addr_count"), version, indexes, ) @@ -36,30 +36,30 @@ impl TotalAddressCountVecs { Ok(Self { all, - by_address_type, + by_addr_type, }) } - /// Eagerly compute total = address_count + empty_address_count. + /// Eagerly compute total = addr_count + empty_addr_count. pub(crate) fn compute( &mut self, max_from: Height, - address_count: &AddressCountsVecs, - empty_address_count: &AddressCountsVecs, + addr_count: &AddrCountsVecs, + empty_addr_count: &AddrCountsVecs, exit: &Exit, ) -> Result<()> { self.all.height.compute_add( max_from, - &address_count.all.height, - &empty_address_count.all.height, + &addr_count.all.height, + &empty_addr_count.all.height, exit, )?; - for ((_, total), ((_, addr), (_, empty))) in self.by_address_type.iter_mut().zip( - address_count - .by_address_type + for ((_, total), ((_, addr), (_, empty))) in self.by_addr_type.iter_mut().zip( + addr_count + .by_addr_type .iter() - .zip(empty_address_count.by_address_type.iter()), + .zip(empty_addr_count.by_addr_type.iter()), ) { total .height diff --git a/crates/brk_computer/src/distribution/address/type_map/height_vec.rs b/crates/brk_computer/src/distribution/addr/type_map/height_vec.rs similarity index 59% rename from crates/brk_computer/src/distribution/address/type_map/height_vec.rs rename to crates/brk_computer/src/distribution/addr/type_map/height_vec.rs index 3ff51503e..eec89e8d7 100644 --- a/crates/brk_computer/src/distribution/address/type_map/height_vec.rs +++ b/crates/brk_computer/src/distribution/addr/type_map/height_vec.rs @@ -2,13 +2,13 @@ use brk_types::Height; use derive_more::{Deref, DerefMut}; use rustc_hash::FxHashMap; -use super::vec::AddressTypeToVec; +use super::vec::AddrTypeToVec; -/// Hashmap from Height to AddressTypeToVec. +/// Hashmap from Height to AddrTypeToVec. #[derive(Debug, Default, Deref, DerefMut)] -pub struct HeightToAddressTypeToVec(FxHashMap>); +pub struct HeightToAddrTypeToVec(FxHashMap>); -impl HeightToAddressTypeToVec { +impl HeightToAddrTypeToVec { /// Create with pre-allocated capacity for unique heights. pub(crate) fn with_capacity(capacity: usize) -> Self { Self(FxHashMap::with_capacity_and_hasher( @@ -18,9 +18,9 @@ impl HeightToAddressTypeToVec { } } -impl HeightToAddressTypeToVec { - /// Consume and iterate over (Height, AddressTypeToVec) pairs. - pub(crate) fn into_iter(self) -> impl Iterator)> { +impl HeightToAddrTypeToVec { + /// Consume and iterate over (Height, AddrTypeToVec) pairs. + pub(crate) fn into_iter(self) -> impl Iterator)> { self.0.into_iter() } } diff --git a/crates/brk_computer/src/distribution/address/type_map/index_map.rs b/crates/brk_computer/src/distribution/addr/type_map/index_map.rs similarity index 84% rename from crates/brk_computer/src/distribution/address/type_map/index_map.rs rename to crates/brk_computer/src/distribution/addr/type_map/index_map.rs index 17aa1569a..91c901688 100644 --- a/crates/brk_computer/src/distribution/address/type_map/index_map.rs +++ b/crates/brk_computer/src/distribution/addr/type_map/index_map.rs @@ -1,6 +1,6 @@ use std::{collections::hash_map::Entry, mem}; -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_types::{OutputType, TypeIndex}; use derive_more::{Deref, DerefMut}; use rustc_hash::FxHashMap; @@ -8,11 +8,11 @@ use smallvec::{Array, SmallVec}; /// A hashmap for each address type, keyed by TypeIndex. #[derive(Debug, Deref, DerefMut)] -pub struct AddressTypeToTypeIndexMap(ByAddressType>); +pub struct AddrTypeToTypeIndexMap(ByAddrType>); -impl Default for AddressTypeToTypeIndexMap { +impl Default for AddrTypeToTypeIndexMap { fn default() -> Self { - Self(ByAddressType { + Self(ByAddrType { p2a: FxHashMap::default(), p2pk33: FxHashMap::default(), p2pk65: FxHashMap::default(), @@ -25,10 +25,10 @@ impl Default for AddressTypeToTypeIndexMap { } } -impl AddressTypeToTypeIndexMap { +impl AddrTypeToTypeIndexMap { /// Create with pre-allocated capacity per address type. pub(crate) fn with_capacity(capacity: usize) -> Self { - Self(ByAddressType { + Self(ByAddrType { p2a: FxHashMap::with_capacity_and_hasher(capacity, Default::default()), p2pk33: FxHashMap::with_capacity_and_hasher(capacity, Default::default()), p2pk65: FxHashMap::with_capacity_and_hasher(capacity, Default::default()), @@ -62,11 +62,11 @@ impl AddressTypeToTypeIndexMap { /// Insert a value for a specific address type and type_index. pub(crate) fn insert_for_type( &mut self, - address_type: OutputType, + addr_type: OutputType, type_index: TypeIndex, value: T, ) { - self.get_mut(address_type).unwrap().insert(type_index, value); + self.get_mut(addr_type).unwrap().insert(type_index, value); } /// Consume and iterate over entries by address type. @@ -75,8 +75,8 @@ impl AddressTypeToTypeIndexMap { self.0.into_iter() } - /// Consume and return the inner ByAddressType. - pub(crate) fn into_inner(self) -> ByAddressType> { + /// Consume and return the inner ByAddrType. + pub(crate) fn into_inner(self) -> ByAddrType> { self.0 } @@ -88,14 +88,14 @@ impl AddressTypeToTypeIndexMap { } } -impl AddressTypeToTypeIndexMap> +impl AddrTypeToTypeIndexMap> where T: Array, { /// Merge two maps of SmallVec values, concatenating vectors. pub(crate) fn merge_vec(mut self, other: Self) -> Self { - for (address_type, other_map) in other.0.into_iter() { - let self_map = self.0.get_mut_unwrap(address_type); + for (addr_type, other_map) in other.0.into_iter() { + let self_map = self.0.get_mut_unwrap(addr_type); for (type_index, mut other_vec) in other_map { match self_map.entry(type_index) { Entry::Occupied(mut entry) => { diff --git a/crates/brk_computer/src/distribution/address/type_map/mod.rs b/crates/brk_computer/src/distribution/addr/type_map/mod.rs similarity index 100% rename from crates/brk_computer/src/distribution/address/type_map/mod.rs rename to crates/brk_computer/src/distribution/addr/type_map/mod.rs diff --git a/crates/brk_computer/src/distribution/address/type_map/vec.rs b/crates/brk_computer/src/distribution/addr/type_map/vec.rs similarity index 72% rename from crates/brk_computer/src/distribution/address/type_map/vec.rs rename to crates/brk_computer/src/distribution/addr/type_map/vec.rs index 45d5ef9d0..a43821800 100644 --- a/crates/brk_computer/src/distribution/address/type_map/vec.rs +++ b/crates/brk_computer/src/distribution/addr/type_map/vec.rs @@ -1,13 +1,13 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use derive_more::{Deref, DerefMut}; /// A vector for each address type. #[derive(Debug, Deref, DerefMut)] -pub struct AddressTypeToVec(ByAddressType>); +pub struct AddrTypeToVec(ByAddrType>); -impl Default for AddressTypeToVec { +impl Default for AddrTypeToVec { fn default() -> Self { - Self(ByAddressType { + Self(ByAddrType { p2a: vec![], p2pk33: vec![], p2pk65: vec![], @@ -20,10 +20,10 @@ impl Default for AddressTypeToVec { } } -impl AddressTypeToVec { +impl AddrTypeToVec { /// Create with pre-allocated capacity per address type. pub(crate) fn with_capacity(capacity: usize) -> Self { - Self(ByAddressType { + Self(ByAddrType { p2a: Vec::with_capacity(capacity), p2pk33: Vec::with_capacity(capacity), p2pk65: Vec::with_capacity(capacity), @@ -36,9 +36,9 @@ impl AddressTypeToVec { } } -impl AddressTypeToVec { - /// Unwrap the inner ByAddressType. - pub(crate) fn unwrap(self) -> ByAddressType> { +impl AddrTypeToVec { + /// Unwrap the inner ByAddrType. + pub(crate) fn unwrap(self) -> ByAddrType> { self.0 } } diff --git a/crates/brk_computer/src/distribution/address/mod.rs b/crates/brk_computer/src/distribution/address/mod.rs deleted file mode 100644 index 5ef4caadd..000000000 --- a/crates/brk_computer/src/distribution/address/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -mod activity; -mod address_count; -mod data; -mod delta; -mod indexes; -mod new_address_count; -mod total_address_count; -mod type_map; - -pub use activity::{AddressActivityVecs, AddressTypeToActivityCounts}; -pub use address_count::{AddressCountsVecs, AddressTypeToAddressCount}; -pub use data::AddressesDataVecs; -pub use delta::DeltaVecs; -pub use indexes::AnyAddressIndexesVecs; -pub use new_address_count::NewAddressCountVecs; -pub use total_address_count::TotalAddressCountVecs; -pub use type_map::{AddressTypeToTypeIndexMap, AddressTypeToVec, HeightToAddressTypeToVec}; diff --git a/crates/brk_computer/src/distribution/block/cache/addr.rs b/crates/brk_computer/src/distribution/block/cache/addr.rs new file mode 100644 index 000000000..9d1740d9a --- /dev/null +++ b/crates/brk_computer/src/distribution/block/cache/addr.rs @@ -0,0 +1,138 @@ +use brk_cohort::ByAddrType; +use brk_error::Result; +use brk_types::{ + AnyAddrDataIndexEnum, EmptyAddrData, FundedAddrData, OutputType, TxIndex, TypeIndex, +}; +use smallvec::SmallVec; + +use crate::distribution::{ + addr::{AddrTypeToTypeIndexMap, AddrsDataVecs, AnyAddrIndexesVecs}, + compute::VecsReaders, +}; + +use super::super::cohort::{WithAddrDataSource, update_tx_counts}; +use super::lookup::AddrLookup; + +/// Cache for address data within a flush interval. +pub struct AddrCache { + /// Addrs with non-zero balance + funded: AddrTypeToTypeIndexMap>, + /// Addrs that became empty (zero balance) + empty: AddrTypeToTypeIndexMap>, +} + +impl Default for AddrCache { + fn default() -> Self { + Self::new() + } +} + +impl AddrCache { + pub(crate) fn new() -> Self { + Self { + funded: AddrTypeToTypeIndexMap::default(), + empty: AddrTypeToTypeIndexMap::default(), + } + } + + /// Check if address is in cache (either funded or empty). + #[inline] + pub(crate) fn contains(&self, addr_type: OutputType, type_index: TypeIndex) -> bool { + self.funded + .get(addr_type) + .is_some_and(|m| m.contains_key(&type_index)) + || self + .empty + .get(addr_type) + .is_some_and(|m| m.contains_key(&type_index)) + } + + /// Merge address data into funded cache. + #[inline] + pub(crate) fn merge_funded( + &mut self, + data: AddrTypeToTypeIndexMap>, + ) { + self.funded.merge_mut(data); + } + + /// Create an AddrLookup view into this cache. + #[inline] + pub(crate) fn as_lookup(&mut self) -> AddrLookup<'_> { + AddrLookup { + funded: &mut self.funded, + empty: &mut self.empty, + } + } + + /// Update transaction counts for addresses. + pub(crate) fn update_tx_counts( + &mut self, + tx_index_vecs: AddrTypeToTypeIndexMap>, + ) { + update_tx_counts(&mut self.funded, &mut self.empty, tx_index_vecs); + } + + /// Take the cache contents for flushing, leaving empty caches. + pub(crate) fn take( + &mut self, + ) -> ( + AddrTypeToTypeIndexMap>, + AddrTypeToTypeIndexMap>, + ) { + ( + std::mem::take(&mut self.empty), + std::mem::take(&mut self.funded), + ) + } +} + +/// Load address data from storage or create new. +/// +/// Returns None if address is already in cache (funded or empty). +#[allow(clippy::too_many_arguments)] +pub(crate) fn load_uncached_addr_data( + addr_type: OutputType, + type_index: TypeIndex, + first_addr_indexes: &ByAddrType, + cache: &AddrCache, + vr: &VecsReaders, + any_addr_indexes: &AnyAddrIndexesVecs, + addrs_data: &AddrsDataVecs, +) -> Result>> { + // Check if this is a new address (type_index >= first for this height) + let first = *first_addr_indexes.get(addr_type).unwrap(); + if first <= type_index { + return Ok(Some(WithAddrDataSource::New( + FundedAddrData::default(), + ))); + } + + // Skip if already in cache + if cache.contains(addr_type, type_index) { + return Ok(None); + } + + // Read from storage + let reader = vr.addr_reader(addr_type); + let any_addr_index = any_addr_indexes.get(addr_type, type_index, reader)?; + + Ok(Some(match any_addr_index.to_enum() { + AnyAddrDataIndexEnum::Funded(funded_index) => { + let reader = &vr.any_addr_index_to_any_addr_data.funded; + let funded_data = addrs_data + .funded + .get_any_or_read_at(funded_index.into(), reader)? + .unwrap(); + WithAddrDataSource::FromFunded(funded_index, funded_data) + } + AnyAddrDataIndexEnum::Empty(empty_index) => { + let reader = &vr.any_addr_index_to_any_addr_data.empty; + let empty_data = addrs_data + .empty + .get_any_or_read_at(empty_index.into(), reader)? + .unwrap(); + WithAddrDataSource::FromEmpty(empty_index, empty_data.into()) + } + })) +} diff --git a/crates/brk_computer/src/distribution/block/cache/address.rs b/crates/brk_computer/src/distribution/block/cache/address.rs deleted file mode 100644 index 9f941ab49..000000000 --- a/crates/brk_computer/src/distribution/block/cache/address.rs +++ /dev/null @@ -1,138 +0,0 @@ -use brk_cohort::ByAddressType; -use brk_error::Result; -use brk_types::{ - AnyAddressDataIndexEnum, EmptyAddressData, FundedAddressData, OutputType, TxIndex, TypeIndex, -}; -use smallvec::SmallVec; - -use crate::distribution::{ - address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAddressIndexesVecs}, - compute::VecsReaders, -}; - -use super::super::cohort::{WithAddressDataSource, update_tx_counts}; -use super::lookup::AddressLookup; - -/// Cache for address data within a flush interval. -pub struct AddressCache { - /// Addresses with non-zero balance - funded: AddressTypeToTypeIndexMap>, - /// Addresses that became empty (zero balance) - empty: AddressTypeToTypeIndexMap>, -} - -impl Default for AddressCache { - fn default() -> Self { - Self::new() - } -} - -impl AddressCache { - pub(crate) fn new() -> Self { - Self { - funded: AddressTypeToTypeIndexMap::default(), - empty: AddressTypeToTypeIndexMap::default(), - } - } - - /// Check if address is in cache (either funded or empty). - #[inline] - pub(crate) fn contains(&self, address_type: OutputType, type_index: TypeIndex) -> bool { - self.funded - .get(address_type) - .is_some_and(|m| m.contains_key(&type_index)) - || self - .empty - .get(address_type) - .is_some_and(|m| m.contains_key(&type_index)) - } - - /// Merge address data into funded cache. - #[inline] - pub(crate) fn merge_funded( - &mut self, - data: AddressTypeToTypeIndexMap>, - ) { - self.funded.merge_mut(data); - } - - /// Create an AddressLookup view into this cache. - #[inline] - pub(crate) fn as_lookup(&mut self) -> AddressLookup<'_> { - AddressLookup { - funded: &mut self.funded, - empty: &mut self.empty, - } - } - - /// Update transaction counts for addresses. - pub(crate) fn update_tx_counts( - &mut self, - tx_index_vecs: AddressTypeToTypeIndexMap>, - ) { - update_tx_counts(&mut self.funded, &mut self.empty, tx_index_vecs); - } - - /// Take the cache contents for flushing, leaving empty caches. - pub(crate) fn take( - &mut self, - ) -> ( - AddressTypeToTypeIndexMap>, - AddressTypeToTypeIndexMap>, - ) { - ( - std::mem::take(&mut self.empty), - std::mem::take(&mut self.funded), - ) - } -} - -/// Load address data from storage or create new. -/// -/// Returns None if address is already in cache (funded or empty). -#[allow(clippy::too_many_arguments)] -pub(crate) fn load_uncached_address_data( - address_type: OutputType, - type_index: TypeIndex, - first_address_indexes: &ByAddressType, - cache: &AddressCache, - vr: &VecsReaders, - any_address_indexes: &AnyAddressIndexesVecs, - addresses_data: &AddressesDataVecs, -) -> Result>> { - // Check if this is a new address (type_index >= first for this height) - let first = *first_address_indexes.get(address_type).unwrap(); - if first <= type_index { - return Ok(Some(WithAddressDataSource::New( - FundedAddressData::default(), - ))); - } - - // Skip if already in cache - if cache.contains(address_type, type_index) { - return Ok(None); - } - - // Read from storage - let reader = vr.address_reader(address_type); - let any_address_index = any_address_indexes.get(address_type, type_index, reader)?; - - Ok(Some(match any_address_index.to_enum() { - AnyAddressDataIndexEnum::Funded(funded_index) => { - let reader = &vr.any_address_index_to_any_address_data.funded; - let funded_data = addresses_data - .funded - .get_any_or_read_at(funded_index.into(), reader)? - .unwrap(); - WithAddressDataSource::FromFunded(funded_index, funded_data) - } - AnyAddressDataIndexEnum::Empty(empty_index) => { - let reader = &vr.any_address_index_to_any_address_data.empty; - let empty_data = addresses_data - .empty - .get_any_or_read_at(empty_index.into(), reader)? - .unwrap(); - WithAddressDataSource::FromEmpty(empty_index, empty_data.into()) - } - })) -} diff --git a/crates/brk_computer/src/distribution/block/cache/lookup.rs b/crates/brk_computer/src/distribution/block/cache/lookup.rs index e988277fb..5dfa2bf26 100644 --- a/crates/brk_computer/src/distribution/block/cache/lookup.rs +++ b/crates/brk_computer/src/distribution/block/cache/lookup.rs @@ -1,8 +1,8 @@ -use brk_types::{EmptyAddressData, FundedAddressData, OutputType, TypeIndex}; +use brk_types::{EmptyAddrData, FundedAddrData, OutputType, TypeIndex}; -use crate::distribution::address::AddressTypeToTypeIndexMap; +use crate::distribution::addr::AddrTypeToTypeIndexMap; -use super::super::cohort::WithAddressDataSource; +use super::super::cohort::WithAddrDataSource; /// Tracking status of an address - determines cohort update strategy. #[derive(Clone, Copy)] @@ -16,18 +16,18 @@ pub enum TrackingStatus { } /// Context for looking up and storing address data during block processing. -pub struct AddressLookup<'a> { - pub funded: &'a mut AddressTypeToTypeIndexMap>, - pub empty: &'a mut AddressTypeToTypeIndexMap>, +pub struct AddrLookup<'a> { + pub funded: &'a mut AddrTypeToTypeIndexMap>, + pub empty: &'a mut AddrTypeToTypeIndexMap>, } -impl<'a> AddressLookup<'a> { +impl<'a> AddrLookup<'a> { pub(crate) fn get_or_create_for_receive( &mut self, output_type: OutputType, type_index: TypeIndex, ) -> ( - &mut WithAddressDataSource, + &mut WithAddrDataSource, TrackingStatus, ) { use std::collections::hash_map::Entry; @@ -36,7 +36,7 @@ impl<'a> AddressLookup<'a> { match map.entry(type_index) { Entry::Occupied(entry) => { - // Address is in cache. Need to determine if it's been processed + // Addr is in cache. Need to determine if it's been processed // by process_received (added to a cohort) or just funded this block. // // - If wrapper is New AND funded_txo_count == 0: hasn't received yet, @@ -47,15 +47,15 @@ impl<'a> AddressLookup<'a> { // - If wrapper is FromEmpty AND utxo_count == 0: still empty → WasEmpty // - If wrapper is FromEmpty AND utxo_count > 0: already received → Tracked let status = match entry.get() { - WithAddressDataSource::New(data) => { + WithAddrDataSource::New(data) => { if data.funded_txo_count == 0 { TrackingStatus::New } else { TrackingStatus::Tracked } } - WithAddressDataSource::FromFunded(..) => TrackingStatus::Tracked, - WithAddressDataSource::FromEmpty(_, data) => { + WithAddrDataSource::FromFunded(..) => TrackingStatus::Tracked, + WithAddrDataSource::FromEmpty(_, data) => { if data.utxo_count() == 0 { TrackingStatus::WasEmpty } else { @@ -72,7 +72,7 @@ impl<'a> AddressLookup<'a> { return (entry.insert(empty_data.into()), TrackingStatus::WasEmpty); } ( - entry.insert(WithAddressDataSource::New(FundedAddressData::default())), + entry.insert(WithAddrDataSource::New(FundedAddrData::default())), TrackingStatus::New, ) } @@ -84,12 +84,12 @@ impl<'a> AddressLookup<'a> { &mut self, output_type: OutputType, type_index: TypeIndex, - ) -> &mut WithAddressDataSource { + ) -> &mut WithAddrDataSource { self.funded .get_mut(output_type) .unwrap() .get_mut(&type_index) - .expect("Address must exist for send") + .expect("Addr must exist for send") } /// Move address from funded to empty set. diff --git a/crates/brk_computer/src/distribution/block/cache/mod.rs b/crates/brk_computer/src/distribution/block/cache/mod.rs index e567f878a..0574856d2 100644 --- a/crates/brk_computer/src/distribution/block/cache/mod.rs +++ b/crates/brk_computer/src/distribution/block/cache/mod.rs @@ -1,5 +1,5 @@ -mod address; +mod addr; mod lookup; -pub use address::*; +pub use addr::*; pub use lookup::*; diff --git a/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs b/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs new file mode 100644 index 000000000..8ca353974 --- /dev/null +++ b/crates/brk_computer/src/distribution/block/cohort/addr_updates.rs @@ -0,0 +1,152 @@ +use brk_error::Result; +use brk_types::{ + AnyAddrIndex, EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, + OutputType, TypeIndex, +}; +use vecdb::AnyVec; + +use crate::distribution::{AddrTypeToTypeIndexMap, AddrsDataVecs}; + +use super::with_source::WithAddrDataSource; + +/// Process funded address data updates. +/// +/// Handles: +/// - New funded address: push to funded storage +/// - Updated funded address (was funded): update in place +/// - Transition empty -> funded: delete from empty, push to funded +pub(crate) fn process_funded_addrs( + addrs_data: &mut AddrsDataVecs, + funded_updates: AddrTypeToTypeIndexMap>, +) -> Result> { + let total: usize = funded_updates.iter().map(|(_, m)| m.len()).sum(); + + let mut updates: Vec<(FundedAddrIndex, FundedAddrData)> = Vec::with_capacity(total); + let mut deletes: Vec = Vec::with_capacity(total); + let mut pushes: Vec<(OutputType, TypeIndex, FundedAddrData)> = Vec::with_capacity(total); + + for (addr_type, items) in funded_updates.into_iter() { + for (type_index, source) in items { + match source { + WithAddrDataSource::New(data) => { + pushes.push((addr_type, type_index, data)); + } + WithAddrDataSource::FromFunded(index, data) => { + updates.push((index, data)); + } + WithAddrDataSource::FromEmpty(empty_index, data) => { + deletes.push(empty_index); + pushes.push((addr_type, type_index, data)); + } + } + } + } + + // Phase 1: Deletes (creates holes) + for empty_index in deletes { + addrs_data.empty.delete(empty_index); + } + + // Phase 2: Updates (in-place) + for (index, data) in updates { + addrs_data.funded.update(index, data)?; + } + + // Phase 3: Pushes (fill holes first, then pure pushes) + let mut result = AddrTypeToTypeIndexMap::with_capacity(pushes.len() / 4); + let holes_count = addrs_data.funded.holes().len(); + let mut pushes_iter = pushes.into_iter(); + + for (addr_type, type_index, data) in pushes_iter.by_ref().take(holes_count) { + let index = addrs_data.funded.fill_first_hole_or_push(data)?; + result + .get_mut(addr_type) + .unwrap() + .insert(type_index, AnyAddrIndex::from(index)); + } + + // Pure pushes - no holes remain + addrs_data.funded.reserve_pushed(pushes_iter.len()); + let mut next_index = addrs_data.funded.len(); + for (addr_type, type_index, data) in pushes_iter { + addrs_data.funded.push(data); + result.get_mut(addr_type).unwrap().insert( + type_index, + AnyAddrIndex::from(FundedAddrIndex::from(next_index)), + ); + next_index += 1; + } + + Ok(result) +} + +/// Process empty address data updates. +/// +/// Handles: +/// - New empty address: push to empty storage +/// - Updated empty address (was empty): update in place +/// - Transition funded -> empty: delete from funded, push to empty +pub(crate) fn process_empty_addrs( + addrs_data: &mut AddrsDataVecs, + empty_updates: AddrTypeToTypeIndexMap>, +) -> Result> { + let total: usize = empty_updates.iter().map(|(_, m)| m.len()).sum(); + + let mut updates: Vec<(EmptyAddrIndex, EmptyAddrData)> = Vec::with_capacity(total); + let mut deletes: Vec = Vec::with_capacity(total); + let mut pushes: Vec<(OutputType, TypeIndex, EmptyAddrData)> = Vec::with_capacity(total); + + for (addr_type, items) in empty_updates.into_iter() { + for (type_index, source) in items { + match source { + WithAddrDataSource::New(data) => { + pushes.push((addr_type, type_index, data)); + } + WithAddrDataSource::FromEmpty(index, data) => { + updates.push((index, data)); + } + WithAddrDataSource::FromFunded(funded_index, data) => { + deletes.push(funded_index); + pushes.push((addr_type, type_index, data)); + } + } + } + } + + // Phase 1: Deletes (creates holes) + for funded_index in deletes { + addrs_data.funded.delete(funded_index); + } + + // Phase 2: Updates (in-place) + for (index, data) in updates { + addrs_data.empty.update(index, data)?; + } + + // Phase 3: Pushes (fill holes first, then pure pushes) + let mut result = AddrTypeToTypeIndexMap::with_capacity(pushes.len() / 4); + let holes_count = addrs_data.empty.holes().len(); + let mut pushes_iter = pushes.into_iter(); + + for (addr_type, type_index, data) in pushes_iter.by_ref().take(holes_count) { + let index = addrs_data.empty.fill_first_hole_or_push(data)?; + result + .get_mut(addr_type) + .unwrap() + .insert(type_index, AnyAddrIndex::from(index)); + } + + // Pure pushes - no holes remain + addrs_data.empty.reserve_pushed(pushes_iter.len()); + let mut next_index = addrs_data.empty.len(); + for (addr_type, type_index, data) in pushes_iter { + addrs_data.empty.push(data); + result.get_mut(addr_type).unwrap().insert( + type_index, + AnyAddrIndex::from(EmptyAddrIndex::from(next_index)), + ); + next_index += 1; + } + + Ok(result) +} diff --git a/crates/brk_computer/src/distribution/block/cohort/address_updates.rs b/crates/brk_computer/src/distribution/block/cohort/address_updates.rs deleted file mode 100644 index 480715a1a..000000000 --- a/crates/brk_computer/src/distribution/block/cohort/address_updates.rs +++ /dev/null @@ -1,152 +0,0 @@ -use brk_error::Result; -use brk_types::{ - AnyAddressIndex, EmptyAddressData, EmptyAddressIndex, FundedAddressData, FundedAddressIndex, - OutputType, TypeIndex, -}; -use vecdb::AnyVec; - -use crate::distribution::{AddressTypeToTypeIndexMap, AddressesDataVecs}; - -use super::with_source::WithAddressDataSource; - -/// Process funded address data updates. -/// -/// Handles: -/// - New funded address: push to funded storage -/// - Updated funded address (was funded): update in place -/// - Transition empty -> funded: delete from empty, push to funded -pub(crate) fn process_funded_addresses( - addresses_data: &mut AddressesDataVecs, - funded_updates: AddressTypeToTypeIndexMap>, -) -> Result> { - let total: usize = funded_updates.iter().map(|(_, m)| m.len()).sum(); - - let mut updates: Vec<(FundedAddressIndex, FundedAddressData)> = Vec::with_capacity(total); - let mut deletes: Vec = Vec::with_capacity(total); - let mut pushes: Vec<(OutputType, TypeIndex, FundedAddressData)> = Vec::with_capacity(total); - - for (address_type, items) in funded_updates.into_iter() { - for (type_index, source) in items { - match source { - WithAddressDataSource::New(data) => { - pushes.push((address_type, type_index, data)); - } - WithAddressDataSource::FromFunded(index, data) => { - updates.push((index, data)); - } - WithAddressDataSource::FromEmpty(empty_index, data) => { - deletes.push(empty_index); - pushes.push((address_type, type_index, data)); - } - } - } - } - - // Phase 1: Deletes (creates holes) - for empty_index in deletes { - addresses_data.empty.delete(empty_index); - } - - // Phase 2: Updates (in-place) - for (index, data) in updates { - addresses_data.funded.update(index, data)?; - } - - // Phase 3: Pushes (fill holes first, then pure pushes) - let mut result = AddressTypeToTypeIndexMap::with_capacity(pushes.len() / 4); - let holes_count = addresses_data.funded.holes().len(); - let mut pushes_iter = pushes.into_iter(); - - for (address_type, type_index, data) in pushes_iter.by_ref().take(holes_count) { - let index = addresses_data.funded.fill_first_hole_or_push(data)?; - result - .get_mut(address_type) - .unwrap() - .insert(type_index, AnyAddressIndex::from(index)); - } - - // Pure pushes - no holes remain - addresses_data.funded.reserve_pushed(pushes_iter.len()); - let mut next_index = addresses_data.funded.len(); - for (address_type, type_index, data) in pushes_iter { - addresses_data.funded.push(data); - result.get_mut(address_type).unwrap().insert( - type_index, - AnyAddressIndex::from(FundedAddressIndex::from(next_index)), - ); - next_index += 1; - } - - Ok(result) -} - -/// Process empty address data updates. -/// -/// Handles: -/// - New empty address: push to empty storage -/// - Updated empty address (was empty): update in place -/// - Transition funded -> empty: delete from funded, push to empty -pub(crate) fn process_empty_addresses( - addresses_data: &mut AddressesDataVecs, - empty_updates: AddressTypeToTypeIndexMap>, -) -> Result> { - let total: usize = empty_updates.iter().map(|(_, m)| m.len()).sum(); - - let mut updates: Vec<(EmptyAddressIndex, EmptyAddressData)> = Vec::with_capacity(total); - let mut deletes: Vec = Vec::with_capacity(total); - let mut pushes: Vec<(OutputType, TypeIndex, EmptyAddressData)> = Vec::with_capacity(total); - - for (address_type, items) in empty_updates.into_iter() { - for (type_index, source) in items { - match source { - WithAddressDataSource::New(data) => { - pushes.push((address_type, type_index, data)); - } - WithAddressDataSource::FromEmpty(index, data) => { - updates.push((index, data)); - } - WithAddressDataSource::FromFunded(funded_index, data) => { - deletes.push(funded_index); - pushes.push((address_type, type_index, data)); - } - } - } - } - - // Phase 1: Deletes (creates holes) - for funded_index in deletes { - addresses_data.funded.delete(funded_index); - } - - // Phase 2: Updates (in-place) - for (index, data) in updates { - addresses_data.empty.update(index, data)?; - } - - // Phase 3: Pushes (fill holes first, then pure pushes) - let mut result = AddressTypeToTypeIndexMap::with_capacity(pushes.len() / 4); - let holes_count = addresses_data.empty.holes().len(); - let mut pushes_iter = pushes.into_iter(); - - for (address_type, type_index, data) in pushes_iter.by_ref().take(holes_count) { - let index = addresses_data.empty.fill_first_hole_or_push(data)?; - result - .get_mut(address_type) - .unwrap() - .insert(type_index, AnyAddressIndex::from(index)); - } - - // Pure pushes - no holes remain - addresses_data.empty.reserve_pushed(pushes_iter.len()); - let mut next_index = addresses_data.empty.len(); - for (address_type, type_index, data) in pushes_iter { - addresses_data.empty.push(data); - result.get_mut(address_type).unwrap().insert( - type_index, - AnyAddressIndex::from(EmptyAddressIndex::from(next_index)), - ); - next_index += 1; - } - - Ok(result) -} diff --git a/crates/brk_computer/src/distribution/block/cohort/mod.rs b/crates/brk_computer/src/distribution/block/cohort/mod.rs index 96af2745e..2195c864a 100644 --- a/crates/brk_computer/src/distribution/block/cohort/mod.rs +++ b/crates/brk_computer/src/distribution/block/cohort/mod.rs @@ -1,10 +1,10 @@ -mod address_updates; +mod addr_updates; mod received; mod sent; mod tx_counts; mod with_source; -pub(crate) use address_updates::*; +pub(crate) use addr_updates::*; pub(crate) use received::*; pub(crate) use sent::*; pub(crate) use tx_counts::*; diff --git a/crates/brk_computer/src/distribution/block/cohort/received.rs b/crates/brk_computer/src/distribution/block/cohort/received.rs index a863304a1..638fc6000 100644 --- a/crates/brk_computer/src/distribution/block/cohort/received.rs +++ b/crates/brk_computer/src/distribution/block/cohort/received.rs @@ -1,13 +1,13 @@ -use brk_cohort::{AmountBucket, ByAddressType}; +use brk_cohort::{AmountBucket, ByAddrType}; use brk_types::{Cents, Sats, TypeIndex}; use rustc_hash::FxHashMap; use crate::distribution::{ - address::{AddressTypeToActivityCounts, AddressTypeToVec}, - cohorts::AddressCohorts, + addr::{AddrTypeToActivityCounts, AddrTypeToVec}, + cohorts::AddrCohorts, }; -use super::super::cache::{AddressLookup, TrackingStatus}; +use super::super::cache::{AddrLookup, TrackingStatus}; /// Aggregated receive data for a single address within a block. #[derive(Default)] @@ -18,13 +18,13 @@ struct AggregatedReceive { #[allow(clippy::too_many_arguments)] pub(crate) fn process_received( - received_data: AddressTypeToVec<(TypeIndex, Sats)>, - cohorts: &mut AddressCohorts, - lookup: &mut AddressLookup<'_>, + received_data: AddrTypeToVec<(TypeIndex, Sats)>, + cohorts: &mut AddrCohorts, + lookup: &mut AddrLookup<'_>, price: Cents, - address_count: &mut ByAddressType, - empty_address_count: &mut ByAddressType, - activity_counts: &mut AddressTypeToActivityCounts, + addr_count: &mut ByAddrType, + empty_addr_count: &mut ByAddrType, + activity_counts: &mut AddrTypeToActivityCounts, ) { let max_type_len = received_data.iter().map(|(_, v)| v.len()).max().unwrap_or(0); let mut aggregated: FxHashMap = @@ -36,8 +36,8 @@ pub(crate) fn process_received( } // Cache mutable refs for this address type - let type_address_count = address_count.get_mut(output_type).unwrap(); - let type_empty_count = empty_address_count.get_mut(output_type).unwrap(); + let type_addr_count = addr_count.get_mut(output_type).unwrap(); + let type_empty_count = empty_addr_count.get_mut(output_type).unwrap(); let type_activity = activity_counts.get_mut_unwrap(output_type); // Aggregate receives by address - each address processed exactly once @@ -55,10 +55,10 @@ pub(crate) fn process_received( match status { TrackingStatus::New => { - *type_address_count += 1; + *type_addr_count += 1; } TrackingStatus::WasEmpty => { - *type_address_count += 1; + *type_addr_count += 1; *type_empty_count -= 1; // Reactivated - was empty, now has funds type_activity.reactivated += 1; @@ -100,7 +100,7 @@ pub(crate) fn process_received( "process_received: cohort underflow detected!\n\ output_type={:?}, type_index={:?}\n\ prev_balance={}, new_balance={}, total_value={}\n\ - Address: {:?}", + Addr: {:?}", output_type, type_index, prev_balance, diff --git a/crates/brk_computer/src/distribution/block/cohort/sent.rs b/crates/brk_computer/src/distribution/block/cohort/sent.rs index 267052215..846cdc729 100644 --- a/crates/brk_computer/src/distribution/block/cohort/sent.rs +++ b/crates/brk_computer/src/distribution/block/cohort/sent.rs @@ -1,16 +1,16 @@ -use brk_cohort::{AmountBucket, ByAddressType}; +use brk_cohort::{AmountBucket, ByAddrType}; use brk_error::Result; use brk_types::{Age, Cents, CheckedSub, Height, Sats, Timestamp, TypeIndex}; use rustc_hash::FxHashSet; use vecdb::VecIndex; use crate::distribution::{ - address::{AddressTypeToActivityCounts, HeightToAddressTypeToVec}, - cohorts::AddressCohorts, + addr::{AddrTypeToActivityCounts, HeightToAddrTypeToVec}, + cohorts::AddrCohorts, compute::PriceRangeMax, }; -use super::super::cache::AddressLookup; +use super::super::cache::AddrLookup; /// Process sent outputs for address cohorts. /// @@ -27,20 +27,20 @@ use super::super::cache::AddressLookup; /// for accurate peak regret calculation. #[allow(clippy::too_many_arguments)] pub(crate) fn process_sent( - sent_data: HeightToAddressTypeToVec<(TypeIndex, Sats)>, - cohorts: &mut AddressCohorts, - lookup: &mut AddressLookup<'_>, + sent_data: HeightToAddrTypeToVec<(TypeIndex, Sats)>, + cohorts: &mut AddrCohorts, + lookup: &mut AddrLookup<'_>, current_price: Cents, price_range_max: &PriceRangeMax, - address_count: &mut ByAddressType, - empty_address_count: &mut ByAddressType, - activity_counts: &mut AddressTypeToActivityCounts, - received_addresses: &ByAddressType>, + addr_count: &mut ByAddrType, + empty_addr_count: &mut ByAddrType, + activity_counts: &mut AddrTypeToActivityCounts, + received_addrs: &ByAddrType>, height_to_price: &[Cents], height_to_timestamp: &[Timestamp], current_height: Height, current_timestamp: Timestamp, - seen_senders: &mut ByAddressType>, + seen_senders: &mut ByAddrType>, ) -> Result<()> { seen_senders.values_mut().for_each(|set| set.clear()); @@ -54,10 +54,10 @@ pub(crate) fn process_sent( for (output_type, vec) in by_type.unwrap().into_iter() { // Cache mutable refs for this address type - let type_address_count = address_count.get_mut(output_type).unwrap(); - let type_empty_count = empty_address_count.get_mut(output_type).unwrap(); + let type_addr_count = addr_count.get_mut(output_type).unwrap(); + let type_empty_count = empty_addr_count.get_mut(output_type).unwrap(); let type_activity = activity_counts.get_mut_unwrap(output_type); - let type_received = received_addresses.get(output_type); + let type_received = received_addrs.get(output_type); let type_seen = seen_senders.get_mut_unwrap(output_type); for (type_index, value) in vec { @@ -99,7 +99,7 @@ pub(crate) fn process_sent( // Migrate address to new bucket or mark as empty if will_be_empty { - *type_address_count -= 1; + *type_addr_count -= 1; *type_empty_count += 1; lookup.move_to_empty(output_type, type_index); } else if crossing_boundary { diff --git a/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs b/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs index 313211c79..a4e792d0d 100644 --- a/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs +++ b/crates/brk_computer/src/distribution/block/cohort/tx_counts.rs @@ -1,9 +1,9 @@ -use brk_types::{EmptyAddressData, FundedAddressData, TxIndex}; +use brk_types::{EmptyAddrData, FundedAddrData, TxIndex}; use smallvec::SmallVec; -use crate::distribution::address::AddressTypeToTypeIndexMap; +use crate::distribution::addr::AddrTypeToTypeIndexMap; -use super::with_source::WithAddressDataSource; +use super::with_source::WithAddrDataSource; /// Update tx_count for addresses based on unique transactions they participated in. /// @@ -14,9 +14,9 @@ use super::with_source::WithAddressDataSource; /// Addresses are looked up in funded_cache first, then empty_cache. /// NOTE: This should be called AFTER merging parallel-fetched address data into funded_cache. pub(crate) fn update_tx_counts( - funded_cache: &mut AddressTypeToTypeIndexMap>, - empty_cache: &mut AddressTypeToTypeIndexMap>, - mut tx_index_vecs: AddressTypeToTypeIndexMap>, + funded_cache: &mut AddrTypeToTypeIndexMap>, + empty_cache: &mut AddrTypeToTypeIndexMap>, + mut tx_index_vecs: AddrTypeToTypeIndexMap>, ) { // First, deduplicate tx_index_vecs for addresses that appear multiple times in a block for (_, map) in tx_index_vecs.iter_mut() { @@ -29,20 +29,20 @@ pub(crate) fn update_tx_counts( } // Update tx_count on address data - for (address_type, type_index, tx_index_vec) in tx_index_vecs + for (addr_type, type_index, tx_index_vec) in tx_index_vecs .into_iter() .flat_map(|(t, m)| m.into_iter().map(move |(i, v)| (t, i, v))) { let tx_count = tx_index_vec.len() as u32; if let Some(addr_data) = funded_cache - .get_mut(address_type) + .get_mut(addr_type) .unwrap() .get_mut(&type_index) { addr_data.tx_count += tx_count; } else if let Some(addr_data) = empty_cache - .get_mut(address_type) + .get_mut(addr_type) .unwrap() .get_mut(&type_index) { diff --git a/crates/brk_computer/src/distribution/block/cohort/with_source.rs b/crates/brk_computer/src/distribution/block/cohort/with_source.rs index a02ef4513..52dc8a8e2 100644 --- a/crates/brk_computer/src/distribution/block/cohort/with_source.rs +++ b/crates/brk_computer/src/distribution/block/cohort/with_source.rs @@ -1,20 +1,20 @@ -use brk_types::{EmptyAddressData, EmptyAddressIndex, FundedAddressData, FundedAddressIndex}; +use brk_types::{EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex}; /// Address data wrapped with its source location for flush operations. /// /// This enum tracks where the data came from so it can be correctly /// updated or created during the flush phase. #[derive(Debug, Clone)] -pub enum WithAddressDataSource { +pub enum WithAddrDataSource { /// Brand new address (never seen before) New(T), /// Funded from funded address storage (with original index) - FromFunded(FundedAddressIndex, T), + FromFunded(FundedAddrIndex, T), /// Funded from empty address storage (with original index) - FromEmpty(EmptyAddressIndex, T), + FromEmpty(EmptyAddrIndex, T), } -impl std::ops::Deref for WithAddressDataSource { +impl std::ops::Deref for WithAddrDataSource { type Target = T; fn deref(&self) -> &Self::Target { @@ -24,7 +24,7 @@ impl std::ops::Deref for WithAddressDataSource { } } -impl std::ops::DerefMut for WithAddressDataSource { +impl std::ops::DerefMut for WithAddrDataSource { fn deref_mut(&mut self) -> &mut Self::Target { match self { Self::New(v) | Self::FromFunded(_, v) | Self::FromEmpty(_, v) => v, @@ -32,24 +32,24 @@ impl std::ops::DerefMut for WithAddressDataSource { } } -impl From> for WithAddressDataSource { +impl From> for WithAddrDataSource { #[inline] - fn from(value: WithAddressDataSource) -> Self { + fn from(value: WithAddrDataSource) -> Self { match value { - WithAddressDataSource::New(v) => Self::New(v.into()), - WithAddressDataSource::FromFunded(i, v) => Self::FromFunded(i, v.into()), - WithAddressDataSource::FromEmpty(i, v) => Self::FromEmpty(i, v.into()), + WithAddrDataSource::New(v) => Self::New(v.into()), + WithAddrDataSource::FromFunded(i, v) => Self::FromFunded(i, v.into()), + WithAddrDataSource::FromEmpty(i, v) => Self::FromEmpty(i, v.into()), } } } -impl From> for WithAddressDataSource { +impl From> for WithAddrDataSource { #[inline] - fn from(value: WithAddressDataSource) -> Self { + fn from(value: WithAddrDataSource) -> Self { match value { - WithAddressDataSource::New(v) => Self::New(v.into()), - WithAddressDataSource::FromFunded(i, v) => Self::FromFunded(i, v.into()), - WithAddressDataSource::FromEmpty(i, v) => Self::FromEmpty(i, v.into()), + WithAddrDataSource::New(v) => Self::New(v.into()), + WithAddrDataSource::FromFunded(i, v) => Self::FromFunded(i, v.into()), + WithAddrDataSource::FromEmpty(i, v) => Self::FromEmpty(i, v.into()), } } } diff --git a/crates/brk_computer/src/distribution/block/utxo/inputs.rs b/crates/brk_computer/src/distribution/block/utxo/inputs.rs index a61ebe72b..c48d15efb 100644 --- a/crates/brk_computer/src/distribution/block/utxo/inputs.rs +++ b/crates/brk_computer/src/distribution/block/utxo/inputs.rs @@ -1,21 +1,21 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; -use brk_types::{FundedAddressData, Height, OutputType, Sats, TxIndex, TypeIndex}; +use brk_types::{FundedAddrData, Height, OutputType, Sats, TxIndex, TypeIndex}; use rayon::prelude::*; use rustc_hash::FxHashMap; use smallvec::SmallVec; use crate::distribution::{ - address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAddressIndexesVecs}, + addr::{AddrTypeToTypeIndexMap, AddrsDataVecs, AnyAddrIndexesVecs}, compute::VecsReaders, state::Transacted, }; -use crate::distribution::address::HeightToAddressTypeToVec; +use crate::distribution::addr::HeightToAddrTypeToVec; use super::super::{ - cache::{AddressCache, load_uncached_address_data}, - cohort::WithAddressDataSource, + cache::{AddrCache, load_uncached_addr_data}, + cohort::WithAddrDataSource, }; /// Result of processing inputs for a block. @@ -23,11 +23,11 @@ pub struct InputsResult { /// Map from UTXO creation height -> aggregated sent supply. pub height_to_sent: FxHashMap, /// Per-height, per-address-type sent data: (type_index, value) for each address. - pub sent_data: HeightToAddressTypeToVec<(TypeIndex, Sats)>, - /// Address data looked up during processing, keyed by (address_type, type_index). - pub address_data: AddressTypeToTypeIndexMap>, + pub sent_data: HeightToAddrTypeToVec<(TypeIndex, Sats)>, + /// Address data looked up during processing, keyed by (addr_type, type_index). + pub addr_data: AddrTypeToTypeIndexMap>, /// Transaction indexes per address for tx_count tracking. - pub tx_index_vecs: AddressTypeToTypeIndexMap>, + pub tx_index_vecs: AddrTypeToTypeIndexMap>, } /// Process inputs (spent UTXOs) for a block. @@ -51,11 +51,11 @@ pub(crate) fn process_inputs( txin_index_to_output_type: &[OutputType], txin_index_to_type_index: &[TypeIndex], txin_index_to_prev_height: &[Height], - first_address_indexes: &ByAddressType, - cache: &AddressCache, + first_addr_indexes: &ByAddrType, + cache: &AddrCache, vr: &VecsReaders, - any_address_indexes: &AnyAddressIndexesVecs, - addresses_data: &AddressesDataVecs, + any_addr_indexes: &AnyAddrIndexesVecs, + addrs_data: &AddrsDataVecs, ) -> Result { let map_fn = |local_idx: usize| -> Result<_> { let tx_index = txin_index_to_tx_index[local_idx]; @@ -64,21 +64,21 @@ pub(crate) fn process_inputs( let value = txin_index_to_value[local_idx]; let input_type = txin_index_to_output_type[local_idx]; - if input_type.is_not_address() { + if input_type.is_not_addr() { return Ok((prev_height, value, input_type, None)); } let type_index = txin_index_to_type_index[local_idx]; // Look up address data - let addr_data_opt = load_uncached_address_data( + let addr_data_opt = load_uncached_addr_data( input_type, type_index, - first_address_indexes, + first_addr_indexes, cache, vr, - any_address_indexes, - addresses_data, + any_addr_indexes, + addrs_data, )?; Ok(( @@ -108,13 +108,13 @@ pub(crate) fn process_inputs( estimated_unique_heights, Default::default(), ); - let mut sent_data = HeightToAddressTypeToVec::with_capacity(estimated_unique_heights); - let mut address_data = - AddressTypeToTypeIndexMap::>::with_capacity( + let mut sent_data = HeightToAddrTypeToVec::with_capacity(estimated_unique_heights); + let mut addr_data = + AddrTypeToTypeIndexMap::>::with_capacity( estimated_per_type, ); let mut tx_index_vecs = - AddressTypeToTypeIndexMap::>::with_capacity(estimated_per_type); + AddrTypeToTypeIndexMap::>::with_capacity(estimated_per_type); for (prev_height, value, output_type, addr_info) in items { height_to_sent @@ -130,8 +130,8 @@ pub(crate) fn process_inputs( .unwrap() .push((type_index, value)); - if let Some(addr_data) = addr_data_opt { - address_data.insert_for_type(output_type, type_index, addr_data); + if let Some(source) = addr_data_opt { + addr_data.insert_for_type(output_type, type_index, source); } tx_index_vecs @@ -146,7 +146,7 @@ pub(crate) fn process_inputs( Ok(InputsResult { height_to_sent, sent_data, - address_data, + addr_data, tx_index_vecs, }) } diff --git a/crates/brk_computer/src/distribution/block/utxo/outputs.rs b/crates/brk_computer/src/distribution/block/utxo/outputs.rs index d8221a6be..8878b62a8 100644 --- a/crates/brk_computer/src/distribution/block/utxo/outputs.rs +++ b/crates/brk_computer/src/distribution/block/utxo/outputs.rs @@ -1,20 +1,20 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; -use brk_types::{FundedAddressData, Sats, TxIndex, TypeIndex}; +use brk_types::{FundedAddrData, Sats, TxIndex, TypeIndex}; use rayon::prelude::*; use smallvec::SmallVec; use crate::distribution::{ - address::{ - AddressTypeToTypeIndexMap, AddressTypeToVec, AddressesDataVecs, AnyAddressIndexesVecs, + addr::{ + AddrTypeToTypeIndexMap, AddrTypeToVec, AddrsDataVecs, AnyAddrIndexesVecs, }, compute::{TxOutData, VecsReaders}, state::Transacted, }; use super::super::{ - cache::{AddressCache, load_uncached_address_data}, - cohort::WithAddressDataSource, + cache::{AddrCache, load_uncached_addr_data}, + cohort::WithAddrDataSource, }; /// Result of processing outputs for a block. @@ -22,11 +22,11 @@ pub struct OutputsResult { /// Aggregated supply transacted in this block. pub transacted: Transacted, /// Per-address-type received data: (type_index, value) for each address. - pub received_data: AddressTypeToVec<(TypeIndex, Sats)>, - /// Address data looked up during processing, keyed by (address_type, type_index). - pub address_data: AddressTypeToTypeIndexMap>, + pub received_data: AddrTypeToVec<(TypeIndex, Sats)>, + /// Address data looked up during processing, keyed by (addr_type, type_index). + pub addr_data: AddrTypeToTypeIndexMap>, /// Transaction indexes per address for tx_count tracking. - pub tx_index_vecs: AddressTypeToTypeIndexMap>, + pub tx_index_vecs: AddrTypeToTypeIndexMap>, } /// Process outputs (new UTXOs) for a block. @@ -40,35 +40,35 @@ pub struct OutputsResult { pub(crate) fn process_outputs( txout_index_to_tx_index: &[TxIndex], txout_data_vec: &[TxOutData], - first_address_indexes: &ByAddressType, - cache: &AddressCache, + first_addr_indexes: &ByAddrType, + cache: &AddrCache, vr: &VecsReaders, - any_address_indexes: &AnyAddressIndexesVecs, - addresses_data: &AddressesDataVecs, + any_addr_indexes: &AnyAddrIndexesVecs, + addrs_data: &AddrsDataVecs, ) -> Result { let output_count = txout_data_vec.len(); - // Phase 1: Address lookups (mmap reads) — parallel for large blocks, sequential for small + // Phase 1: Addr lookups (mmap reads) — parallel for large blocks, sequential for small let map_fn = |local_idx: usize| -> Result<_> { let txout_data = &txout_data_vec[local_idx]; let value = txout_data.value; let output_type = txout_data.output_type; - if output_type.is_not_address() { + if output_type.is_not_addr() { return Ok((value, output_type, None)); } let type_index = txout_data.type_index; let tx_index = txout_index_to_tx_index[local_idx]; - let addr_data_opt = load_uncached_address_data( + let addr_data_opt = load_uncached_addr_data( output_type, type_index, - first_address_indexes, + first_addr_indexes, cache, vr, - any_address_indexes, - addresses_data, + any_addr_indexes, + addrs_data, )?; Ok(( @@ -92,13 +92,13 @@ pub(crate) fn process_outputs( // Phase 2: Sequential accumulation let estimated_per_type = (output_count / 8).max(8); let mut transacted = Transacted::default(); - let mut received_data = AddressTypeToVec::with_capacity(estimated_per_type); - let mut address_data = - AddressTypeToTypeIndexMap::>::with_capacity( + let mut received_data = AddrTypeToVec::with_capacity(estimated_per_type); + let mut addr_data = + AddrTypeToTypeIndexMap::>::with_capacity( estimated_per_type, ); let mut tx_index_vecs = - AddressTypeToTypeIndexMap::>::with_capacity(estimated_per_type); + AddrTypeToTypeIndexMap::>::with_capacity(estimated_per_type); for (value, output_type, addr_info) in items { transacted.iterate(value, output_type); @@ -109,8 +109,8 @@ pub(crate) fn process_outputs( .unwrap() .push((type_index, value)); - if let Some(addr_data) = addr_data_opt { - address_data.insert_for_type(output_type, type_index, addr_data); + if let Some(source) = addr_data_opt { + addr_data.insert_for_type(output_type, type_index, source); } tx_index_vecs @@ -125,7 +125,7 @@ pub(crate) fn process_outputs( Ok(OutputsResult { transacted, received_data, - address_data, + addr_data, tx_index_vecs, }) } diff --git a/crates/brk_computer/src/distribution/cohorts/address/groups.rs b/crates/brk_computer/src/distribution/cohorts/addr/groups.rs similarity index 89% rename from crates/brk_computer/src/distribution/cohorts/address/groups.rs rename to crates/brk_computer/src/distribution/cohorts/addr/groups.rs index 208d8602b..d4ff5f3bc 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/addr/groups.rs @@ -1,7 +1,7 @@ use std::path::Path; use brk_cohort::{ - AddressGroups, AmountRange, OverAmount, UnderAmount, Filter, Filtered, + AddrGroups, AmountRange, OverAmount, UnderAmount, Filter, Filtered, }; use brk_error::Result; use brk_traversable::Traversable; @@ -12,16 +12,16 @@ use vecdb::{AnyStoredVec, Database, Exit, Rw, StorageMode}; use crate::{distribution::DynCohortVecs, indexes, internal::CachedWindowStarts, prices}; -use super::{super::traits::CohortVecs, vecs::AddressCohortVecs}; +use super::{super::traits::CohortVecs, vecs::AddrCohortVecs}; const VERSION: Version = Version::new(0); -/// All Address cohorts organized by filter type. +/// All Addr cohorts organized by filter type. #[derive(Deref, DerefMut, Traversable)] -pub struct AddressCohorts(AddressGroups>); +pub struct AddrCohorts(AddrGroups>); -impl AddressCohorts { - /// Import all Address cohorts from database. +impl AddrCohorts { + /// Import all Addr cohorts from database. pub(crate) fn forced_import( db: &Database, version: Version, @@ -33,15 +33,15 @@ impl AddressCohorts { // Helper to create a cohort - only amount_range cohorts have state let create = - |filter: Filter, name: &'static str, has_state: bool| -> Result { + |filter: Filter, name: &'static str, has_state: bool| -> Result { let sp = if has_state { Some(states_path) } else { None }; - AddressCohortVecs::forced_import(db, filter, name, v, indexes, sp, cached_starts) + AddrCohortVecs::forced_import(db, filter, name, v, indexes, sp, cached_starts) }; let full = |f: Filter, name: &'static str| create(f, name, true); let none = |f: Filter, name: &'static str| create(f, name, false); - Ok(Self(AddressGroups { + Ok(Self(AddrGroups { amount_range: AmountRange::try_new(&full)?, under_amount: UnderAmount::try_new(&none)?, over_amount: OverAmount::try_new(&none)?, @@ -51,7 +51,7 @@ impl AddressCohorts { /// Apply a function to each aggregate cohort with its source cohorts (in parallel). fn for_each_aggregate(&mut self, f: F) -> Result<()> where - F: Fn(&mut AddressCohortVecs, Vec<&AddressCohortVecs>) -> Result<()> + Sync, + F: Fn(&mut AddrCohortVecs, Vec<&AddrCohortVecs>) -> Result<()> + Sync, { let by_amount_range = &self.0.amount_range; diff --git a/crates/brk_computer/src/distribution/cohorts/address/mod.rs b/crates/brk_computer/src/distribution/cohorts/addr/mod.rs similarity index 100% rename from crates/brk_computer/src/distribution/cohorts/address/mod.rs rename to crates/brk_computer/src/distribution/cohorts/addr/mod.rs diff --git a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs similarity index 83% rename from crates/brk_computer/src/distribution/cohorts/address/vecs.rs rename to crates/brk_computer/src/distribution/cohorts/addr/vecs.rs index 2198c5a59..c63138afc 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs @@ -8,7 +8,7 @@ use rayon::prelude::*; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ - distribution::state::{AddressCohortState, MinimalRealizedState}, + distribution::state::{AddrCohortState, MinimalRealizedState}, indexes, internal::{CachedWindowStarts, PerBlockWithDeltas}, prices, @@ -18,19 +18,19 @@ use crate::distribution::metrics::{ImportConfig, MinimalCohortMetrics}; use super::super::traits::{CohortVecs, DynCohortVecs}; #[derive(Traversable)] -pub struct AddressCohortVecs { +pub struct AddrCohortVecs { starting_height: Option, #[traversable(skip)] - pub state: Option>>, + pub state: Option>>, #[traversable(flatten)] pub metrics: MinimalCohortMetrics, - pub address_count: PerBlockWithDeltas, + pub addr_count: PerBlockWithDeltas, } -impl AddressCohortVecs { +impl AddrCohortVecs { pub(crate) fn forced_import( db: &Database, filter: Filter, @@ -40,7 +40,7 @@ impl AddressCohortVecs { states_path: Option<&Path>, cached_starts: &CachedWindowStarts, ) -> Result { - let full_name = CohortContext::Address.full_name(&filter, name); + let full_name = CohortContext::Addr.full_name(&filter, name); let cfg = ImportConfig { db, @@ -51,9 +51,9 @@ impl AddressCohortVecs { cached_starts, }; - let address_count = PerBlockWithDeltas::forced_import( + let addr_count = PerBlockWithDeltas::forced_import( db, - &cfg.name("address_count"), + &cfg.name("addr_count"), version, Version::ONE, indexes, @@ -62,9 +62,9 @@ impl AddressCohortVecs { Ok(Self { starting_height: None, - state: states_path.map(|path| Box::new(AddressCohortState::new(path, &full_name))), + state: states_path.map(|path| Box::new(AddrCohortState::new(path, &full_name))), metrics: MinimalCohortMetrics::forced_import(&cfg)?, - address_count, + addr_count, }) } @@ -76,7 +76,7 @@ impl AddressCohortVecs { &mut self, ) -> impl ParallelIterator { let mut vecs: Vec<&mut dyn AnyStoredVec> = Vec::new(); - vecs.push(&mut self.address_count.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.addr_count.height as &mut dyn AnyStoredVec); vecs.extend(self.metrics.collect_all_vecs_mut()); vecs.into_par_iter() } @@ -89,15 +89,15 @@ impl AddressCohortVecs { } } -impl Filtered for AddressCohortVecs { +impl Filtered for AddrCohortVecs { fn filter(&self) -> &Filter { &self.metrics.filter } } -impl DynCohortVecs for AddressCohortVecs { +impl DynCohortVecs for AddrCohortVecs { fn min_stateful_len(&self) -> usize { - self.address_count + self.addr_count .height .len() .min(self.metrics.min_stateful_len()) @@ -130,7 +130,7 @@ impl DynCohortVecs for AddressCohortVecs { .height .collect_one(prev_height) .unwrap(); - state.address_count = *self.address_count.height.collect_one(prev_height).unwrap(); + state.addr_count = *self.addr_count.height.collect_one(prev_height).unwrap(); state.inner.restore_realized_cap(); @@ -149,7 +149,7 @@ impl DynCohortVecs for AddressCohortVecs { fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { use vecdb::WritableVec; - self.address_count + self.addr_count .height .validate_computed_version_or_reset(base_version)?; Ok(()) @@ -161,9 +161,9 @@ impl DynCohortVecs for AddressCohortVecs { } if let Some(state) = self.state.as_ref() { - self.address_count + self.addr_count .height - .push(state.address_count.into()); + .push(state.addr_count.into()); self.metrics.supply.push_state(&state.inner); self.metrics.outputs.push_state(&state.inner); self.metrics.realized.push_state(&state.inner); @@ -203,18 +203,18 @@ impl DynCohortVecs for AddressCohortVecs { } } -impl CohortVecs for AddressCohortVecs { +impl CohortVecs for AddrCohortVecs { fn compute_from_stateful( &mut self, starting_indexes: &Indexes, others: &[&Self], exit: &Exit, ) -> Result<()> { - self.address_count.height.compute_sum_of_others( + self.addr_count.height.compute_sum_of_others( starting_indexes.height, others .iter() - .map(|v| &v.address_count.height) + .map(|v| &v.addr_count.height) .collect::>() .as_slice(), exit, diff --git a/crates/brk_computer/src/distribution/cohorts/mod.rs b/crates/brk_computer/src/distribution/cohorts/mod.rs index 5241b3261..391cbb1e6 100644 --- a/crates/brk_computer/src/distribution/cohorts/mod.rs +++ b/crates/brk_computer/src/distribution/cohorts/mod.rs @@ -1,7 +1,7 @@ -mod address; +mod addr; mod traits; mod utxo; -pub use address::AddressCohorts; +pub use addr::AddrCohorts; pub use traits::DynCohortVecs; pub use utxo::UTXOCohorts; diff --git a/crates/brk_computer/src/distribution/compute/block_loop.rs b/crates/brk_computer/src/distribution/compute/block_loop.rs index f9f7fad2a..c6e990528 100644 --- a/crates/brk_computer/src/distribution/compute/block_loop.rs +++ b/crates/brk_computer/src/distribution/compute/block_loop.rs @@ -1,4 +1,4 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_indexer::Indexer; use brk_types::{ @@ -11,12 +11,12 @@ use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, VecIndex, WritableVec}; use crate::{ distribution::{ - address::{AddressTypeToActivityCounts, AddressTypeToAddressCount}, + addr::{AddrTypeToActivityCounts, AddrTypeToAddrCount}, block::{ - AddressCache, InputsResult, process_inputs, process_outputs, process_received, + AddrCache, InputsResult, process_inputs, process_outputs, process_received, process_sent, }, - compute::write::{process_address_updates, write}, + compute::write::{process_addr_updates, write}, state::{BlockState, Transacted}, }, indexes, inputs, outputs, transactions, @@ -25,7 +25,7 @@ use crate::{ use super::{ super::{ RangeMap, - cohorts::{AddressCohorts, DynCohortVecs, UTXOCohorts}, + cohorts::{AddrCohorts, DynCohortVecs, UTXOCohorts}, vecs::Vecs, }, BIP30_DUPLICATE_HEIGHT_1, BIP30_DUPLICATE_HEIGHT_2, BIP30_ORIGINAL_HEIGHT_1, @@ -103,7 +103,7 @@ pub(crate) fn process_blocks( .collect(); debug!("creating VecsReaders"); - let mut vr = VecsReaders::new(&vecs.any_address_indexes, &vecs.addresses_data); + let mut vr = VecsReaders::new(&vecs.any_addr_indexes, &vecs.addrs_data); debug!("VecsReaders created"); // Extend tx_index_to_height RangeMap with new entries (incremental, O(new_blocks)) @@ -143,69 +143,69 @@ pub(crate) fn process_blocks( // Pre-collect first address indexes per type for the block range let first_p2a_vec = indexer .vecs - .addresses + .addrs .p2a.first_index .collect_range_at(start_usize, end_usize); let first_p2pk33_vec = indexer .vecs - .addresses + .addrs .p2pk33.first_index .collect_range_at(start_usize, end_usize); let first_p2pk65_vec = indexer .vecs - .addresses + .addrs .p2pk65.first_index .collect_range_at(start_usize, end_usize); let first_p2pkh_vec = indexer .vecs - .addresses + .addrs .p2pkh.first_index .collect_range_at(start_usize, end_usize); let first_p2sh_vec = indexer .vecs - .addresses + .addrs .p2sh.first_index .collect_range_at(start_usize, end_usize); let first_p2tr_vec = indexer .vecs - .addresses + .addrs .p2tr.first_index .collect_range_at(start_usize, end_usize); let first_p2wpkh_vec = indexer .vecs - .addresses + .addrs .p2wpkh.first_index .collect_range_at(start_usize, end_usize); let first_p2wsh_vec = indexer .vecs - .addresses + .addrs .p2wsh.first_index .collect_range_at(start_usize, end_usize); // Track running totals - recover from previous height if resuming - debug!("recovering address_counts from height {}", starting_height); - let (mut address_counts, mut empty_address_counts) = if starting_height > Height::ZERO { - let address_counts = - AddressTypeToAddressCount::from((&vecs.addresses.funded.by_address_type, starting_height)); - let empty_address_counts = AddressTypeToAddressCount::from(( - &vecs.addresses.empty.by_address_type, + debug!("recovering addr_counts from height {}", starting_height); + let (mut addr_counts, mut empty_addr_counts) = if starting_height > Height::ZERO { + let addr_counts = + AddrTypeToAddrCount::from((&vecs.addrs.funded.by_addr_type, starting_height)); + let empty_addr_counts = AddrTypeToAddrCount::from(( + &vecs.addrs.empty.by_addr_type, starting_height, )); - (address_counts, empty_address_counts) + (addr_counts, empty_addr_counts) } else { ( - AddressTypeToAddressCount::default(), - AddressTypeToAddressCount::default(), + AddrTypeToAddrCount::default(), + AddrTypeToAddrCount::default(), ) }; - debug!("address_counts recovered"); + debug!("addr_counts recovered"); // Track activity counts - reset each block - let mut activity_counts = AddressTypeToActivityCounts::default(); + let mut activity_counts = AddrTypeToActivityCounts::default(); - debug!("creating AddressCache"); - let mut cache = AddressCache::new(); - debug!("AddressCache created, entering main loop"); + debug!("creating AddrCache"); + let mut cache = AddrCache::new(); + debug!("AddrCache created, entering main loop"); // Initialize Fenwick tree from imported BTreeMap state (one-time) vecs.utxo_cohorts.init_fenwick_if_needed(); @@ -216,10 +216,10 @@ pub(crate) fn process_blocks( let start = starting_height.to_usize(); vecs.utxo_cohorts .par_iter_vecs_mut() - .chain(vecs.address_cohorts.par_iter_vecs_mut()) - .chain(vecs.addresses.funded.par_iter_height_mut()) - .chain(vecs.addresses.empty.par_iter_height_mut()) - .chain(vecs.addresses.activity.par_iter_height_mut()) + .chain(vecs.addr_cohorts.par_iter_vecs_mut()) + .chain(vecs.addrs.funded.par_iter_height_mut()) + .chain(vecs.addrs.empty.par_iter_height_mut()) + .chain(vecs.addrs.activity.par_iter_height_mut()) .chain(rayon::iter::once( &mut vecs.coinblocks_destroyed.base.height as &mut dyn AnyStoredVec, )) @@ -227,8 +227,8 @@ pub(crate) fn process_blocks( } // Reusable hashsets (avoid per-block allocation) - let mut received_addresses = ByAddressType::>::default(); - let mut seen_senders = ByAddressType::>::default(); + let mut received_addrs = ByAddrType::>::default(); + let mut seen_senders = ByAddrType::>::default(); // Track earliest chain_state modification from sends (for incremental supply_state writes) let mut min_supply_modified: Option = None; @@ -255,7 +255,7 @@ pub(crate) fn process_blocks( debug_assert_eq!(ctx.price_at(height), block_price); // Get first address indexes for this height from pre-collected vecs - let first_address_indexes = ByAddressType { + let first_addr_indexes = ByAddrType { p2a: TypeIndex::from(first_p2a_vec[offset].to_usize()), p2pk33: TypeIndex::from(first_p2pk33_vec[offset].to_usize()), p2pk65: TypeIndex::from(first_p2pk65_vec[offset].to_usize()), @@ -285,11 +285,11 @@ pub(crate) fn process_blocks( process_outputs( txout_index_to_tx_index, txout_data_vec, - &first_address_indexes, + &first_addr_indexes, &cache, &vr, - &vecs.any_address_indexes, - &vecs.addresses_data, + &vecs.any_addr_indexes, + &vecs.addrs_data, ) }, || -> Result<_> { @@ -309,17 +309,17 @@ pub(crate) fn process_blocks( input_output_types, input_type_indexes, input_prev_heights, - &first_address_indexes, + &first_addr_indexes, &cache, &vr, - &vecs.any_address_indexes, - &vecs.addresses_data, + &vecs.any_addr_indexes, + &vecs.addrs_data, ) } else { Ok(InputsResult { height_to_sent: Default::default(), sent_data: Default::default(), - address_data: Default::default(), + addr_data: Default::default(), tx_index_vecs: Default::default(), }) } @@ -331,8 +331,8 @@ pub(crate) fn process_blocks( let (outputs_result, inputs_result) = oi_result?; // Merge new address data into current cache - cache.merge_funded(outputs_result.address_data); - cache.merge_funded(inputs_result.address_data); + cache.merge_funded(outputs_result.addr_data); + cache.merge_funded(inputs_result.addr_data); // Combine tx_index_vecs from outputs and inputs, then update tx_count let combined_tx_index_vecs = outputs_result @@ -390,15 +390,15 @@ pub(crate) fn process_blocks( // Build set of addresses that received this block (for detecting "both" in sent) // Reuse pre-allocated hashsets: clear preserves capacity, avoiding reallocation - received_addresses.values_mut().for_each(|set| set.clear()); + received_addrs.values_mut().for_each(|set| set.clear()); for (output_type, vec) in outputs_result.received_data.iter() { - let set = received_addresses.get_mut_unwrap(output_type); + let set = received_addrs.get_mut_unwrap(output_type); for (type_index, _) in vec { set.insert(*type_index); } } - // Process UTXO cohorts and Address cohorts in parallel + // Process UTXO cohorts and Addr cohorts in parallel let (_, addr_result) = rayon::join( || { // UTXO cohorts receive/send @@ -418,25 +418,25 @@ pub(crate) fn process_blocks( // Process received outputs (addresses receiving funds) process_received( outputs_result.received_data, - &mut vecs.address_cohorts, + &mut vecs.addr_cohorts, &mut lookup, block_price, - &mut address_counts, - &mut empty_address_counts, + &mut addr_counts, + &mut empty_addr_counts, &mut activity_counts, ); // Process sent inputs (addresses sending funds) process_sent( inputs_result.sent_data, - &mut vecs.address_cohorts, + &mut vecs.addr_cohorts, &mut lookup, block_price, ctx.price_range_max, - &mut address_counts, - &mut empty_address_counts, + &mut addr_counts, + &mut empty_addr_counts, &mut activity_counts, - &received_addresses, + &received_addrs, height_to_price_vec, height_to_timestamp_vec, height, @@ -451,18 +451,18 @@ pub(crate) fn process_blocks( vecs.utxo_cohorts.update_fenwick_from_pending(); // Push to height-indexed vectors - vecs.addresses.funded - .push_height(address_counts.sum(), &address_counts); - vecs.addresses.empty - .push_height(empty_address_counts.sum(), &empty_address_counts); - vecs.addresses.activity.push_height(&activity_counts); + vecs.addrs.funded + .push_height(addr_counts.sum(), &addr_counts); + vecs.addrs.empty + .push_height(empty_addr_counts.sum(), &empty_addr_counts); + vecs.addrs.activity.push_height(&activity_counts); let is_last_of_day = is_last_of_day[offset]; let date_opt = is_last_of_day.then(|| Date::from(timestamp)); push_cohort_states( &mut vecs.utxo_cohorts, - &mut vecs.address_cohorts, + &mut vecs.addr_cohorts, height, block_price, ); @@ -484,9 +484,9 @@ pub(crate) fn process_blocks( let (empty_updates, funded_updates) = cache.take(); // Process address updates (mutations) - process_address_updates( - &mut vecs.addresses_data, - &mut vecs.any_address_indexes, + process_addr_updates( + &mut vecs.addrs_data, + &mut vecs.any_addr_indexes, empty_updates, funded_updates, )?; @@ -499,7 +499,7 @@ pub(crate) fn process_blocks( vecs.flush()?; // Recreate readers - vr = VecsReaders::new(&vecs.any_address_indexes, &vecs.addresses_data); + vr = VecsReaders::new(&vecs.any_addr_indexes, &vecs.addrs_data); } } @@ -511,9 +511,9 @@ pub(crate) fn process_blocks( let (empty_updates, funded_updates) = cache.take(); // Process address updates (mutations) - process_address_updates( - &mut vecs.addresses_data, - &mut vecs.any_address_indexes, + process_addr_updates( + &mut vecs.addrs_data, + &mut vecs.any_addr_indexes, empty_updates, funded_updates, )?; @@ -527,7 +527,7 @@ pub(crate) fn process_blocks( /// Push cohort states to height-indexed vectors, then reset per-block values. fn push_cohort_states( utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, + addr_cohorts: &mut AddrCohorts, height: Height, height_price: Cents, ) { @@ -542,7 +542,7 @@ fn push_cohort_states( }) }, || { - address_cohorts + addr_cohorts .par_iter_separate_mut() .for_each(|v| { v.push_state(height); @@ -558,7 +558,7 @@ fn push_cohort_states( utxo_cohorts .iter_separate_mut() .for_each(|v| v.reset_single_iteration_values()); - address_cohorts + addr_cohorts .iter_separate_mut() .for_each(|v| v.reset_single_iteration_values()); } diff --git a/crates/brk_computer/src/distribution/compute/readers.rs b/crates/brk_computer/src/distribution/compute/readers.rs index 3a75bd2fc..0e4407ffe 100644 --- a/crates/brk_computer/src/distribution/compute/readers.rs +++ b/crates/brk_computer/src/distribution/compute/readers.rs @@ -1,4 +1,4 @@ -use brk_cohort::{ByAddressType, ByAnyAddress}; +use brk_cohort::{ByAddrType, ByAnyAddr}; use brk_indexer::Indexer; use brk_types::{Height, OutPoint, OutputType, Sats, StoredU64, TxIndex, TypeIndex}; use vecdb::{ReadableVec, Reader, VecIndex}; @@ -6,7 +6,7 @@ use vecdb::{ReadableVec, Reader, VecIndex}; use crate::{ distribution::{ RangeMap, - address::{AddressesDataVecs, AnyAddressIndexesVecs}, + addr::{AddrsDataVecs, AnyAddrIndexesVecs}, }, inputs, }; @@ -161,37 +161,37 @@ impl<'a> TxInReaders<'a> { /// Cached readers for stateful vectors. pub struct VecsReaders { - pub address_type_index_to_any_address_index: ByAddressType, - pub any_address_index_to_any_address_data: ByAnyAddress, + pub addr_type_index_to_any_addr_index: ByAddrType, + pub any_addr_index_to_any_addr_data: ByAnyAddr, } impl VecsReaders { pub(crate) fn new( - any_address_indexes: &AnyAddressIndexesVecs, - addresses_data: &AddressesDataVecs, + any_addr_indexes: &AnyAddrIndexesVecs, + addrs_data: &AddrsDataVecs, ) -> Self { Self { - address_type_index_to_any_address_index: ByAddressType { - p2a: any_address_indexes.p2a.create_reader(), - p2pk33: any_address_indexes.p2pk33.create_reader(), - p2pk65: any_address_indexes.p2pk65.create_reader(), - p2pkh: any_address_indexes.p2pkh.create_reader(), - p2sh: any_address_indexes.p2sh.create_reader(), - p2tr: any_address_indexes.p2tr.create_reader(), - p2wpkh: any_address_indexes.p2wpkh.create_reader(), - p2wsh: any_address_indexes.p2wsh.create_reader(), + addr_type_index_to_any_addr_index: ByAddrType { + p2a: any_addr_indexes.p2a.create_reader(), + p2pk33: any_addr_indexes.p2pk33.create_reader(), + p2pk65: any_addr_indexes.p2pk65.create_reader(), + p2pkh: any_addr_indexes.p2pkh.create_reader(), + p2sh: any_addr_indexes.p2sh.create_reader(), + p2tr: any_addr_indexes.p2tr.create_reader(), + p2wpkh: any_addr_indexes.p2wpkh.create_reader(), + p2wsh: any_addr_indexes.p2wsh.create_reader(), }, - any_address_index_to_any_address_data: ByAnyAddress { - funded: addresses_data.funded.create_reader(), - empty: addresses_data.empty.create_reader(), + any_addr_index_to_any_addr_data: ByAnyAddr { + funded: addrs_data.funded.create_reader(), + empty: addrs_data.empty.create_reader(), }, } } /// Get reader for specific address type. - pub(crate) fn address_reader(&self, address_type: OutputType) -> &Reader { - self.address_type_index_to_any_address_index - .get(address_type) + pub(crate) fn addr_reader(&self, addr_type: OutputType) -> &Reader { + self.addr_type_index_to_any_addr_index + .get(addr_type) .unwrap() } } diff --git a/crates/brk_computer/src/distribution/compute/recover.rs b/crates/brk_computer/src/distribution/compute/recover.rs index 13104425f..e352ae1d7 100644 --- a/crates/brk_computer/src/distribution/compute/recover.rs +++ b/crates/brk_computer/src/distribution/compute/recover.rs @@ -6,9 +6,9 @@ use tracing::{debug, warn}; use vecdb::Stamp; use super::super::{ - AddressesDataVecs, - address::AnyAddressIndexesVecs, - cohorts::{AddressCohorts, UTXOCohorts}, + AddrsDataVecs, + addr::AnyAddrIndexesVecs, + cohorts::{AddrCohorts, UTXOCohorts}, }; /// Result of state recovery. @@ -25,22 +25,22 @@ pub struct RecoveredState { pub(crate) fn recover_state( height: Height, chain_state_rollback: vecdb::Result, - any_address_indexes: &mut AnyAddressIndexesVecs, - addresses_data: &mut AddressesDataVecs, + any_addr_indexes: &mut AnyAddrIndexesVecs, + addrs_data: &mut AddrsDataVecs, utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, + addr_cohorts: &mut AddrCohorts, ) -> Result { let stamp = Stamp::from(height); // Rollback address state vectors - let address_indexes_rollback = any_address_indexes.rollback_before(stamp); - let address_data_rollback = addresses_data.rollback_before(stamp); + let addr_indexes_rollback = any_addr_indexes.rollback_before(stamp); + let addr_data_rollback = addrs_data.rollback_before(stamp); // Verify rollback consistency - all must agree on the same height let consistent_height = rollback_states( chain_state_rollback, - address_indexes_rollback, - address_data_rollback, + addr_indexes_rollback, + addr_data_rollback, ); // If rollbacks are inconsistent, start fresh @@ -88,19 +88,19 @@ pub(crate) fn recover_state( // Import address cohort states - all must succeed debug!( - "importing address cohort states at height {}", + "importing addr cohort states at height {}", consistent_height ); - if !address_cohorts.import_separate_states(consistent_height) { + if !addr_cohorts.import_separate_states(consistent_height) { warn!( - "Address cohort state import failed at height {}", + "Addr cohort state import failed at height {}", consistent_height ); return Ok(RecoveredState { starting_height: Height::ZERO, }); } - debug!("address cohort states imported"); + debug!("addr cohort states imported"); Ok(RecoveredState { starting_height: consistent_height, @@ -111,22 +111,22 @@ pub(crate) fn recover_state( /// /// Resets all state vectors and cohort states. pub(crate) fn reset_state( - any_address_indexes: &mut AnyAddressIndexesVecs, - addresses_data: &mut AddressesDataVecs, + any_addr_indexes: &mut AnyAddrIndexesVecs, + addrs_data: &mut AddrsDataVecs, utxo_cohorts: &mut UTXOCohorts, - address_cohorts: &mut AddressCohorts, + addr_cohorts: &mut AddrCohorts, ) -> Result { // Reset address state - any_address_indexes.reset()?; - addresses_data.reset()?; + any_addr_indexes.reset()?; + addrs_data.reset()?; // Reset cohort state heights utxo_cohorts.reset_separate_state_heights(); - address_cohorts.reset_separate_state_heights(); + addr_cohorts.reset_separate_state_heights(); // Reset cost_basis_data for all cohorts utxo_cohorts.reset_separate_cost_basis_data()?; - address_cohorts.reset_separate_cost_basis_data()?; + addr_cohorts.reset_separate_cost_basis_data()?; Ok(RecoveredState { starting_height: Height::ZERO, @@ -164,8 +164,8 @@ pub enum StartMode { /// otherwise returns Height::ZERO (need fresh start). fn rollback_states( chain_state_rollback: vecdb::Result, - address_indexes_rollbacks: Result>, - address_data_rollbacks: Result<[Stamp; 2]>, + addr_indexes_rollbacks: Result>, + addr_data_rollbacks: Result<[Stamp; 2]>, ) -> Height { let mut heights: BTreeSet = BTreeSet::new(); @@ -181,30 +181,30 @@ fn rollback_states( ); heights.insert(chain_height); - let Ok(stamps) = address_indexes_rollbacks else { + let Ok(stamps) = addr_indexes_rollbacks else { warn!( - "address_indexes rollback failed: {:?}", - address_indexes_rollbacks + "addr_indexes rollback failed: {:?}", + addr_indexes_rollbacks ); return Height::ZERO; }; for (i, s) in stamps.iter().enumerate() { let h = Height::from(*s).incremented(); debug!( - "address_indexes[{}] rolled back to stamp {:?}, height {}", + "addr_indexes[{}] rolled back to stamp {:?}, height {}", i, s, h ); heights.insert(h); } - let Ok(stamps) = address_data_rollbacks else { - warn!("address_data rollback failed: {:?}", address_data_rollbacks); + let Ok(stamps) = addr_data_rollbacks else { + warn!("addr_data rollback failed: {:?}", addr_data_rollbacks); return Height::ZERO; }; for (i, s) in stamps.iter().enumerate() { let h = Height::from(*s).incremented(); debug!( - "address_data[{}] rolled back to stamp {:?}, height {}", + "addr_data[{}] rolled back to stamp {:?}, height {}", i, s, h ); heights.insert(h); diff --git a/crates/brk_computer/src/distribution/compute/write.rs b/crates/brk_computer/src/distribution/compute/write.rs index 7de24b9e6..1a85f7d0a 100644 --- a/crates/brk_computer/src/distribution/compute/write.rs +++ b/crates/brk_computer/src/distribution/compute/write.rs @@ -1,18 +1,18 @@ use std::time::Instant; use brk_error::Result; -use brk_types::{EmptyAddressData, FundedAddressData, Height}; +use brk_types::{EmptyAddrData, FundedAddrData, Height}; use rayon::prelude::*; use tracing::info; use vecdb::{AnyStoredVec, AnyVec, Stamp, VecIndex, WritableVec}; use crate::distribution::{ Vecs, - block::{WithAddressDataSource, process_empty_addresses, process_funded_addresses}, + block::{WithAddrDataSource, process_empty_addrs, process_funded_addrs}, state::BlockState, }; -use super::super::address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAddressIndexesVecs}; +use super::super::addr::{AddrTypeToTypeIndexMap, AddrsDataVecs, AnyAddrIndexesVecs}; /// Process address updates from caches. /// @@ -22,20 +22,20 @@ use super::super::address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAdd /// - Updates address indexes /// /// Call this before `flush()` to prepare data for writing. -pub(crate) fn process_address_updates( - addresses_data: &mut AddressesDataVecs, - address_indexes: &mut AnyAddressIndexesVecs, - empty_updates: AddressTypeToTypeIndexMap>, - funded_updates: AddressTypeToTypeIndexMap>, +pub(crate) fn process_addr_updates( + addrs_data: &mut AddrsDataVecs, + addr_indexes: &mut AnyAddrIndexesVecs, + empty_updates: AddrTypeToTypeIndexMap>, + funded_updates: AddrTypeToTypeIndexMap>, ) -> Result<()> { - info!("Processing address updates..."); + info!("Processing addr updates..."); let i = Instant::now(); - let empty_result = process_empty_addresses(addresses_data, empty_updates)?; - let funded_result = process_funded_addresses(addresses_data, funded_updates)?; - address_indexes.par_batch_update(empty_result, funded_result)?; + let empty_result = process_empty_addrs(addrs_data, empty_updates)?; + let funded_result = process_funded_addrs(addrs_data, funded_updates)?; + addr_indexes.par_batch_update(empty_result, funded_result)?; - info!("Processed address updates in {:?}", i.elapsed()); + info!("Processed addr updates in {:?}", i.elapsed()); Ok(()) } @@ -73,12 +73,12 @@ pub(crate) fn write( vecs.supply_state.push(block_state.supply); } - vecs.any_address_indexes + vecs.any_addr_indexes .par_iter_mut() - .chain(vecs.addresses_data.par_iter_mut()) - .chain(vecs.addresses.funded.par_iter_height_mut()) - .chain(vecs.addresses.empty.par_iter_height_mut()) - .chain(vecs.addresses.activity.par_iter_height_mut()) + .chain(vecs.addrs_data.par_iter_mut()) + .chain(vecs.addrs.funded.par_iter_height_mut()) + .chain(vecs.addrs.empty.par_iter_height_mut()) + .chain(vecs.addrs.activity.par_iter_height_mut()) .chain( [ &mut vecs.supply_state as &mut dyn AnyStoredVec, @@ -87,13 +87,13 @@ pub(crate) fn write( .into_par_iter(), ) .chain(vecs.utxo_cohorts.par_iter_vecs_mut()) - .chain(vecs.address_cohorts.par_iter_vecs_mut()) + .chain(vecs.addr_cohorts.par_iter_vecs_mut()) .try_for_each(|v| v.any_stamped_write_maybe_with_changes(stamp, with_changes))?; // Commit states after vec writes let cleanup = with_changes; vecs.utxo_cohorts.commit_all_states(height, cleanup)?; - vecs.address_cohorts.commit_all_states(height, cleanup)?; + vecs.addr_cohorts.commit_all_states(height, cleanup)?; info!("Wrote in {:?}", i.elapsed()); diff --git a/crates/brk_computer/src/distribution/mod.rs b/crates/brk_computer/src/distribution/mod.rs index 534bdcf67..fedab2065 100644 --- a/crates/brk_computer/src/distribution/mod.rs +++ b/crates/brk_computer/src/distribution/mod.rs @@ -1,4 +1,4 @@ -pub mod address; +pub mod addr; mod block; pub mod cohorts; pub mod compute; @@ -11,5 +11,5 @@ pub use vecs::Vecs; pub const DB_NAME: &str = "distribution"; -pub use address::{AddressTypeToTypeIndexMap, AddressesDataVecs, AnyAddressIndexesVecs}; -pub use cohorts::{AddressCohorts, DynCohortVecs, UTXOCohorts}; +pub use addr::{AddrTypeToTypeIndexMap, AddrsDataVecs, AnyAddrIndexesVecs}; +pub use cohorts::{AddrCohorts, DynCohortVecs, UTXOCohorts}; diff --git a/crates/brk_computer/src/distribution/state/cohort/address.rs b/crates/brk_computer/src/distribution/state/cohort/addr.rs similarity index 53% rename from crates/brk_computer/src/distribution/state/cohort/address.rs rename to crates/brk_computer/src/distribution/state/cohort/addr.rs index 28c7728c2..b604111e2 100644 --- a/crates/brk_computer/src/distribution/state/cohort/address.rs +++ b/crates/brk_computer/src/distribution/state/cohort/addr.rs @@ -1,7 +1,7 @@ use std::path::Path; use brk_error::Result; -use brk_types::{Age, Cents, FundedAddressData, Sats, SupplyState}; +use brk_types::{Age, Cents, FundedAddrData, Sats, SupplyState}; use vecdb::unlikely; use super::super::cost_basis::{CostBasisRaw, RealizedOps}; @@ -10,22 +10,22 @@ use super::base::CohortState; /// Significant digits for address cost basis prices (after rounding to dollars). const COST_BASIS_PRICE_DIGITS: i32 = 4; -pub struct AddressCohortState { - pub address_count: u64, +pub struct AddrCohortState { + pub addr_count: u64, pub inner: CohortState, } -impl AddressCohortState { +impl AddrCohortState { pub(crate) fn new(path: &Path, name: &str) -> Self { Self { - address_count: 0, + addr_count: 0, inner: CohortState::new(path, name).with_price_rounding(COST_BASIS_PRICE_DIGITS), } } /// Reset state for fresh start. pub(crate) fn reset(&mut self) { - self.address_count = 0; + self.addr_count = 0; self.inner.supply = SupplyState::default(); self.inner.sent = Sats::ZERO; self.inner.satdays_destroyed = Sats::ZERO; @@ -34,18 +34,18 @@ impl AddressCohortState { pub(crate) fn send( &mut self, - address_data: &mut FundedAddressData, + addr_data: &mut FundedAddrData, value: Sats, current_price: Cents, prev_price: Cents, ath: Cents, age: Age, ) -> Result<()> { - let prev = address_data.cost_basis_snapshot(); - address_data.send(value, prev_price)?; - let current = address_data.cost_basis_snapshot(); + let prev = addr_data.cost_basis_snapshot(); + addr_data.send(value, prev_price)?; + let current = addr_data.cost_basis_snapshot(); - self.inner.send_address( + self.inner.send_addr( &SupplyState { utxo_count: 1, value, @@ -63,16 +63,16 @@ impl AddressCohortState { pub(crate) fn receive_outputs( &mut self, - address_data: &mut FundedAddressData, + addr_data: &mut FundedAddrData, value: Sats, price: Cents, output_count: u32, ) { - let prev = address_data.cost_basis_snapshot(); - address_data.receive_outputs(value, price, output_count); - let current = address_data.cost_basis_snapshot(); + let prev = addr_data.cost_basis_snapshot(); + addr_data.receive_outputs(value, price, output_count); + let current = addr_data.cost_basis_snapshot(); - self.inner.receive_address( + self.inner.receive_addr( &SupplyState { utxo_count: output_count as u64, value, @@ -83,53 +83,53 @@ impl AddressCohortState { ); } - pub(crate) fn add(&mut self, address_data: &FundedAddressData) { - self.address_count += 1; + pub(crate) fn add(&mut self, addr_data: &FundedAddrData) { + self.addr_count += 1; self.inner - .increment_snapshot(&address_data.cost_basis_snapshot()); + .increment_snapshot(&addr_data.cost_basis_snapshot()); } - pub(crate) fn subtract(&mut self, address_data: &FundedAddressData) { - let snapshot = address_data.cost_basis_snapshot(); + pub(crate) fn subtract(&mut self, addr_data: &FundedAddrData) { + let snapshot = addr_data.cost_basis_snapshot(); // Check for potential underflow before it happens if unlikely(self.inner.supply.utxo_count < snapshot.supply_state.utxo_count) { panic!( - "AddressCohortState::subtract underflow!\n\ - Cohort state: address_count={}, supply={}\n\ - Address being subtracted: {}\n\ - Address supply: {}\n\ + "AddrCohortState::subtract underflow!\n\ + Cohort state: addr_count={}, supply={}\n\ + Addr being subtracted: {}\n\ + Addr supply: {}\n\ Realized price: {}\n\ - This means the address is not properly tracked in this cohort.", - self.address_count, + This means the addr is not properly tracked in this cohort.", + self.addr_count, self.inner.supply, - address_data, + addr_data, snapshot.supply_state, snapshot.realized_price ); } if unlikely(self.inner.supply.value < snapshot.supply_state.value) { panic!( - "AddressCohortState::subtract value underflow!\n\ - Cohort state: address_count={}, supply={}\n\ - Address being subtracted: {}\n\ - Address supply: {}\n\ + "AddrCohortState::subtract value underflow!\n\ + Cohort state: addr_count={}, supply={}\n\ + Addr being subtracted: {}\n\ + Addr supply: {}\n\ Realized price: {}\n\ - This means the address is not properly tracked in this cohort.", - self.address_count, + This means the addr is not properly tracked in this cohort.", + self.addr_count, self.inner.supply, - address_data, + addr_data, snapshot.supply_state, snapshot.realized_price ); } - self.address_count = self.address_count.checked_sub(1).unwrap_or_else(|| { + self.addr_count = self.addr_count.checked_sub(1).unwrap_or_else(|| { panic!( - "AddressCohortState::subtract address_count underflow! address_count=0\n\ - Address being subtracted: {}\n\ + "AddrCohortState::subtract addr_count underflow! addr_count=0\n\ + Addr being subtracted: {}\n\ Realized price: {}", - address_data, snapshot.realized_price + addr_data, snapshot.realized_price ) }); diff --git a/crates/brk_computer/src/distribution/state/cohort/base.rs b/crates/brk_computer/src/distribution/state/cohort/base.rs index 07f3781bd..ec2d79158 100644 --- a/crates/brk_computer/src/distribution/state/cohort/base.rs +++ b/crates/brk_computer/src/distribution/state/cohort/base.rs @@ -158,7 +158,7 @@ impl CohortState { } } - pub(crate) fn receive_address( + pub(crate) fn receive_addr( &mut self, supply: &SupplyState, price: Cents, @@ -224,7 +224,7 @@ impl CohortState { } #[allow(clippy::too_many_arguments)] - pub(crate) fn send_address( + pub(crate) fn send_addr( &mut self, supply: &SupplyState, current_price: Cents, diff --git a/crates/brk_computer/src/distribution/state/cohort/mod.rs b/crates/brk_computer/src/distribution/state/cohort/mod.rs index 71b673e86..1c057f86d 100644 --- a/crates/brk_computer/src/distribution/state/cohort/mod.rs +++ b/crates/brk_computer/src/distribution/state/cohort/mod.rs @@ -1,7 +1,7 @@ -mod address; +mod addr; mod base; mod utxo; -pub use address::*; +pub use addr::*; pub use base::*; pub use utxo::*; diff --git a/crates/brk_computer/src/distribution/vecs.rs b/crates/brk_computer/src/distribution/vecs.rs index d1341865c..ab91cf665 100644 --- a/crates/brk_computer/src/distribution/vecs.rs +++ b/crates/brk_computer/src/distribution/vecs.rs @@ -4,7 +4,7 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_traversable::Traversable; use brk_types::{ - Cents, EmptyAddressData, EmptyAddressIndex, FundedAddressData, FundedAddressIndex, Height, + Cents, EmptyAddrData, EmptyAddrIndex, FundedAddrData, FundedAddrIndex, Height, Indexes, StoredF64, SupplyState, Timestamp, TxIndex, Version, }; use tracing::{debug, info}; @@ -28,28 +28,28 @@ use crate::{ }; use super::{ - AddressCohorts, AddressesDataVecs, AnyAddressIndexesVecs, RangeMap, UTXOCohorts, - address::{ - AddressCountsVecs, AddressActivityVecs, DeltaVecs, NewAddressCountVecs, TotalAddressCountVecs, + AddrCohorts, AddrsDataVecs, AnyAddrIndexesVecs, RangeMap, UTXOCohorts, + addr::{ + AddrCountsVecs, AddrActivityVecs, DeltaVecs, NewAddrCountVecs, TotalAddrCountVecs, }, }; const VERSION: Version = Version::new(22); #[derive(Traversable)] -pub struct AddressMetricsVecs { - pub funded: AddressCountsVecs, - pub empty: AddressCountsVecs, - pub activity: AddressActivityVecs, - pub total: TotalAddressCountVecs, - pub new: NewAddressCountVecs, +pub struct AddrMetricsVecs { + pub funded: AddrCountsVecs, + pub empty: AddrCountsVecs, + pub activity: AddrActivityVecs, + pub total: TotalAddrCountVecs, + pub new: NewAddrCountVecs, pub delta: DeltaVecs, #[traversable(wrap = "indexes", rename = "funded")] pub funded_index: - LazyVecFrom1, + LazyVecFrom1, #[traversable(wrap = "indexes", rename = "empty")] pub empty_index: - LazyVecFrom1, + LazyVecFrom1, } #[derive(Traversable)] @@ -61,17 +61,17 @@ pub struct Vecs { #[traversable(wrap = "supply", rename = "state")] pub supply_state: M::Stored>, - #[traversable(wrap = "addresses", rename = "indexes")] - pub any_address_indexes: AnyAddressIndexesVecs, - #[traversable(wrap = "addresses", rename = "data")] - pub addresses_data: AddressesDataVecs, + #[traversable(wrap = "addrs", rename = "indexes")] + pub any_addr_indexes: AnyAddrIndexesVecs, + #[traversable(wrap = "addrs", rename = "data")] + pub addrs_data: AddrsDataVecs, #[traversable(wrap = "cohorts", rename = "utxo")] pub utxo_cohorts: UTXOCohorts, - #[traversable(wrap = "cohorts", rename = "address")] - pub address_cohorts: AddressCohorts, + #[traversable(wrap = "cohorts", rename = "addr")] + pub addr_cohorts: AddrCohorts, #[traversable(wrap = "cointime/activity")] pub coinblocks_destroyed: PerBlockCumulativeWithSums, - pub addresses: AddressMetricsVecs, + pub addrs: AddrMetricsVecs, /// In-memory block state for UTXO processing. Persisted via supply_state. /// Kept across compute() calls to avoid O(n) rebuild on resume. @@ -111,47 +111,47 @@ impl Vecs { let utxo_cohorts = UTXOCohorts::forced_import(&db, version, indexes, &states_path, cached_starts)?; - let address_cohorts = AddressCohorts::forced_import(&db, version, indexes, &states_path, cached_starts)?; + let addr_cohorts = AddrCohorts::forced_import(&db, version, indexes, &states_path, cached_starts)?; // Create address data BytesVecs first so we can also use them for identity mappings - let funded_address_index_to_funded_address_data = BytesVec::forced_import_with( - vecdb::ImportOptions::new(&db, "funded_address_data", version) + let funded_addr_index_to_funded_addr_data = BytesVec::forced_import_with( + vecdb::ImportOptions::new(&db, "funded_addr_data", version) .with_saved_stamped_changes(SAVED_STAMPED_CHANGES), )?; - let empty_address_index_to_empty_address_data = BytesVec::forced_import_with( - vecdb::ImportOptions::new(&db, "empty_address_data", version) + let empty_addr_index_to_empty_addr_data = BytesVec::forced_import_with( + vecdb::ImportOptions::new(&db, "empty_addr_data", version) .with_saved_stamped_changes(SAVED_STAMPED_CHANGES), )?; // Identity mappings for traversable - let funded_address_index = LazyVecFrom1::init( - "funded_address_index", + let funded_addr_index = LazyVecFrom1::init( + "funded_addr_index", version, - funded_address_index_to_funded_address_data.read_only_boxed_clone(), + funded_addr_index_to_funded_addr_data.read_only_boxed_clone(), |index, _| index, ); - let empty_address_index = LazyVecFrom1::init( - "empty_address_index", + let empty_addr_index = LazyVecFrom1::init( + "empty_addr_index", version, - empty_address_index_to_empty_address_data.read_only_boxed_clone(), + empty_addr_index_to_empty_addr_data.read_only_boxed_clone(), |index, _| index, ); - let address_count = AddressCountsVecs::forced_import(&db, "address_count", version, indexes)?; - let empty_address_count = - AddressCountsVecs::forced_import(&db, "empty_address_count", version, indexes)?; - let address_activity = - AddressActivityVecs::forced_import(&db, "address_activity", version, indexes, cached_starts)?; + let addr_count = AddrCountsVecs::forced_import(&db, "addr_count", version, indexes)?; + let empty_addr_count = + AddrCountsVecs::forced_import(&db, "empty_addr_count", version, indexes)?; + let addr_activity = + AddrActivityVecs::forced_import(&db, "addr_activity", version, indexes, cached_starts)?; - // Stored total = address_count + empty_address_count (global + per-type, with all derived indexes) - let total_address_count = TotalAddressCountVecs::forced_import(&db, version, indexes)?; + // Stored total = addr_count + empty_addr_count (global + per-type, with all derived indexes) + let total_addr_count = TotalAddrCountVecs::forced_import(&db, version, indexes)?; // Per-block delta of total (global + per-type) - let new_address_count = - NewAddressCountVecs::forced_import(&db, version, indexes, cached_starts)?; + let new_addr_count = + NewAddrCountVecs::forced_import(&db, version, indexes, cached_starts)?; // Growth rate: delta change + rate (global + per-type) - let delta = DeltaVecs::new(version, &address_count, cached_starts, indexes); + let delta = DeltaVecs::new(version, &addr_count, cached_starts, indexes); let this = Self { supply_state: BytesVec::forced_import_with( @@ -159,19 +159,19 @@ impl Vecs { .with_saved_stamped_changes(SAVED_STAMPED_CHANGES), )?, - addresses: AddressMetricsVecs { - funded: address_count, - empty: empty_address_count, - activity: address_activity, - total: total_address_count, - new: new_address_count, + addrs: AddrMetricsVecs { + funded: addr_count, + empty: empty_addr_count, + activity: addr_activity, + total: total_addr_count, + new: new_addr_count, delta, - funded_index: funded_address_index, - empty_index: empty_address_index, + funded_index: funded_addr_index, + empty_index: empty_addr_index, }, utxo_cohorts, - address_cohorts, + addr_cohorts, coinblocks_destroyed: PerBlockCumulativeWithSums::forced_import( &db, @@ -181,10 +181,10 @@ impl Vecs { cached_starts, )?, - any_address_indexes: AnyAddressIndexesVecs::forced_import(&db, version)?, - addresses_data: AddressesDataVecs { - funded: funded_address_index_to_funded_address_data, - empty: empty_address_index_to_empty_address_data, + any_addr_indexes: AnyAddrIndexesVecs::forced_import(&db, version)?, + addrs_data: AddrsDataVecs { + funded: funded_addr_index_to_funded_addr_data, + empty: empty_addr_index_to_empty_addr_data, }, chain_state: Vec::new(), tx_index_to_height: RangeMap::default(), @@ -275,10 +275,10 @@ impl Vecs { let recovered = recover_state( height, chain_state_rollback, - &mut self.any_address_indexes, - &mut self.addresses_data, + &mut self.any_addr_indexes, + &mut self.addrs_data, &mut self.utxo_cohorts, - &mut self.address_cohorts, + &mut self.addr_cohorts, )?; if recovered.starting_height.is_zero() { @@ -302,14 +302,14 @@ impl Vecs { // Recover or reuse chain_state let starting_height = if recovered_height.is_zero() { self.supply_state.reset()?; - self.addresses.funded.reset_height()?; - self.addresses.empty.reset_height()?; - self.addresses.activity.reset_height()?; + self.addrs.funded.reset_height()?; + self.addrs.empty.reset_height()?; + self.addrs.activity.reset_height()?; reset_state( - &mut self.any_address_indexes, - &mut self.addresses_data, + &mut self.any_addr_indexes, + &mut self.addrs_data, &mut self.utxo_cohorts, - &mut self.address_cohorts, + &mut self.addr_cohorts, )?; chain_state.clear(); @@ -356,7 +356,7 @@ impl Vecs { debug!("validating computed versions"); let base_version = VERSION; self.utxo_cohorts.validate_computed_versions(base_version)?; - self.address_cohorts + self.addr_cohorts .validate_computed_versions(base_version)?; debug!("computed versions validated"); @@ -406,7 +406,7 @@ impl Vecs { { let (r1, r2) = rayon::join( || self.utxo_cohorts.compute_overlapping_vecs(starting_indexes, exit), - || self.address_cohorts.compute_overlapping_vecs(starting_indexes, exit), + || self.addr_cohorts.compute_overlapping_vecs(starting_indexes, exit), ); r1?; r2?; @@ -421,30 +421,30 @@ impl Vecs { { let (r1, r2) = rayon::join( || self.utxo_cohorts.compute_rest_part1(prices, starting_indexes, exit), - || self.address_cohorts.compute_rest_part1(prices, starting_indexes, exit), + || self.addr_cohorts.compute_rest_part1(prices, starting_indexes, exit), ); r1?; r2?; } - // 6b. Compute address count sum (by address_type → all) - self.addresses.funded.compute_rest(starting_indexes, exit)?; - self.addresses.empty.compute_rest(starting_indexes, exit)?; + // 6b. Compute address count sum (by addr_type -> all) + self.addrs.funded.compute_rest(starting_indexes, exit)?; + self.addrs.empty.compute_rest(starting_indexes, exit)?; - // 6c. Compute total_address_count = address_count + empty_address_count - self.addresses.total.compute( + // 6c. Compute total_addr_count = addr_count + empty_addr_count + self.addrs.total.compute( starting_indexes.height, - &self.addresses.funded, - &self.addresses.empty, + &self.addrs.funded, + &self.addrs.empty, exit, )?; - self.addresses + self.addrs .activity .compute_rest(starting_indexes.height, exit)?; - self.addresses.new.compute( + self.addrs.new.compute( starting_indexes.height, - &self.addresses.total, + &self.addrs.total, exit, )?; @@ -467,7 +467,7 @@ impl Vecs { &height_to_market_cap, exit, )?; - self.address_cohorts + self.addr_cohorts .compute_rest_part2(prices, starting_indexes, exit)?; let _lock = exit.lock(); @@ -483,13 +483,13 @@ impl Vecs { fn min_stateful_len(&self) -> Height { self.utxo_cohorts .min_stateful_len() - .min(self.address_cohorts.min_stateful_len()) + .min(self.addr_cohorts.min_stateful_len()) .min(Height::from(self.supply_state.len())) - .min(self.any_address_indexes.min_stamped_len()) - .min(self.addresses_data.min_stamped_len()) - .min(Height::from(self.addresses.funded.min_stateful_len())) - .min(Height::from(self.addresses.empty.min_stateful_len())) - .min(Height::from(self.addresses.activity.min_stateful_len())) + .min(self.any_addr_indexes.min_stamped_len()) + .min(self.addrs_data.min_stamped_len()) + .min(Height::from(self.addrs.funded.min_stateful_len())) + .min(Height::from(self.addrs.empty.min_stateful_len())) + .min(Height::from(self.addrs.activity.min_stateful_len())) .min(Height::from(self.coinblocks_destroyed.base.height.len())) } } diff --git a/crates/brk_computer/src/indexes/address.rs b/crates/brk_computer/src/indexes/addr.rs similarity index 51% rename from crates/brk_computer/src/indexes/address.rs rename to crates/brk_computer/src/indexes/addr.rs index 86f7165b3..a5e71bfc6 100644 --- a/crates/brk_computer/src/indexes/address.rs +++ b/crates/brk_computer/src/indexes/addr.rs @@ -1,10 +1,10 @@ use brk_indexer::Indexer; use brk_traversable::Traversable; use brk_types::{ - Address, AddressBytes, EmptyOutputIndex, OpReturnIndex, P2AAddressIndex, P2ABytes, - P2MSOutputIndex, P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, - P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes, - P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, TxIndex, UnknownOutputIndex, + Addr, AddrBytes, EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2ABytes, + P2MSOutputIndex, P2PK33AddrIndex, P2PK33Bytes, P2PK65AddrIndex, P2PK65Bytes, + P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, P2TRAddrIndex, P2TRBytes, + P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TxIndex, UnknownOutputIndex, Version, }; use vecdb::{LazyVecFrom1, ReadableCloneableVec}; @@ -28,52 +28,52 @@ pub struct Vecs { #[derive(Clone, Traversable)] pub struct P2PK33Vecs { pub identity: - LazyVecFrom1, - pub address: LazyVecFrom1, + LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2PK65Vecs { pub identity: - LazyVecFrom1, - pub address: LazyVecFrom1, + LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2PKHVecs { - pub identity: LazyVecFrom1, - pub address: LazyVecFrom1, + pub identity: LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2SHVecs { - pub identity: LazyVecFrom1, - pub address: LazyVecFrom1, + pub identity: LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2TRVecs { - pub identity: LazyVecFrom1, - pub address: LazyVecFrom1, + pub identity: LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2WPKHVecs { pub identity: - LazyVecFrom1, - pub address: LazyVecFrom1, + LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2WSHVecs { - pub identity: LazyVecFrom1, - pub address: LazyVecFrom1, + pub identity: LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] pub struct P2AVecs { - pub identity: LazyVecFrom1, - pub address: LazyVecFrom1, + pub identity: LazyVecFrom1, + pub addr: LazyVecFrom1, } #[derive(Clone, Traversable)] @@ -101,114 +101,114 @@ impl Vecs { Self { p2pk33: P2PK33Vecs { identity: LazyVecFrom1::init( - "p2pk33_address_index", + "p2pk33_addr_index", version, - indexer.vecs.addresses.p2pk33.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2pk33.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2pk33_address", + addr: LazyVecFrom1::init( + "p2pk33_addr", version, - indexer.vecs.addresses.p2pk33.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2pk33.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2pk65: P2PK65Vecs { identity: LazyVecFrom1::init( - "p2pk65_address_index", + "p2pk65_addr_index", version, - indexer.vecs.addresses.p2pk65.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2pk65.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2pk65_address", + addr: LazyVecFrom1::init( + "p2pk65_addr", version, - indexer.vecs.addresses.p2pk65.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2pk65.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2pkh: P2PKHVecs { identity: LazyVecFrom1::init( - "p2pkh_address_index", + "p2pkh_addr_index", version, - indexer.vecs.addresses.p2pkh.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2pkh.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2pkh_address", + addr: LazyVecFrom1::init( + "p2pkh_addr", version, - indexer.vecs.addresses.p2pkh.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2pkh.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2sh: P2SHVecs { identity: LazyVecFrom1::init( - "p2sh_address_index", + "p2sh_addr_index", version, - indexer.vecs.addresses.p2sh.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2sh.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2sh_address", + addr: LazyVecFrom1::init( + "p2sh_addr", version, - indexer.vecs.addresses.p2sh.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2sh.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2tr: P2TRVecs { identity: LazyVecFrom1::init( - "p2tr_address_index", + "p2tr_addr_index", version, - indexer.vecs.addresses.p2tr.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2tr.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2tr_address", + addr: LazyVecFrom1::init( + "p2tr_addr", version, - indexer.vecs.addresses.p2tr.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2tr.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2wpkh: P2WPKHVecs { identity: LazyVecFrom1::init( - "p2wpkh_address_index", + "p2wpkh_addr_index", version, - indexer.vecs.addresses.p2wpkh.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2wpkh.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2wpkh_address", + addr: LazyVecFrom1::init( + "p2wpkh_addr", version, - indexer.vecs.addresses.p2wpkh.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2wpkh.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2wsh: P2WSHVecs { identity: LazyVecFrom1::init( - "p2wsh_address_index", + "p2wsh_addr_index", version, - indexer.vecs.addresses.p2wsh.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2wsh.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2wsh_address", + addr: LazyVecFrom1::init( + "p2wsh_addr", version, - indexer.vecs.addresses.p2wsh.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2wsh.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2a: P2AVecs { identity: LazyVecFrom1::init( - "p2a_address_index", + "p2a_addr_index", version, - indexer.vecs.addresses.p2a.bytes.read_only_boxed_clone(), + indexer.vecs.addrs.p2a.bytes.read_only_boxed_clone(), |index, _| index, ), - address: LazyVecFrom1::init( - "p2a_address", + addr: LazyVecFrom1::init( + "p2a_addr", version, - indexer.vecs.addresses.p2a.bytes.read_only_boxed_clone(), - |_, bytes| Address::try_from(&AddressBytes::from(bytes)).unwrap(), + indexer.vecs.addrs.p2a.bytes.read_only_boxed_clone(), + |_, bytes| Addr::try_from(&AddrBytes::from(bytes)).unwrap(), ), }, p2ms: P2MSVecs { diff --git a/crates/brk_computer/src/indexes/mod.rs b/crates/brk_computer/src/indexes/mod.rs index 9037b342b..f6d5248f3 100644 --- a/crates/brk_computer/src/indexes/mod.rs +++ b/crates/brk_computer/src/indexes/mod.rs @@ -1,4 +1,4 @@ -mod address; +mod addr; mod cached_mappings; mod day1; mod day3; @@ -37,7 +37,7 @@ use crate::{ }; pub use cached_mappings::CachedMappings; -pub use address::Vecs as AddressVecs; +pub use addr::Vecs as AddrVecs; pub use day1::Vecs as Day1Vecs; pub use day3::Vecs as Day3Vecs; pub use epoch::Vecs as EpochVecs; @@ -65,7 +65,7 @@ pub struct Vecs { db: Database, #[traversable(skip)] pub cached_mappings: CachedMappings, - pub address: AddressVecs, + pub addr: AddrVecs, pub height: HeightVecs, pub epoch: EpochVecs, pub halving: HalvingVecs, @@ -97,7 +97,7 @@ impl Vecs { let version = parent_version; - let address = AddressVecs::forced_import(version, indexer); + let addr = AddrVecs::forced_import(version, indexer); let height = HeightVecs::forced_import(&db, version)?; let epoch = EpochVecs::forced_import(&db, version)?; let halving = HalvingVecs::forced_import(&db, version)?; @@ -138,7 +138,7 @@ impl Vecs { let this = Self { cached_mappings, - address, + addr, height, epoch, halving, diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index 54afc1038..07f9f6762 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -306,12 +306,8 @@ impl Computer { .compute(indexer, &mut self.blocks, starting_indexes, exit) })?; - timed("Computed prices", || { - self.prices - .compute(indexer, &self.indexes, &starting_indexes, exit) - })?; - thread::scope(|scope| -> Result<()> { + // Positions only needs indexer + starting_indexes — start immediately. let positions = scope.spawn(|| { timed("Computed positions", || { self.positions @@ -319,10 +315,37 @@ impl Computer { }) }); - timed("Computed blocks", || { - self.blocks - .compute(indexer, &self.indexes, &starting_indexes, exit) - })?; + // Prices and blocks are independent — parallelize. + let (prices_result, blocks_result) = rayon::join( + || { + timed("Computed prices", || { + self.prices + .compute(indexer, &self.indexes, &starting_indexes, exit) + }) + }, + || { + timed("Computed blocks", || { + self.blocks + .compute(indexer, &self.indexes, &starting_indexes, exit) + }) + }, + ); + prices_result?; + blocks_result?; + + // Market only needs indexes, prices, blocks — start it early + // so it runs in the background alongside the rest of the pipeline. + let market = scope.spawn(|| { + timed("Computed market", || { + self.market.compute( + &self.indexes, + &self.prices, + &self.blocks, + &starting_indexes, + exit, + ) + }) + }); // inputs and scripts are independent — parallelize let (inputs_result, scripts_result) = rayon::join( @@ -390,6 +413,7 @@ impl Computer { })?; positions.join().unwrap()?; + market.join().unwrap()?; Ok(()) })?; @@ -427,13 +451,16 @@ impl Computer { Ok(()) })?; + // Indicators doesn't depend on supply or cointime — run it in the + // background alongside supply + cointime to save a scope barrier. thread::scope(|scope| -> Result<()> { - let market = scope.spawn(|| { - timed("Computed market", || { - self.market.compute( - &self.indexes, - &self.prices, - &self.blocks, + let indicators = scope.spawn(|| { + timed("Computed indicators", || { + self.indicators.compute( + &self.mining, + &self.distribution, + &self.transactions, + &self.market, &starting_indexes, exit, ) @@ -453,24 +480,6 @@ impl Computer { ) })?; - market.join().unwrap()?; - Ok(()) - })?; - - thread::scope(|scope| -> Result<()> { - let indicators = scope.spawn(|| { - timed("Computed indicators", || { - self.indicators.compute( - &self.mining, - &self.distribution, - &self.transactions, - &self.market, - &starting_indexes, - exit, - ) - }) - }); - timed("Computed cointime", || { self.cointime.compute( &starting_indexes, diff --git a/crates/brk_computer/src/pools/mod.rs b/crates/brk_computer/src/pools/mod.rs index 00fc1b34b..487102b88 100644 --- a/crates/brk_computer/src/pools/mod.rs +++ b/crates/brk_computer/src/pools/mod.rs @@ -5,7 +5,7 @@ use brk_indexer::Indexer; use brk_store::AnyStore; use brk_traversable::Traversable; use brk_types::{ - Address, AddressBytes, Height, Indexes, OutputType, PoolSlug, Pools, TxOutIndex, pools, + Addr, AddrBytes, Height, Indexes, OutputType, PoolSlug, Pools, TxOutIndex, pools, }; use rayon::prelude::*; use vecdb::{ @@ -121,14 +121,14 @@ impl Vecs { let first_txout_index = indexer.vecs.transactions.first_txout_index.reader(); let output_type = indexer.vecs.outputs.output_type.reader(); let type_index = indexer.vecs.outputs.type_index.reader(); - let p2pk65 = indexer.vecs.addresses.p2pk65.bytes.reader(); - let p2pk33 = indexer.vecs.addresses.p2pk33.bytes.reader(); - let p2pkh = indexer.vecs.addresses.p2pkh.bytes.reader(); - let p2sh = indexer.vecs.addresses.p2sh.bytes.reader(); - let p2wpkh = indexer.vecs.addresses.p2wpkh.bytes.reader(); - let p2wsh = indexer.vecs.addresses.p2wsh.bytes.reader(); - let p2tr = indexer.vecs.addresses.p2tr.bytes.reader(); - let p2a = indexer.vecs.addresses.p2a.bytes.reader(); + let p2pk65 = indexer.vecs.addrs.p2pk65.bytes.reader(); + let p2pk33 = indexer.vecs.addrs.p2pk33.bytes.reader(); + let p2pkh = indexer.vecs.addrs.p2pkh.bytes.reader(); + let p2sh = indexer.vecs.addrs.p2sh.bytes.reader(); + let p2wpkh = indexer.vecs.addrs.p2wpkh.bytes.reader(); + let p2wsh = indexer.vecs.addrs.p2wsh.bytes.reader(); + let p2tr = indexer.vecs.addrs.p2tr.bytes.reader(); + let p2a = indexer.vecs.addrs.p2a.bytes.reader(); let unknown = self.pools.get_unknown(); @@ -165,18 +165,18 @@ impl Vecs { let ot = output_type.get(txout_index.to_usize()); let ti = usize::from(type_index.get(txout_index.to_usize())); match ot { - OutputType::P2PK65 => Some(AddressBytes::from(p2pk65.get(ti))), - OutputType::P2PK33 => Some(AddressBytes::from(p2pk33.get(ti))), - OutputType::P2PKH => Some(AddressBytes::from(p2pkh.get(ti))), - OutputType::P2SH => Some(AddressBytes::from(p2sh.get(ti))), - OutputType::P2WPKH => Some(AddressBytes::from(p2wpkh.get(ti))), - OutputType::P2WSH => Some(AddressBytes::from(p2wsh.get(ti))), - OutputType::P2TR => Some(AddressBytes::from(p2tr.get(ti))), - OutputType::P2A => Some(AddressBytes::from(p2a.get(ti))), + OutputType::P2PK65 => Some(AddrBytes::from(p2pk65.get(ti))), + OutputType::P2PK33 => Some(AddrBytes::from(p2pk33.get(ti))), + OutputType::P2PKH => Some(AddrBytes::from(p2pkh.get(ti))), + OutputType::P2SH => Some(AddrBytes::from(p2sh.get(ti))), + OutputType::P2WPKH => Some(AddrBytes::from(p2wpkh.get(ti))), + OutputType::P2WSH => Some(AddrBytes::from(p2wsh.get(ti))), + OutputType::P2TR => Some(AddrBytes::from(p2tr.get(ti))), + OutputType::P2A => Some(AddrBytes::from(p2a.get(ti))), _ => None, } - .map(|bytes| Address::try_from(&bytes).unwrap()) - .and_then(|address| self.pools.find_from_address(&address)) + .map(|bytes| Addr::try_from(&bytes).unwrap()) + .and_then(|addr| self.pools.find_from_addr(&addr)) }) .or_else(|| self.pools.find_from_coinbase_tag(&coinbase_tag)) .unwrap_or(unknown); diff --git a/crates/brk_computer/src/scripts/count/compute.rs b/crates/brk_computer/src/scripts/count/compute.rs index b85a4034d..0a48c6395 100644 --- a/crates/brk_computer/src/scripts/count/compute.rs +++ b/crates/brk_computer/src/scripts/count/compute.rs @@ -16,8 +16,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2a.first_index, - &indexer.vecs.addresses.p2a.bytes, + &indexer.vecs.addrs.p2a.first_index, + &indexer.vecs.addrs.p2a.bytes, exit, )?) })?; @@ -36,8 +36,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2pk33.first_index, - &indexer.vecs.addresses.p2pk33.bytes, + &indexer.vecs.addrs.p2pk33.first_index, + &indexer.vecs.addrs.p2pk33.bytes, exit, )?) })?; @@ -46,8 +46,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2pk65.first_index, - &indexer.vecs.addresses.p2pk65.bytes, + &indexer.vecs.addrs.p2pk65.first_index, + &indexer.vecs.addrs.p2pk65.bytes, exit, )?) })?; @@ -56,8 +56,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2pkh.first_index, - &indexer.vecs.addresses.p2pkh.bytes, + &indexer.vecs.addrs.p2pkh.first_index, + &indexer.vecs.addrs.p2pkh.bytes, exit, )?) })?; @@ -66,8 +66,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2sh.first_index, - &indexer.vecs.addresses.p2sh.bytes, + &indexer.vecs.addrs.p2sh.first_index, + &indexer.vecs.addrs.p2sh.bytes, exit, )?) })?; @@ -76,8 +76,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2tr.first_index, - &indexer.vecs.addresses.p2tr.bytes, + &indexer.vecs.addrs.p2tr.first_index, + &indexer.vecs.addrs.p2tr.bytes, exit, )?) })?; @@ -86,8 +86,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2wpkh.first_index, - &indexer.vecs.addresses.p2wpkh.bytes, + &indexer.vecs.addrs.p2wpkh.first_index, + &indexer.vecs.addrs.p2wpkh.bytes, exit, )?) })?; @@ -96,8 +96,8 @@ impl Vecs { .compute(starting_indexes.height, exit, |v| { Ok(v.compute_count_from_indexes( starting_indexes.height, - &indexer.vecs.addresses.p2wsh.first_index, - &indexer.vecs.addresses.p2wsh.bytes, + &indexer.vecs.addrs.p2wsh.first_index, + &indexer.vecs.addrs.p2wsh.bytes, exit, )?) })?; diff --git a/crates/brk_error/src/lib.rs b/crates/brk_error/src/lib.rs index ff0fbc74b..acb15b272 100644 --- a/crates/brk_error/src/lib.rs +++ b/crates/brk_error/src/lib.rs @@ -81,7 +81,7 @@ pub enum Error { WrongLength { expected: usize, received: usize }, #[error("Wrong address type")] - WrongAddressType, + WrongAddrType, #[error("Date cannot be indexed, must be 2009-01-03, 2009-01-09 or greater")] UnindexableDate, @@ -90,7 +90,7 @@ pub enum Error { QuickCacheError, #[error("The provided address appears to be invalid")] - InvalidAddress, + InvalidAddr, #[error("Invalid network")] InvalidNetwork, @@ -102,7 +102,7 @@ pub enum Error { MempoolNotAvailable, #[error("Address not found in the blockchain (no transaction history)")] - UnknownAddress, + UnknownAddr, #[error("Failed to find the TXID in the blockchain")] UnknownTxid, diff --git a/crates/brk_indexer/src/indexes.rs b/crates/brk_indexer/src/indexes.rs index 7e40ef435..95bca0aea 100644 --- a/crates/brk_indexer/src/indexes.rs +++ b/crates/brk_indexer/src/indexes.rs @@ -38,33 +38,33 @@ impl IndexesExt for Indexes { vecs.scripts .op_return.first_index .checked_push(height, self.op_return_index)?; - vecs.addresses + vecs.addrs .p2a.first_index - .checked_push(height, self.p2a_address_index)?; + .checked_push(height, self.p2a_addr_index)?; vecs.scripts .unknown.first_index .checked_push(height, self.unknown_output_index)?; - vecs.addresses + vecs.addrs .p2pk33.first_index - .checked_push(height, self.p2pk33_address_index)?; - vecs.addresses + .checked_push(height, self.p2pk33_addr_index)?; + vecs.addrs .p2pk65.first_index - .checked_push(height, self.p2pk65_address_index)?; - vecs.addresses + .checked_push(height, self.p2pk65_addr_index)?; + vecs.addrs .p2pkh.first_index - .checked_push(height, self.p2pkh_address_index)?; - vecs.addresses + .checked_push(height, self.p2pkh_addr_index)?; + vecs.addrs .p2sh.first_index - .checked_push(height, self.p2sh_address_index)?; - vecs.addresses + .checked_push(height, self.p2sh_addr_index)?; + vecs.addrs .p2tr.first_index - .checked_push(height, self.p2tr_address_index)?; - vecs.addresses + .checked_push(height, self.p2tr_addr_index)?; + vecs.addrs .p2wpkh.first_index - .checked_push(height, self.p2wpkh_address_index)?; - vecs.addresses + .checked_push(height, self.p2wpkh_addr_index)?; + vecs.addrs .p2wsh.first_index - .checked_push(height, self.p2wsh_address_index)?; + .checked_push(height, self.p2wsh_addr_index)?; Ok(()) } @@ -115,51 +115,51 @@ impl IndexesExt for Indexes { starting_height, )?; - let p2pk33_address_index = starting_index( - &vecs.addresses.p2pk33.first_index, - &vecs.addresses.p2pk33.bytes, + let p2pk33_addr_index = starting_index( + &vecs.addrs.p2pk33.first_index, + &vecs.addrs.p2pk33.bytes, starting_height, )?; - let p2pk65_address_index = starting_index( - &vecs.addresses.p2pk65.first_index, - &vecs.addresses.p2pk65.bytes, + let p2pk65_addr_index = starting_index( + &vecs.addrs.p2pk65.first_index, + &vecs.addrs.p2pk65.bytes, starting_height, )?; - let p2pkh_address_index = starting_index( - &vecs.addresses.p2pkh.first_index, - &vecs.addresses.p2pkh.bytes, + let p2pkh_addr_index = starting_index( + &vecs.addrs.p2pkh.first_index, + &vecs.addrs.p2pkh.bytes, starting_height, )?; - let p2sh_address_index = starting_index( - &vecs.addresses.p2sh.first_index, - &vecs.addresses.p2sh.bytes, + let p2sh_addr_index = starting_index( + &vecs.addrs.p2sh.first_index, + &vecs.addrs.p2sh.bytes, starting_height, )?; - let p2tr_address_index = starting_index( - &vecs.addresses.p2tr.first_index, - &vecs.addresses.p2tr.bytes, + let p2tr_addr_index = starting_index( + &vecs.addrs.p2tr.first_index, + &vecs.addrs.p2tr.bytes, starting_height, )?; - let p2wpkh_address_index = starting_index( - &vecs.addresses.p2wpkh.first_index, - &vecs.addresses.p2wpkh.bytes, + let p2wpkh_addr_index = starting_index( + &vecs.addrs.p2wpkh.first_index, + &vecs.addrs.p2wpkh.bytes, starting_height, )?; - let p2wsh_address_index = starting_index( - &vecs.addresses.p2wsh.first_index, - &vecs.addresses.p2wsh.bytes, + let p2wsh_addr_index = starting_index( + &vecs.addrs.p2wsh.first_index, + &vecs.addrs.p2wsh.bytes, starting_height, )?; - let p2a_address_index = starting_index( - &vecs.addresses.p2a.first_index, - &vecs.addresses.p2a.bytes, + let p2a_addr_index = starting_index( + &vecs.addrs.p2a.first_index, + &vecs.addrs.p2a.bytes, starting_height, )?; @@ -192,14 +192,14 @@ impl IndexesExt for Indexes { height: starting_height, p2ms_output_index, op_return_index, - p2pk33_address_index, - p2pk65_address_index, - p2pkh_address_index, - p2sh_address_index, - p2tr_address_index, - p2wpkh_address_index, - p2wsh_address_index, - p2a_address_index, + p2pk33_addr_index, + p2pk65_addr_index, + p2pkh_addr_index, + p2sh_addr_index, + p2tr_addr_index, + p2wpkh_addr_index, + p2wsh_addr_index, + p2a_addr_index, tx_index, txin_index, txout_index, diff --git a/crates/brk_indexer/src/lib.rs b/crates/brk_indexer/src/lib.rs index 9f7ea8c4d..8986ac337 100644 --- a/crates/brk_indexer/src/lib.rs +++ b/crates/brk_indexer/src/lib.rs @@ -235,7 +235,7 @@ impl Indexer { txouts, txins, &buffers.same_block_spent, - &mut buffers.already_added_addresses, + &mut buffers.already_added_addrs, &mut buffers.same_block_output_info, )?; diff --git a/crates/brk_indexer/src/processor/mod.rs b/crates/brk_indexer/src/processor/mod.rs index 299ccc270..7f3981175 100644 --- a/crates/brk_indexer/src/processor/mod.rs +++ b/crates/brk_indexer/src/processor/mod.rs @@ -6,9 +6,9 @@ mod types; pub use types::*; -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; -use brk_types::{AddressHash, Block, Height, OutPoint, TxInIndex, TxIndex, TxOutIndex, TypeIndex}; +use brk_types::{AddrHash, Block, Height, OutPoint, TxInIndex, TxIndex, TxOutIndex, TypeIndex}; use rustc_hash::{FxHashMap, FxHashSet}; use crate::{Indexes, Readers, Stores, Vecs}; @@ -40,7 +40,7 @@ impl BlockProcessor<'_> { txouts: Vec, txins: Vec<(TxInIndex, InputSource)>, same_block_spent_outpoints: &FxHashSet, - already_added: &mut ByAddressType>, + already_added: &mut ByAddrType>, same_block_info: &mut FxHashMap, ) -> Result<()> { let height = self.height; @@ -52,12 +52,12 @@ impl BlockProcessor<'_> { let outputs = &mut self.vecs.outputs; let inputs = &mut self.vecs.inputs; - let addresses = &mut self.vecs.addresses; + let addrs = &mut self.vecs.addrs; let scripts = &mut self.vecs.scripts; - let addr_hash_stores = &mut self.stores.address_type_to_address_hash_to_address_index; - let addr_tx_index_stores = &mut self.stores.address_type_to_address_index_and_tx_index; - let addr_outpoint_stores = &mut self.stores.address_type_to_address_index_and_unspent_outpoint; + let addr_hash_stores = &mut self.stores.addr_type_to_addr_hash_to_addr_index; + let addr_tx_index_stores = &mut self.stores.addr_type_to_addr_index_and_tx_index; + let addr_outpoint_stores = &mut self.stores.addr_type_to_addr_index_and_unspent_outpoint; let txid_prefix_store = &mut self.stores.txid_prefix_to_tx_index; let (finalize_result, metadata_result) = rayon::join( @@ -66,7 +66,7 @@ impl BlockProcessor<'_> { indexes, first_txout_index, outputs, - addresses, + addrs, scripts, addr_hash_stores, addr_tx_index_stores, diff --git a/crates/brk_indexer/src/processor/txin.rs b/crates/brk_indexer/src/processor/txin.rs index 712b32e9a..3389a98c9 100644 --- a/crates/brk_indexer/src/processor/txin.rs +++ b/crates/brk_indexer/src/processor/txin.rs @@ -1,8 +1,8 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::{Error, Result}; use brk_store::Store; use brk_types::{ - AddressIndexOutPoint, AddressIndexTxIndex, OutPoint, OutputType, TxInIndex, TxIndex, Txid, + AddrIndexOutPoint, AddrIndexTxIndex, OutPoint, OutputType, TxInIndex, TxIndex, Txid, TxidPrefix, TypeIndex, Unit, Vin, Vout, }; use rayon::prelude::*; @@ -151,8 +151,8 @@ impl<'a> BlockProcessor<'a> { pub(super) fn finalize_inputs( first_txin_index: &mut PcoVec, inputs: &mut InputsVecs, - addr_tx_index_stores: &mut ByAddressType>, - addr_outpoint_stores: &mut ByAddressType>, + addr_tx_index_stores: &mut ByAddrType>, + addr_outpoint_stores: &mut ByAddrType>, txins: Vec<(TxInIndex, InputSource)>, same_block_output_info: &mut FxHashMap, ) -> Result<()> { @@ -203,19 +203,19 @@ pub(super) fn finalize_inputs( inputs.output_type.checked_push(txin_index, output_type)?; inputs.type_index.checked_push(txin_index, type_index)?; - if !output_type.is_address() { + if !output_type.is_addr() { continue; } - let address_type = output_type; - let address_index = type_index; + let addr_type = output_type; + let addr_index = type_index; addr_tx_index_stores - .get_mut_unwrap(address_type) - .insert(AddressIndexTxIndex::from((address_index, tx_index)), Unit); + .get_mut_unwrap(addr_type) + .insert(AddrIndexTxIndex::from((addr_index, tx_index)), Unit); addr_outpoint_stores - .get_mut_unwrap(address_type) - .remove(AddressIndexOutPoint::from((address_index, outpoint))); + .get_mut_unwrap(addr_type) + .remove(AddrIndexOutPoint::from((addr_index, outpoint))); } Ok(()) diff --git a/crates/brk_indexer/src/processor/txout.rs b/crates/brk_indexer/src/processor/txout.rs index 4235ff987..de340536f 100644 --- a/crates/brk_indexer/src/processor/txout.rs +++ b/crates/brk_indexer/src/processor/txout.rs @@ -1,8 +1,8 @@ -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::{Error, Result}; use brk_store::Store; use brk_types::{ - AddressBytes, AddressHash, AddressIndexOutPoint, AddressIndexTxIndex, OutPoint, OutputType, + AddrBytes, AddrHash, AddrIndexOutPoint, AddrIndexTxIndex, OutPoint, OutputType, Sats, TxIndex, TxOutIndex, TypeIndex, Unit, Vout, }; use rayon::prelude::*; @@ -11,7 +11,7 @@ use tracing::error; use vecdb::{BytesVec, WritableVec}; use super::{BlockProcessor, ProcessedOutput, SameBlockOutputInfo}; -use crate::{AddressesVecs, Indexes, OutputsVecs, ScriptsVecs}; +use crate::{AddrsVecs, Indexes, OutputsVecs, ScriptsVecs}; impl<'a> BlockProcessor<'a> { pub fn process_outputs(&self) -> Result>> { @@ -40,48 +40,48 @@ impl<'a> BlockProcessor<'a> { let script = &txout.script_pubkey; let output_type = OutputType::from(script); - if output_type.is_not_address() { + if output_type.is_not_addr() { return Ok(ProcessedOutput { txout_index, txout, tx_index, vout, output_type, - address_info: None, + addr_info: None, existing_type_index: None, }); } - let address_type = output_type; - let address_bytes = AddressBytes::try_from((script, address_type)).unwrap(); - let address_hash = AddressHash::from(&address_bytes); + let addr_type = output_type; + let addr_bytes = AddrBytes::try_from((script, addr_type)).unwrap(); + let addr_hash = AddrHash::from(&addr_bytes); let existing_type_index = self .stores - .address_type_to_address_hash_to_address_index - .get_unwrap(address_type) - .get(&address_hash)? + .addr_type_to_addr_hash_to_addr_index + .get_unwrap(addr_type) + .get(&addr_hash)? .map(|v| *v) .and_then(|type_index_local| { - (type_index_local < self.indexes.to_type_index(address_type)) + (type_index_local < self.indexes.to_type_index(addr_type)) .then_some(type_index_local) }); if check_collisions && let Some(type_index) = existing_type_index { - let prev_addressbytes = self + let prev_addrbytes = self .vecs - .addresses - .get_bytes_by_type(address_type, type_index, &self.readers.addressbytes) - .ok_or(Error::Internal("Missing addressbytes"))?; + .addrs + .get_bytes_by_type(addr_type, type_index, &self.readers.addrbytes) + .ok_or(Error::Internal("Missing addrbytes"))?; - if prev_addressbytes != address_bytes { + if prev_addrbytes != addr_bytes { error!( ?height, ?vout, ?block_tx_index, - ?address_type, - ?prev_addressbytes, - ?address_bytes, + ?addr_type, + ?prev_addrbytes, + ?addr_bytes, ?type_index, "Address hash collision" ); @@ -95,7 +95,7 @@ impl<'a> BlockProcessor<'a> { tx_index, vout, output_type, - address_info: Some((address_bytes, address_hash)), + addr_info: Some((addr_bytes, addr_hash)), existing_type_index, }) }, @@ -109,17 +109,17 @@ pub(super) fn finalize_outputs( indexes: &mut Indexes, first_txout_index: &mut BytesVec, outputs: &mut OutputsVecs, - addresses: &mut AddressesVecs, + addrs: &mut AddrsVecs, scripts: &mut ScriptsVecs, - addr_hash_stores: &mut ByAddressType>, - addr_tx_index_stores: &mut ByAddressType>, - addr_outpoint_stores: &mut ByAddressType>, + addr_hash_stores: &mut ByAddrType>, + addr_tx_index_stores: &mut ByAddrType>, + addr_outpoint_stores: &mut ByAddrType>, txouts: Vec, same_block_spent_outpoints: &FxHashSet, - already_added_address_hash: &mut ByAddressType>, + already_added_addr_hash: &mut ByAddrType>, same_block_output_info: &mut FxHashMap, ) -> Result<()> { - already_added_address_hash + already_added_addr_hash .values_mut() .for_each(|m| m.clear()); same_block_output_info.clear(); @@ -130,7 +130,7 @@ pub(super) fn finalize_outputs( tx_index, vout, output_type, - address_info, + addr_info, existing_type_index, } in txouts { @@ -144,23 +144,23 @@ pub(super) fn finalize_outputs( let type_index = if let Some(ti) = existing_type_index { ti - } else if let Some((address_bytes, address_hash)) = address_info { - let address_type = output_type; - if let Some(&ti) = already_added_address_hash - .get_unwrap(address_type) - .get(&address_hash) + } else if let Some((addr_bytes, addr_hash)) = addr_info { + let addr_type = output_type; + if let Some(&ti) = already_added_addr_hash + .get_unwrap(addr_type) + .get(&addr_hash) { ti } else { - let ti = indexes.increment_address_index(address_type); + let ti = indexes.increment_addr_index(addr_type); - already_added_address_hash - .get_mut_unwrap(address_type) - .insert(address_hash, ti); + already_added_addr_hash + .get_mut_unwrap(addr_type) + .insert(addr_hash, ti); addr_hash_stores - .get_mut_unwrap(address_type) - .insert(address_hash, ti); - addresses.push_bytes_if_needed(ti, address_bytes)?; + .get_mut_unwrap(addr_type) + .insert(addr_hash, ti); + addrs.push_bytes_if_needed(ti, addr_bytes)?; ti } @@ -200,13 +200,13 @@ pub(super) fn finalize_outputs( if output_type.is_unspendable() { continue; - } else if output_type.is_address() { - let address_type = output_type; - let address_index = type_index; + } else if output_type.is_addr() { + let addr_type = output_type; + let addr_index = type_index; addr_tx_index_stores - .get_mut_unwrap(address_type) - .insert(AddressIndexTxIndex::from((address_index, tx_index)), Unit); + .get_mut_unwrap(addr_type) + .insert(AddrIndexTxIndex::from((addr_index, tx_index)), Unit); } let outpoint = OutPoint::new(tx_index, vout); @@ -219,13 +219,13 @@ pub(super) fn finalize_outputs( type_index, }, ); - } else if output_type.is_address() { - let address_type = output_type; - let address_index = type_index; + } else if output_type.is_addr() { + let addr_type = output_type; + let addr_index = type_index; addr_outpoint_stores - .get_mut_unwrap(address_type) - .insert(AddressIndexOutPoint::from((address_index, outpoint)), Unit); + .get_mut_unwrap(addr_type) + .insert(AddrIndexOutPoint::from((addr_index, outpoint)), Unit); } } diff --git a/crates/brk_indexer/src/processor/types.rs b/crates/brk_indexer/src/processor/types.rs index 2eed2c1b4..52436cb9e 100644 --- a/crates/brk_indexer/src/processor/types.rs +++ b/crates/brk_indexer/src/processor/types.rs @@ -1,7 +1,7 @@ use bitcoin::{Transaction, TxOut}; -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_types::{ - AddressBytes, AddressHash, OutPoint, OutputType, TxIndex, TxOutIndex, Txid, TxidPrefix, + AddrBytes, AddrHash, OutPoint, OutputType, TxIndex, TxOutIndex, Txid, TxidPrefix, TypeIndex, Vin, Vout, }; use rustc_hash::{FxHashMap, FxHashSet}; @@ -34,7 +34,7 @@ pub struct ProcessedOutput<'a> { pub tx_index: TxIndex, pub vout: Vout, pub output_type: OutputType, - pub address_info: Option<(AddressBytes, AddressHash)>, + pub addr_info: Option<(AddrBytes, AddrHash)>, pub existing_type_index: Option, } @@ -53,6 +53,6 @@ pub struct ComputedTx<'a> { pub struct BlockBuffers { pub txid_prefix_map: FxHashMap, pub same_block_spent: FxHashSet, - pub already_added_addresses: ByAddressType>, + pub already_added_addrs: ByAddrType>, pub same_block_output_info: FxHashMap, } diff --git a/crates/brk_indexer/src/readers.rs b/crates/brk_indexer/src/readers.rs index d5e9a782c..cd0a17f4d 100644 --- a/crates/brk_indexer/src/readers.rs +++ b/crates/brk_indexer/src/readers.rs @@ -1,29 +1,29 @@ use bitcoin::ScriptBuf; use brk_types::{ - AddressBytes, OutputType, P2AAddressIndex, P2ABytes, P2PK33AddressIndex, P2PK33Bytes, - P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes, - P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, + AddrBytes, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, P2PK33Bytes, + P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, P2SHBytes, + P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TxIndex, TxOutIndex, Txid, TypeIndex, }; use vecdb::{BytesStrategy, VecReader}; use crate::Vecs; -pub struct AddressReaders { - pub p2pk65: VecReader>, - pub p2pk33: VecReader>, - pub p2pkh: VecReader>, - pub p2sh: VecReader>, - pub p2wpkh: VecReader>, - pub p2wsh: VecReader>, - pub p2tr: VecReader>, - pub p2a: VecReader>, +pub struct AddrReaders { + pub p2pk65: VecReader>, + pub p2pk33: VecReader>, + pub p2pkh: VecReader>, + pub p2sh: VecReader>, + pub p2wpkh: VecReader>, + pub p2wsh: VecReader>, + pub p2tr: VecReader>, + pub p2a: VecReader>, } -impl AddressReaders { +impl AddrReaders { pub fn script_pubkey(&self, output_type: OutputType, type_index: TypeIndex) -> ScriptBuf { let idx = usize::from(type_index); - let bytes: Option = match output_type { + let bytes: Option = match output_type { OutputType::P2PK65 => self.p2pk65.try_get(idx).map(Into::into), OutputType::P2PK33 => self.p2pk33.try_get(idx).map(Into::into), OutputType::P2PKH => self.p2pkh.try_get(idx).map(Into::into), @@ -47,7 +47,7 @@ pub struct Readers { pub tx_index_to_first_txout_index: VecReader>, pub txout_index_to_output_type: VecReader>, pub txout_index_to_type_index: VecReader>, - pub addressbytes: AddressReaders, + pub addrbytes: AddrReaders, } impl Readers { @@ -57,7 +57,7 @@ impl Readers { tx_index_to_first_txout_index: vecs.transactions.first_txout_index.reader(), txout_index_to_output_type: vecs.outputs.output_type.reader(), txout_index_to_type_index: vecs.outputs.type_index.reader(), - addressbytes: vecs.addresses.address_readers(), + addrbytes: vecs.addrs.addr_readers(), } } } diff --git a/crates/brk_indexer/src/stores.rs b/crates/brk_indexer/src/stores.rs index 8e27ff085..acf21fea5 100644 --- a/crates/brk_indexer/src/stores.rs +++ b/crates/brk_indexer/src/stores.rs @@ -2,11 +2,11 @@ use std::{fs, path::Path, time::Instant}; use rustc_hash::FxHashSet; -use brk_cohort::ByAddressType; +use brk_cohort::ByAddrType; use brk_error::Result; use brk_store::{AnyStore, Kind, Mode, Store}; use brk_types::{ - AddressHash, AddressIndexOutPoint, AddressIndexTxIndex, BlockHashPrefix, Height, OutPoint, + AddrHash, AddrIndexOutPoint, AddrIndexTxIndex, BlockHashPrefix, Height, OutPoint, OutputType, StoredString, TxIndex, TxOutIndex, TxidPrefix, TypeIndex, Unit, Version, Vout, }; use fjall::{Database, PersistMode}; @@ -22,10 +22,10 @@ use super::Vecs; pub struct Stores { pub db: Database, - pub address_type_to_address_hash_to_address_index: ByAddressType>, - pub address_type_to_address_index_and_tx_index: ByAddressType>, - pub address_type_to_address_index_and_unspent_outpoint: - ByAddressType>, + pub addr_type_to_addr_hash_to_addr_index: ByAddrType>, + pub addr_type_to_addr_index_and_tx_index: ByAddrType>, + pub addr_type_to_addr_index_and_unspent_outpoint: + ByAddrType>, pub blockhash_prefix_to_height: Store, pub height_to_coinbase_tag: Store, pub txid_prefix_to_tx_index: Store, @@ -53,7 +53,7 @@ impl Stores { let database_ref = &database; - let create_address_hash_to_address_index_store = |index| { + let create_addr_hash_to_addr_index_store = |index| { Store::import( database_ref, path, @@ -64,7 +64,7 @@ impl Stores { ) }; - let create_address_index_to_tx_index_store = |index| { + let create_addr_index_to_tx_index_store = |index| { Store::import( database_ref, path, @@ -75,7 +75,7 @@ impl Stores { ) }; - let create_address_index_to_unspent_outpoint_store = |index| { + let create_addr_index_to_unspent_outpoint_store = |index| { Store::import( database_ref, path, @@ -97,14 +97,14 @@ impl Stores { Mode::PushOnly, Kind::Sequential, )?, - address_type_to_address_hash_to_address_index: ByAddressType::new_with_index( - create_address_hash_to_address_index_store, + addr_type_to_addr_hash_to_addr_index: ByAddrType::new_with_index( + create_addr_hash_to_addr_index_store, )?, - address_type_to_address_index_and_tx_index: ByAddressType::new_with_index( - create_address_index_to_tx_index_store, + addr_type_to_addr_index_and_tx_index: ByAddrType::new_with_index( + create_addr_index_to_tx_index_store, )?, - address_type_to_address_index_and_unspent_outpoint: ByAddressType::new_with_index( - create_address_index_to_unspent_outpoint_store, + addr_type_to_addr_index_and_unspent_outpoint: ByAddrType::new_with_index( + create_addr_index_to_unspent_outpoint_store, )?, blockhash_prefix_to_height: Store::import( database_ref, @@ -141,17 +141,17 @@ impl Stores { ] .into_iter() .chain( - self.address_type_to_address_hash_to_address_index + self.addr_type_to_addr_hash_to_addr_index .values() .map(|s| s as &dyn AnyStore), ) .chain( - self.address_type_to_address_index_and_tx_index + self.addr_type_to_addr_index_and_tx_index .values() .map(|s| s as &dyn AnyStore), ) .chain( - self.address_type_to_address_index_and_unspent_outpoint + self.addr_type_to_addr_index_and_unspent_outpoint .values() .map(|s| s as &dyn AnyStore), ) @@ -165,17 +165,17 @@ impl Stores { ] .into_par_iter() .chain( - self.address_type_to_address_hash_to_address_index + self.addr_type_to_addr_hash_to_addr_index .par_values_mut() .map(|s| s as &mut dyn AnyStore), ) .chain( - self.address_type_to_address_index_and_tx_index + self.addr_type_to_addr_index_and_tx_index .par_values_mut() .map(|s| s as &mut dyn AnyStore), ) .chain( - self.address_type_to_address_index_and_unspent_outpoint + self.addr_type_to_addr_index_and_unspent_outpoint .par_values_mut() .map(|s| s as &mut dyn AnyStore), ) @@ -224,15 +224,15 @@ impl Stores { && self.txid_prefix_to_tx_index.is_empty()? && self.height_to_coinbase_tag.is_empty()? && self - .address_type_to_address_hash_to_address_index + .addr_type_to_addr_hash_to_addr_index .values() .try_fold(true, |acc, s| s.is_empty().map(|empty| acc && empty))? && self - .address_type_to_address_index_and_tx_index + .addr_type_to_addr_index_and_tx_index .values() .try_fold(true, |acc, s| s.is_empty().map(|empty| acc && empty))? && self - .address_type_to_address_index_and_unspent_outpoint + .addr_type_to_addr_index_and_unspent_outpoint .values() .try_fold(true, |acc, s| s.is_empty().map(|empty| acc && empty))?) } @@ -257,10 +257,10 @@ impl Stores { self.height_to_coinbase_tag.remove(h); }); - for address_type in OutputType::ADDRESS_TYPES { - for hash in vecs.iter_address_hashes_from(address_type, starting_indexes.height)? { - self.address_type_to_address_hash_to_address_index - .get_mut_unwrap(address_type) + for addr_type in OutputType::ADDR_TYPES { + for hash in vecs.iter_addr_hashes_from(addr_type, starting_indexes.height)? { + self.addr_type_to_addr_hash_to_addr_index + .get_mut_unwrap(addr_type) .remove(hash); } } @@ -299,7 +299,7 @@ impl Stores { let txout_index_to_output_type_reader = vecs.outputs.output_type.reader(); let txout_index_to_type_index_reader = vecs.outputs.type_index.reader(); - let mut address_index_tx_index_to_remove: FxHashSet<(OutputType, TypeIndex, TxIndex)> = + let mut addr_index_tx_index_to_remove: FxHashSet<(OutputType, TypeIndex, TxIndex)> = FxHashSet::default(); let rollback_start = starting_indexes.txout_index.to_usize(); @@ -312,15 +312,15 @@ impl Stores { for (i, txout_index) in (rollback_start..rollback_end).enumerate() { let output_type = txout_index_to_output_type_reader.get(txout_index); - if !output_type.is_address() { + if !output_type.is_addr() { continue; } - let address_type = output_type; - let address_index = txout_index_to_type_index_reader.get(txout_index); + let addr_type = output_type; + let addr_index = txout_index_to_type_index_reader.get(txout_index); let tx_index = tx_indexes[i]; - address_index_tx_index_to_remove.insert((address_type, address_index, tx_index)); + addr_index_tx_index_to_remove.insert((addr_type, addr_index, tx_index)); let vout = Vout::from( txout_index @@ -330,9 +330,9 @@ impl Stores { ); let outpoint = OutPoint::new(tx_index, vout); - self.address_type_to_address_index_and_unspent_outpoint - .get_mut_unwrap(address_type) - .remove(AddressIndexOutPoint::from((address_index, outpoint))); + self.addr_type_to_addr_index_and_unspent_outpoint + .get_mut_unwrap(addr_type) + .remove(AddrIndexOutPoint::from((addr_index, outpoint))); } let start = starting_indexes.txin_index.to_usize(); @@ -364,26 +364,26 @@ impl Stores { .collect(); for (outpoint, output_type, type_index, spending_tx_index) in outputs_to_unspend { - if output_type.is_address() { - let address_type = output_type; - let address_index = type_index; + if output_type.is_addr() { + let addr_type = output_type; + let addr_index = type_index; - address_index_tx_index_to_remove.insert(( - address_type, - address_index, + addr_index_tx_index_to_remove.insert(( + addr_type, + addr_index, spending_tx_index, )); - self.address_type_to_address_index_and_unspent_outpoint - .get_mut_unwrap(address_type) - .insert(AddressIndexOutPoint::from((address_index, outpoint)), Unit); + self.addr_type_to_addr_index_and_unspent_outpoint + .get_mut_unwrap(addr_type) + .insert(AddrIndexOutPoint::from((addr_index, outpoint)), Unit); } } - for (address_type, address_index, tx_index) in address_index_tx_index_to_remove { - self.address_type_to_address_index_and_tx_index - .get_mut_unwrap(address_type) - .remove(AddressIndexTxIndex::from((address_index, tx_index))); + for (addr_type, addr_index, tx_index) in addr_index_tx_index_to_remove { + self.addr_type_to_addr_index_and_tx_index + .get_mut_unwrap(addr_type) + .remove(AddrIndexTxIndex::from((addr_index, tx_index))); } } diff --git a/crates/brk_indexer/src/vecs/addresses.rs b/crates/brk_indexer/src/vecs/addrs.rs similarity index 53% rename from crates/brk_indexer/src/vecs/addresses.rs rename to crates/brk_indexer/src/vecs/addrs.rs index e42b9b246..fbdff7e76 100644 --- a/crates/brk_indexer/src/vecs/addresses.rs +++ b/crates/brk_indexer/src/vecs/addrs.rs @@ -1,9 +1,9 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - AddressBytes, AddressHash, Height, OutputType, P2AAddressIndex, P2ABytes, P2PK33AddressIndex, - P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, - P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex, + AddrBytes, AddrHash, Height, OutputType, P2AAddrIndex, P2ABytes, P2PK33AddrIndex, + P2PK33Bytes, P2PK65AddrIndex, P2PK65Bytes, P2PKHAddrIndex, P2PKHBytes, P2SHAddrIndex, + P2SHBytes, P2TRAddrIndex, P2TRBytes, P2WPKHAddrIndex, P2WPKHBytes, P2WSHAddrIndex, P2WSHBytes, TypeIndex, Version, }; use rayon::prelude::*; @@ -15,37 +15,37 @@ use vecdb::{ }; use crate::parallel_import; -use crate::readers::AddressReaders; +use crate::readers::AddrReaders; #[derive(Traversable)] -pub struct AddressTypeVecs { +pub struct AddrTypeVecs { pub first_index: M::Stored>, pub bytes: M::Stored>, } #[derive(Traversable)] -pub struct AddressesVecs { - pub p2pk65: AddressTypeVecs, - pub p2pk33: AddressTypeVecs, - pub p2pkh: AddressTypeVecs, - pub p2sh: AddressTypeVecs, - pub p2wpkh: AddressTypeVecs, - pub p2wsh: AddressTypeVecs, - pub p2tr: AddressTypeVecs, - pub p2a: AddressTypeVecs, +pub struct AddrsVecs { + pub p2pk65: AddrTypeVecs, + pub p2pk33: AddrTypeVecs, + pub p2pkh: AddrTypeVecs, + pub p2sh: AddrTypeVecs, + pub p2wpkh: AddrTypeVecs, + pub p2wsh: AddrTypeVecs, + pub p2tr: AddrTypeVecs, + pub p2a: AddrTypeVecs, } -impl AddressesVecs { +impl AddrsVecs { pub fn forced_import(db: &Database, version: Version) -> Result { let ( - first_p2pk65_address_index, - first_p2pk33_address_index, - first_p2pkh_address_index, - first_p2sh_address_index, - first_p2wpkh_address_index, - first_p2wsh_address_index, - first_p2tr_address_index, - first_p2a_address_index, + first_p2pk65_addr_index, + first_p2pk33_addr_index, + first_p2pkh_addr_index, + first_p2sh_addr_index, + first_p2wpkh_addr_index, + first_p2wsh_addr_index, + first_p2tr_addr_index, + first_p2a_addr_index, p2pk65_bytes, p2pk33_bytes, p2pkh_bytes, @@ -55,14 +55,14 @@ impl AddressesVecs { p2tr_bytes, p2a_bytes, ) = parallel_import! { - first_p2pk65_address_index = PcoVec::forced_import(db, "first_p2pk65_address_index", version), - first_p2pk33_address_index = PcoVec::forced_import(db, "first_p2pk33_address_index", version), - first_p2pkh_address_index = PcoVec::forced_import(db, "first_p2pkh_address_index", version), - first_p2sh_address_index = PcoVec::forced_import(db, "first_p2sh_address_index", version), - first_p2wpkh_address_index = PcoVec::forced_import(db, "first_p2wpkh_address_index", version), - first_p2wsh_address_index = PcoVec::forced_import(db, "first_p2wsh_address_index", version), - first_p2tr_address_index = PcoVec::forced_import(db, "first_p2tr_address_index", version), - first_p2a_address_index = PcoVec::forced_import(db, "first_p2a_address_index", version), + first_p2pk65_addr_index = PcoVec::forced_import(db, "first_p2pk65_addr_index", version), + first_p2pk33_addr_index = PcoVec::forced_import(db, "first_p2pk33_addr_index", version), + first_p2pkh_addr_index = PcoVec::forced_import(db, "first_p2pkh_addr_index", version), + first_p2sh_addr_index = PcoVec::forced_import(db, "first_p2sh_addr_index", version), + first_p2wpkh_addr_index = PcoVec::forced_import(db, "first_p2wpkh_addr_index", version), + first_p2wsh_addr_index = PcoVec::forced_import(db, "first_p2wsh_addr_index", version), + first_p2tr_addr_index = PcoVec::forced_import(db, "first_p2tr_addr_index", version), + first_p2a_addr_index = PcoVec::forced_import(db, "first_p2a_addr_index", version), p2pk65_bytes = BytesVec::forced_import(db, "p2pk65_bytes", version), p2pk33_bytes = BytesVec::forced_import(db, "p2pk33_bytes", version), p2pkh_bytes = BytesVec::forced_import(db, "p2pkh_bytes", version), @@ -73,14 +73,14 @@ impl AddressesVecs { p2a_bytes = BytesVec::forced_import(db, "p2a_bytes", version), }; Ok(Self { - p2pk65: AddressTypeVecs { first_index: first_p2pk65_address_index, bytes: p2pk65_bytes }, - p2pk33: AddressTypeVecs { first_index: first_p2pk33_address_index, bytes: p2pk33_bytes }, - p2pkh: AddressTypeVecs { first_index: first_p2pkh_address_index, bytes: p2pkh_bytes }, - p2sh: AddressTypeVecs { first_index: first_p2sh_address_index, bytes: p2sh_bytes }, - p2wpkh: AddressTypeVecs { first_index: first_p2wpkh_address_index, bytes: p2wpkh_bytes }, - p2wsh: AddressTypeVecs { first_index: first_p2wsh_address_index, bytes: p2wsh_bytes }, - p2tr: AddressTypeVecs { first_index: first_p2tr_address_index, bytes: p2tr_bytes }, - p2a: AddressTypeVecs { first_index: first_p2a_address_index, bytes: p2a_bytes }, + p2pk65: AddrTypeVecs { first_index: first_p2pk65_addr_index, bytes: p2pk65_bytes }, + p2pk33: AddrTypeVecs { first_index: first_p2pk33_addr_index, bytes: p2pk33_bytes }, + p2pkh: AddrTypeVecs { first_index: first_p2pkh_addr_index, bytes: p2pkh_bytes }, + p2sh: AddrTypeVecs { first_index: first_p2sh_addr_index, bytes: p2sh_bytes }, + p2wpkh: AddrTypeVecs { first_index: first_p2wpkh_addr_index, bytes: p2wpkh_bytes }, + p2wsh: AddrTypeVecs { first_index: first_p2wsh_addr_index, bytes: p2wsh_bytes }, + p2tr: AddrTypeVecs { first_index: first_p2tr_addr_index, bytes: p2tr_bytes }, + p2a: AddrTypeVecs { first_index: first_p2a_addr_index, bytes: p2a_bytes }, }) } @@ -88,14 +88,14 @@ impl AddressesVecs { pub fn truncate( &mut self, height: Height, - p2pk65_address_index: P2PK65AddressIndex, - p2pk33_address_index: P2PK33AddressIndex, - p2pkh_address_index: P2PKHAddressIndex, - p2sh_address_index: P2SHAddressIndex, - p2wpkh_address_index: P2WPKHAddressIndex, - p2wsh_address_index: P2WSHAddressIndex, - p2tr_address_index: P2TRAddressIndex, - p2a_address_index: P2AAddressIndex, + p2pk65_addr_index: P2PK65AddrIndex, + p2pk33_addr_index: P2PK33AddrIndex, + p2pkh_addr_index: P2PKHAddrIndex, + p2sh_addr_index: P2SHAddrIndex, + p2wpkh_addr_index: P2WPKHAddrIndex, + p2wsh_addr_index: P2WSHAddrIndex, + p2tr_addr_index: P2TRAddrIndex, + p2a_addr_index: P2AAddrIndex, stamp: Stamp, ) -> Result<()> { self.p2pk65.first_index @@ -115,21 +115,21 @@ impl AddressesVecs { self.p2a.first_index .truncate_if_needed_with_stamp(height, stamp)?; self.p2pk65.bytes - .truncate_if_needed_with_stamp(p2pk65_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2pk65_addr_index, stamp)?; self.p2pk33.bytes - .truncate_if_needed_with_stamp(p2pk33_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2pk33_addr_index, stamp)?; self.p2pkh.bytes - .truncate_if_needed_with_stamp(p2pkh_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2pkh_addr_index, stamp)?; self.p2sh.bytes - .truncate_if_needed_with_stamp(p2sh_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2sh_addr_index, stamp)?; self.p2wpkh.bytes - .truncate_if_needed_with_stamp(p2wpkh_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2wpkh_addr_index, stamp)?; self.p2wsh.bytes - .truncate_if_needed_with_stamp(p2wsh_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2wsh_addr_index, stamp)?; self.p2tr.bytes - .truncate_if_needed_with_stamp(p2tr_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2tr_addr_index, stamp)?; self.p2a.bytes - .truncate_if_needed_with_stamp(p2a_address_index, stamp)?; + .truncate_if_needed_with_stamp(p2a_addr_index, stamp)?; Ok(()) } @@ -159,69 +159,69 @@ impl AddressesVecs { /// Returns None if the index doesn't exist yet. pub fn get_bytes_by_type( &self, - address_type: OutputType, + addr_type: OutputType, type_index: TypeIndex, - readers: &AddressReaders, - ) -> Option { - match address_type { + readers: &AddrReaders, + ) -> Option { + match addr_type { OutputType::P2PK65 => self .p2pk65.bytes .get_pushed_or_read(type_index.into(), &readers.p2pk65) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2PK33 => self .p2pk33.bytes .get_pushed_or_read(type_index.into(), &readers.p2pk33) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2PKH => self .p2pkh.bytes .get_pushed_or_read(type_index.into(), &readers.p2pkh) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2SH => self .p2sh.bytes .get_pushed_or_read(type_index.into(), &readers.p2sh) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2WPKH => self .p2wpkh.bytes .get_pushed_or_read(type_index.into(), &readers.p2wpkh) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2WSH => self .p2wsh.bytes .get_pushed_or_read(type_index.into(), &readers.p2wsh) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2TR => self .p2tr.bytes .get_pushed_or_read(type_index.into(), &readers.p2tr) - .map(AddressBytes::from), + .map(AddrBytes::from), OutputType::P2A => self .p2a.bytes .get_pushed_or_read(type_index.into(), &readers.p2a) - .map(AddressBytes::from), + .map(AddrBytes::from), _ => unreachable!("get_bytes_by_type called with non-address type"), } } - pub fn push_bytes_if_needed(&mut self, index: TypeIndex, bytes: AddressBytes) -> Result<()> { + pub fn push_bytes_if_needed(&mut self, index: TypeIndex, bytes: AddrBytes) -> Result<()> { match bytes { - AddressBytes::P2PK65(bytes) => self.p2pk65.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2PK33(bytes) => self.p2pk33.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2PKH(bytes) => self.p2pkh.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2SH(bytes) => self.p2sh.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2WPKH(bytes) => self.p2wpkh.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2WSH(bytes) => self.p2wsh.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2TR(bytes) => self.p2tr.bytes.checked_push(index.into(), bytes)?, - AddressBytes::P2A(bytes) => self.p2a.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2PK65(bytes) => self.p2pk65.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2PK33(bytes) => self.p2pk33.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2PKH(bytes) => self.p2pkh.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2SH(bytes) => self.p2sh.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2WPKH(bytes) => self.p2wpkh.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2WSH(bytes) => self.p2wsh.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2TR(bytes) => self.p2tr.bytes.checked_push(index.into(), bytes)?, + AddrBytes::P2A(bytes) => self.p2a.bytes.checked_push(index.into(), bytes)?, }; Ok(()) } /// Iterate address hashes starting from a given height (for rollback). - /// Returns an iterator of AddressHash values for all addresses of the given type + /// Returns an iterator of AddrHash values for all addresses of the given type /// that were added at or after the given height. pub fn iter_hashes_from( &self, - address_type: OutputType, + addr_type: OutputType, height: Height, - ) -> Result + '_>> { + ) -> Result + '_>> { macro_rules! make_iter { ($addr:expr) => {{ match $addr.first_index.collect_one(height) { @@ -229,22 +229,22 @@ impl AddressesVecs { let reader = $addr.bytes.reader(); Ok(Box::new(std::iter::from_fn(move || { reader.try_get(index.to_usize()).map(|typedbytes| { - let bytes = AddressBytes::from(typedbytes); + let bytes = AddrBytes::from(typedbytes); index.increment(); - AddressHash::from(&bytes) + AddrHash::from(&bytes) }) })) - as Box + '_>) + as Box + '_>) } None => { Ok(Box::new(std::iter::empty()) - as Box + '_>) + as Box + '_>) } } }}; } - match address_type { + match addr_type { OutputType::P2PK65 => make_iter!(self.p2pk65), OutputType::P2PK33 => make_iter!(self.p2pk33), OutputType::P2PKH => make_iter!(self.p2pkh), @@ -258,11 +258,11 @@ impl AddressesVecs { } } -macro_rules! impl_address_readers { +macro_rules! impl_addr_readers { ($mode:ty) => { - impl AddressesVecs<$mode> { - pub fn address_readers(&self) -> AddressReaders { - AddressReaders { + impl AddrsVecs<$mode> { + pub fn addr_readers(&self) -> AddrReaders { + AddrReaders { p2pk65: self.p2pk65.bytes.reader(), p2pk33: self.p2pk33.bytes.reader(), p2pkh: self.p2pkh.bytes.reader(), @@ -277,5 +277,5 @@ macro_rules! impl_address_readers { }; } -impl_address_readers!(Rw); -impl_address_readers!(Ro); +impl_addr_readers!(Rw); +impl_addr_readers!(Ro); diff --git a/crates/brk_indexer/src/vecs/mod.rs b/crates/brk_indexer/src/vecs/mod.rs index a7f3a88bb..e45209d6c 100644 --- a/crates/brk_indexer/src/vecs/mod.rs +++ b/crates/brk_indexer/src/vecs/mod.rs @@ -2,7 +2,7 @@ use std::path::Path; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{AddressHash, Height, OutputType, Version}; +use brk_types::{AddrHash, Height, OutputType, Version}; use rayon::prelude::*; use vecdb::{AnyStoredVec, Database, Rw, Stamp, StorageMode}; @@ -10,7 +10,7 @@ const PAGE_SIZE: usize = 4096; use crate::parallel_import; -mod addresses; +mod addrs; mod blocks; mod inputs; mod macros; @@ -18,7 +18,7 @@ mod outputs; mod scripts; mod transactions; -pub use addresses::*; +pub use addrs::*; pub use blocks::*; pub use inputs::*; pub use outputs::*; @@ -38,8 +38,8 @@ pub struct Vecs { pub inputs: InputsVecs, #[traversable(wrap = "outputs", rename = "raw")] pub outputs: OutputsVecs, - #[traversable(wrap = "addresses", rename = "raw")] - pub addresses: AddressesVecs, + #[traversable(wrap = "addrs", rename = "raw")] + pub addrs: AddrsVecs, #[traversable(wrap = "scripts", rename = "raw")] pub scripts: ScriptsVecs, } @@ -51,12 +51,12 @@ impl Vecs { tracing::debug!("Setting min len..."); db.set_min_len(PAGE_SIZE * 50_000_000)?; - let (blocks, transactions, inputs, outputs, addresses, scripts) = parallel_import! { + let (blocks, transactions, inputs, outputs, addrs, scripts) = parallel_import! { blocks = BlocksVecs::forced_import(&db, version), transactions = TransactionsVecs::forced_import(&db, version), inputs = InputsVecs::forced_import(&db, version), outputs = OutputsVecs::forced_import(&db, version), - addresses = AddressesVecs::forced_import(&db, version), + addrs = AddrsVecs::forced_import(&db, version), scripts = ScriptsVecs::forced_import(&db, version), }; @@ -66,7 +66,7 @@ impl Vecs { transactions, inputs, outputs, - addresses, + addrs, scripts, }; @@ -95,16 +95,16 @@ impl Vecs { self.outputs .truncate(starting_indexes.height, starting_indexes.txout_index, stamp)?; - self.addresses.truncate( + self.addrs.truncate( starting_indexes.height, - starting_indexes.p2pk65_address_index, - starting_indexes.p2pk33_address_index, - starting_indexes.p2pkh_address_index, - starting_indexes.p2sh_address_index, - starting_indexes.p2wpkh_address_index, - starting_indexes.p2wsh_address_index, - starting_indexes.p2tr_address_index, - starting_indexes.p2a_address_index, + starting_indexes.p2pk65_addr_index, + starting_indexes.p2pk33_addr_index, + starting_indexes.p2pkh_addr_index, + starting_indexes.p2sh_addr_index, + starting_indexes.p2wpkh_addr_index, + starting_indexes.p2wsh_addr_index, + starting_indexes.p2tr_addr_index, + starting_indexes.p2a_addr_index, stamp, )?; @@ -148,12 +148,12 @@ impl Vecs { Ok(()) } - pub fn iter_address_hashes_from( + pub fn iter_addr_hashes_from( &self, - address_type: OutputType, + addr_type: OutputType, height: Height, - ) -> Result + '_>> { - self.addresses.iter_hashes_from(address_type, height) + ) -> Result + '_>> { + self.addrs.iter_hashes_from(addr_type, height) } fn par_iter_mut_any_stored_vec( @@ -164,7 +164,7 @@ impl Vecs { .chain(self.transactions.par_iter_mut_any()) .chain(self.inputs.par_iter_mut_any()) .chain(self.outputs.par_iter_mut_any()) - .chain(self.addresses.par_iter_mut_any()) + .chain(self.addrs.par_iter_mut_any()) .chain(self.scripts.par_iter_mut_any()) } diff --git a/crates/brk_mempool/examples/mempool.rs b/crates/brk_mempool/examples/mempool.rs index 78d9e26f2..4d0d453d8 100644 --- a/crates/brk_mempool/examples/mempool.rs +++ b/crates/brk_mempool/examples/mempool.rs @@ -63,9 +63,9 @@ fn main() -> Result<()> { } // Address tracking stats - let addresses = mempool.get_addresses(); + let addrs = mempool.get_addrs(); println!("\n=== Address Tracking ==="); - println!(" Addresses with pending txs: {}", addresses.len()); + println!(" Addresses with pending txs: {}", addrs.len()); println!("\n----------------------------------------"); } diff --git a/crates/brk_mempool/src/addresses.rs b/crates/brk_mempool/src/addrs.rs similarity index 82% rename from crates/brk_mempool/src/addresses.rs rename to crates/brk_mempool/src/addrs.rs index 0b3325e51..535a23d03 100644 --- a/crates/brk_mempool/src/addresses.rs +++ b/crates/brk_mempool/src/addrs.rs @@ -1,15 +1,15 @@ -use brk_types::{AddressBytes, AddressMempoolStats, Transaction, Txid}; +use brk_types::{AddrBytes, AddrMempoolStats, Transaction, Txid}; use derive_more::Deref; use rustc_hash::{FxHashMap, FxHashSet}; /// Per-address stats with associated transaction set. -pub type AddressStats = (AddressMempoolStats, FxHashSet); +pub type AddrStats = (AddrMempoolStats, FxHashSet); /// Tracks per-address mempool statistics. #[derive(Default, Deref)] -pub struct AddressTracker(FxHashMap); +pub struct AddrTracker(FxHashMap); -impl AddressTracker { +impl AddrTracker { /// Add a transaction to address tracking. pub fn add_tx(&mut self, tx: &Transaction, txid: &Txid) { self.update(tx, txid, true); @@ -26,7 +26,7 @@ impl AddressTracker { let Some(prevout) = txin.prevout.as_ref() else { continue; }; - let Some(bytes) = prevout.address_bytes() else { + let Some(bytes) = prevout.addr_bytes() else { continue; }; @@ -43,7 +43,7 @@ impl AddressTracker { // Outputs: track receiving for txout in &tx.output { - let Some(bytes) = txout.address_bytes() else { + let Some(bytes) = txout.addr_bytes() else { continue; }; diff --git a/crates/brk_mempool/src/lib.rs b/crates/brk_mempool/src/lib.rs index 83e3cd814..ded1ea59f 100644 --- a/crates/brk_mempool/src/lib.rs +++ b/crates/brk_mempool/src/lib.rs @@ -1,4 +1,4 @@ -mod addresses; +mod addrs; mod block_builder; mod entry; mod entry_pool; diff --git a/crates/brk_mempool/src/sync.rs b/crates/brk_mempool/src/sync.rs index adcaf246b..ca0552fa5 100644 --- a/crates/brk_mempool/src/sync.rs +++ b/crates/brk_mempool/src/sync.rs @@ -10,14 +10,14 @@ use std::{ use brk_error::Result; use brk_rpc::Client; -use brk_types::{AddressBytes, MempoolEntryInfo, MempoolInfo, TxWithHex, Txid, TxidPrefix}; +use brk_types::{AddrBytes, MempoolEntryInfo, MempoolInfo, TxWithHex, Txid, TxidPrefix}; use derive_more::Deref; use parking_lot::{RwLock, RwLockReadGuard}; use rustc_hash::FxHashMap; use tracing::error; use crate::{ - addresses::AddressTracker, + addrs::AddrTracker, block_builder::build_projected_blocks, entry::Entry, entry_pool::EntryPool, @@ -49,7 +49,7 @@ pub struct MempoolInner { info: RwLock, txs: RwLock, - addresses: RwLock, + addrs: RwLock, entries: RwLock, snapshot: RwLock, @@ -64,7 +64,7 @@ impl MempoolInner { client, info: RwLock::new(MempoolInfo::default()), txs: RwLock::new(TxStore::default()), - addresses: RwLock::new(AddressTracker::default()), + addrs: RwLock::new(AddrTracker::default()), entries: RwLock::new(EntryPool::default()), snapshot: RwLock::new(Snapshot::default()), dirty: AtomicBool::new(false), @@ -92,9 +92,9 @@ impl MempoolInner { self.snapshot.read().next_block_hash() } - pub fn address_hash(&self, address: &AddressBytes) -> u64 { - let addresses = self.addresses.read(); - let Some((stats, _)) = addresses.get(address) else { + pub fn addr_hash(&self, addr: &AddrBytes) -> u64 { + let addrs = self.addrs.read(); + let Some((stats, _)) = addrs.get(addr) else { return 0; }; let mut hasher = DefaultHasher::new(); @@ -106,8 +106,8 @@ impl MempoolInner { self.txs.read() } - pub fn get_addresses(&self) -> RwLockReadGuard<'_, AddressTracker> { - self.addresses.read() + pub fn get_addrs(&self) -> RwLockReadGuard<'_, AddrTracker> { + self.addrs.read() } /// Start an infinite update loop with a 1 second interval. @@ -173,7 +173,7 @@ impl MempoolInner { let mut info = self.info.write(); let mut txs = self.txs.write(); - let mut addresses = self.addresses.write(); + let mut addrs = self.addrs.write(); let mut entries = self.entries.write(); let mut had_removals = false; @@ -190,7 +190,7 @@ impl MempoolInner { // Get fee from entries (before removing) - this is the authoritative fee from Bitcoin Core let fee = entries.get(&prefix).map(|e| e.fee).unwrap_or_default(); info.remove(tx, fee); - addresses.remove_tx(tx, txid); + addrs.remove_tx(tx, txid); entries.remove(&prefix); }, ); @@ -205,7 +205,7 @@ impl MempoolInner { }; info.add(tx, entry_info.fee); - addresses.add_tx(tx, txid); + addrs.add_tx(tx, txid); entries.insert(prefix, Entry::from_info(entry_info)); } txs.extend(new_txs); diff --git a/crates/brk_query/examples/query.rs b/crates/brk_query/examples/query.rs index ce72a2274..d84ddd47c 100644 --- a/crates/brk_query/examples/query.rs +++ b/crates/brk_query/examples/query.rs @@ -7,7 +7,7 @@ use brk_mempool::Mempool; use brk_query::Query; use brk_reader::Reader; use brk_rpc::{Auth, Client}; -use brk_types::{Address, OutputType}; +use brk_types::{Addr, OutputType}; use vecdb::Exit; pub fn main() -> Result<()> { @@ -48,22 +48,22 @@ pub fn main() -> Result<()> { dbg!( indexer .stores - .address_type_to_address_hash_to_address_index + .addr_type_to_addr_hash_to_addr_index .get_unwrap(OutputType::P2WSH) .approximate_len() ); - let _ = dbg!(query.address(Address::from( + let _ = dbg!(query.addr(Addr::from( "bc1qwzrryqr3ja8w7hnja2spmkgfdcgvqwp5swz4af4ngsjecfz0w0pqud7k38".to_string(), ))); - let _ = dbg!(query.address_txids( - Address::from("bc1qwzrryqr3ja8w7hnja2spmkgfdcgvqwp5swz4af4ngsjecfz0w0pqud7k38".to_string()), + let _ = dbg!(query.addr_txids( + Addr::from("bc1qwzrryqr3ja8w7hnja2spmkgfdcgvqwp5swz4af4ngsjecfz0w0pqud7k38".to_string()), None, 25 )); - let _ = dbg!(query.address_utxos(Address::from( + let _ = dbg!(query.addr_utxos(Addr::from( "bc1qwzrryqr3ja8w7hnja2spmkgfdcgvqwp5swz4af4ngsjecfz0w0pqud7k38".to_string() ))); diff --git a/crates/brk_query/src/async.rs b/crates/brk_query/src/async.rs index c6cd02bca..04ff04e04 100644 --- a/crates/brk_query/src/async.rs +++ b/crates/brk_query/src/async.rs @@ -26,7 +26,7 @@ impl AsyncQuery { /// /// # Example /// ```ignore - /// let address_stats = query.run(move |q| q.address(address)).await?; + /// let addr_stats = query.run(move |q| q.addr(addr)).await?; /// ``` pub async fn run(&self, f: F) -> Result where diff --git a/crates/brk_query/src/impl/address.rs b/crates/brk_query/src/impl/addr.rs similarity index 64% rename from crates/brk_query/src/impl/address.rs rename to crates/brk_query/src/impl/addr.rs index 6edb21d99..bba31ce22 100644 --- a/crates/brk_query/src/impl/address.rs +++ b/crates/brk_query/src/impl/addr.rs @@ -3,9 +3,9 @@ use std::str::FromStr; use bitcoin::{Network, PublicKey, ScriptBuf}; use brk_error::{Error, Result}; use brk_types::{ - Address, AddressBytes, AddressChainStats, AddressHash, AddressIndexOutPoint, - AddressIndexTxIndex, AddressStats, AnyAddressDataIndexEnum, OutputType, Sats, Transaction, - TxIndex, TxStatus, Txid, TypeIndex, Unit, Utxo, Vout, + Addr, AddrBytes, AddrChainStats, AddrHash, AddrIndexOutPoint, AddrIndexTxIndex, AddrStats, + AnyAddrDataIndexEnum, OutputType, Sats, Transaction, TxIndex, TxStatus, Txid, TypeIndex, Unit, + Utxo, Vout, }; use vecdb::{ReadableVec, VecIndex}; @@ -15,73 +15,73 @@ use crate::Query; const MAX_MEMPOOL_TXIDS: usize = 50; impl Query { - pub fn address(&self, address: Address) -> Result { + pub fn addr(&self, addr: Addr) -> Result { let indexer = self.indexer(); let computer = self.computer(); let stores = &indexer.stores; - let script = if let Ok(address) = bitcoin::Address::from_str(&address) { - if !address.is_valid_for_network(Network::Bitcoin) { + let script = if let Ok(addr) = bitcoin::Address::from_str(&addr) { + if !addr.is_valid_for_network(Network::Bitcoin) { return Err(Error::InvalidNetwork); } - let address = address.assume_checked(); - address.script_pubkey() - } else if let Ok(pubkey) = PublicKey::from_str(&address) { + let addr = addr.assume_checked(); + addr.script_pubkey() + } else if let Ok(pubkey) = PublicKey::from_str(&addr) { ScriptBuf::new_p2pk(&pubkey) } else { - return Err(Error::InvalidAddress); + return Err(Error::InvalidAddr); }; let output_type = OutputType::from(&script); - let Ok(bytes) = AddressBytes::try_from((&script, output_type)) else { - return Err(Error::InvalidAddress); + let Ok(bytes) = AddrBytes::try_from((&script, output_type)) else { + return Err(Error::InvalidAddr); }; - let address_type = output_type; - let hash = AddressHash::from(&bytes); + let addr_type = output_type; + let hash = AddrHash::from(&bytes); let Ok(Some(type_index)) = stores - .address_type_to_address_hash_to_address_index - .get_unwrap(address_type) + .addr_type_to_addr_hash_to_addr_index + .get_unwrap(addr_type) .get(&hash) .map(|opt| opt.map(|cow| cow.into_owned())) else { - return Err(Error::UnknownAddress); + return Err(Error::UnknownAddr); }; - let any_address_index = computer + let any_addr_index = computer .distribution - .any_address_indexes + .any_addr_indexes .get_once(output_type, type_index)?; - let address_data = match any_address_index.to_enum() { - AnyAddressDataIndexEnum::Funded(index) => computer + let addr_data = match any_addr_index.to_enum() { + AnyAddrDataIndexEnum::Funded(index) => computer .distribution - .addresses_data + .addrs_data .funded .reader() .get(usize::from(index)), - AnyAddressDataIndexEnum::Empty(index) => computer + AnyAddrDataIndexEnum::Empty(index) => computer .distribution - .addresses_data + .addrs_data .empty .reader() .get(usize::from(index)) .into(), }; - Ok(AddressStats { - address, - chain_stats: AddressChainStats { + Ok(AddrStats { + addr, + chain_stats: AddrChainStats { type_index, - funded_txo_count: address_data.funded_txo_count, - funded_txo_sum: address_data.received, - spent_txo_count: address_data.spent_txo_count, - spent_txo_sum: address_data.sent, - tx_count: address_data.tx_count, + funded_txo_count: addr_data.funded_txo_count, + funded_txo_sum: addr_data.received, + spent_txo_count: addr_data.spent_txo_count, + spent_txo_sum: addr_data.sent, + tx_count: addr_data.tx_count, }, mempool_stats: self.mempool().map(|mempool| { mempool - .get_addresses() + .get_addrs() .get(&bytes) .map(|(stats, _)| stats) .cloned() @@ -90,26 +90,26 @@ impl Query { }) } - pub fn address_txs( + pub fn addr_txs( &self, - address: Address, + addr: Addr, after_txid: Option, limit: usize, ) -> Result> { - let txindices = self.address_txindices(&address, after_txid, limit)?; + let txindices = self.addr_txindices(&addr, after_txid, limit)?; txindices .into_iter() .map(|tx_index| self.transaction_by_index(tx_index)) .collect() } - pub fn address_txids( + pub fn addr_txids( &self, - address: Address, + addr: Addr, after_txid: Option, limit: usize, ) -> Result> { - let txindices = self.address_txindices(&address, after_txid, limit)?; + let txindices = self.addr_txindices(&addr, after_txid, limit)?; let txid_reader = self.indexer().vecs.transactions.txid.reader(); let txids = txindices .into_iter() @@ -118,19 +118,19 @@ impl Query { Ok(txids) } - fn address_txindices( + fn addr_txindices( &self, - address: &Address, + addr: &Addr, after_txid: Option, limit: usize, ) -> Result> { let indexer = self.indexer(); let stores = &indexer.stores; - let (output_type, type_index) = self.resolve_address(address)?; + let (output_type, type_index) = self.resolve_addr(addr)?; let store = stores - .address_type_to_address_index_and_tx_index + .addr_type_to_addr_index_and_tx_index .get(output_type) .unwrap(); @@ -151,7 +151,7 @@ impl Query { Ok(store .prefix(prefix) .rev() - .filter(|(key, _): &(AddressIndexTxIndex, Unit)| { + .filter(|(key, _): &(AddrIndexTxIndex, Unit)| { if let Some(after) = after_tx_index { key.tx_index() < after } else { @@ -163,15 +163,15 @@ impl Query { .collect()) } - pub fn address_utxos(&self, address: Address) -> Result> { + pub fn addr_utxos(&self, addr: Addr) -> Result> { let indexer = self.indexer(); let stores = &indexer.stores; let vecs = &indexer.vecs; - let (output_type, type_index) = self.resolve_address(&address)?; + let (output_type, type_index) = self.resolve_addr(&addr)?; let store = stores - .address_type_to_address_index_and_unspent_outpoint + .addr_type_to_addr_index_and_unspent_outpoint .get(output_type) .unwrap(); @@ -179,7 +179,7 @@ impl Query { let outpoints: Vec<(TxIndex, Vout)> = store .prefix(prefix) - .map(|(key, _): (AddressIndexOutPoint, Unit)| (key.tx_index(), key.vout())) + .map(|(key, _): (AddrIndexOutPoint, Unit)| (key.tx_index(), key.vout())) .collect(); let txid_reader = vecs.transactions.txid.reader(); @@ -223,23 +223,23 @@ impl Query { Ok(utxos) } - pub fn address_mempool_hash(&self, address: &Address) -> u64 { + pub fn addr_mempool_hash(&self, addr: &Addr) -> u64 { let Some(mempool) = self.mempool() else { return 0; }; - let Ok(bytes) = AddressBytes::from_str(address) else { + let Ok(bytes) = AddrBytes::from_str(addr) else { return 0; }; - mempool.address_hash(&bytes) + mempool.addr_hash(&bytes) } - pub fn address_mempool_txids(&self, address: Address) -> Result> { + pub fn addr_mempool_txids(&self, addr: Addr) -> Result> { let mempool = self.mempool().ok_or(Error::MempoolNotAvailable)?; - let bytes = AddressBytes::from_str(&address)?; - let addresses = mempool.get_addresses(); + let bytes = AddrBytes::from_str(&addr)?; + let addrs = mempool.get_addrs(); - let txids: Vec = addresses + let txids: Vec = addrs .get(&bytes) .map(|(_, txids)| txids.iter().take(MAX_MEMPOOL_TXIDS).cloned().collect()) .unwrap_or_default(); @@ -248,21 +248,21 @@ impl Query { } /// Resolve an address string to its output type and type_index - fn resolve_address(&self, address: &Address) -> Result<(OutputType, TypeIndex)> { + fn resolve_addr(&self, addr: &Addr) -> Result<(OutputType, TypeIndex)> { let stores = &self.indexer().stores; - let bytes = AddressBytes::from_str(address)?; + let bytes = AddrBytes::from_str(addr)?; let output_type = OutputType::from(&bytes); - let hash = AddressHash::from(&bytes); + let hash = AddrHash::from(&bytes); let Ok(Some(type_index)) = stores - .address_type_to_address_hash_to_address_index + .addr_type_to_addr_hash_to_addr_index .get(output_type) .unwrap() .get(&hash) .map(|opt| opt.map(|cow| cow.into_owned())) else { - return Err(Error::UnknownAddress); + return Err(Error::UnknownAddr); }; Ok((output_type, type_index)) diff --git a/crates/brk_query/src/impl/mod.rs b/crates/brk_query/src/impl/mod.rs index 496620961..d836e2008 100644 --- a/crates/brk_query/src/impl/mod.rs +++ b/crates/brk_query/src/impl/mod.rs @@ -1,11 +1,11 @@ -mod address; +mod addr; mod block; mod cost_basis; mod mempool; -mod series; mod mining; mod price; -mod transaction; +mod series; +mod tx; pub use block::BLOCK_TXS_PAGE_SIZE; pub use series::ResolvedQuery; diff --git a/crates/brk_query/src/impl/transaction.rs b/crates/brk_query/src/impl/tx.rs similarity index 98% rename from crates/brk_query/src/impl/transaction.rs rename to crates/brk_query/src/impl/tx.rs index 75334f095..f6d2b6b6c 100644 --- a/crates/brk_query/src/impl/transaction.rs +++ b/crates/brk_query/src/impl/tx.rs @@ -244,7 +244,7 @@ impl Query { let value_reader = indexer.vecs.outputs.value.reader(); let output_type_reader = indexer.vecs.outputs.output_type.reader(); let type_index_reader = indexer.vecs.outputs.type_index.reader(); - let address_readers = indexer.vecs.addresses.address_readers(); + let addr_readers = indexer.vecs.addrs.addr_readers(); // Batch-read outpoints for all inputs (avoids per-input PcoVec page decompression) let outpoints: Vec<_> = indexer.vecs.inputs.outpoint.collect_range_at( @@ -280,7 +280,7 @@ impl Query { output_type_reader.get(usize::from(prev_txout_index)); let prev_type_index = type_index_reader.get(usize::from(prev_txout_index)); let script_pubkey = - address_readers.script_pubkey(prev_output_type, prev_type_index); + addr_readers.script_pubkey(prev_output_type, prev_type_index); let prevout = Some(TxOut::from((script_pubkey, prev_value))); diff --git a/crates/brk_server/src/api/addresses/mod.rs b/crates/brk_server/src/api/addrs/mod.rs similarity index 77% rename from crates/brk_server/src/api/addresses/mod.rs rename to crates/brk_server/src/api/addrs/mod.rs index c1bc8e8d0..6a911403f 100644 --- a/crates/brk_server/src/api/addresses/mod.rs +++ b/crates/brk_server/src/api/addrs/mod.rs @@ -6,20 +6,20 @@ use axum::{ routing::get, }; use brk_types::{ - AddressParam, AddressStats, AddressTxidsParam, AddressValidation, Transaction, Txid, Utxo, - ValidateAddressParam, + AddrParam, AddrStats, AddrTxidsParam, AddrValidation, Transaction, Txid, Utxo, + ValidateAddrParam, }; use crate::{CacheStrategy, extended::TransformResponseExtended}; use super::AppState; -pub trait AddressRoutes { - fn add_addresses_routes(self) -> Self; +pub trait AddrRoutes { + fn add_addr_routes(self) -> Self; } -impl AddressRoutes for ApiRouter { - fn add_addresses_routes(self) -> Self { +impl AddrRoutes for ApiRouter { + fn add_addr_routes(self) -> Self { self .route("/api/address", get(Redirect::temporary("/api/addresses"))) .route("/api/addresses", get(Redirect::temporary("/api#tag/addresses"))) @@ -28,16 +28,16 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, + Path(path): Path, State(state): State | { - state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address(path.address)).await + state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr(path.addr)).await }, |op| op .id("get_address") - .addresses_tag() + .addrs_tag() .summary("Address information") .description("Retrieve address information including balance and transaction counts. Supports all standard Bitcoin address types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address)*") - .ok_response::() + .ok_response::() .not_modified() .bad_request() .not_found() @@ -49,14 +49,14 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, - Query(params): Query, + Path(path): Path, + Query(params): Query, State(state): State | { - state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_txs(path.address, params.after_txid, 25)).await + state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_txs(path.addr, params.after_txid, 25)).await }, |op| op .id("get_address_txs") - .addresses_tag() + .addrs_tag() .summary("Address transactions") .description("Get transaction history for an address, sorted with newest first. Returns up to 50 mempool transactions plus the first 25 confirmed transactions. Use ?after_txid= for pagination.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions)*") .ok_response::>() @@ -71,14 +71,14 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, - Query(params): Query, + Path(path): Path, + Query(params): Query, State(state): State | { - state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_txs(path.address, params.after_txid, 25)).await + state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_txs(path.addr, params.after_txid, 25)).await }, |op| op .id("get_address_confirmed_txs") - .addresses_tag() + .addrs_tag() .summary("Address confirmed transactions") .description("Get confirmed transactions for an address, 25 per page. Use ?after_txid= for pagination.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-chain)*") .ok_response::>() @@ -93,14 +93,14 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, + Path(path): Path, State(state): State | { - let hash = state.sync(|q| q.address_mempool_hash(&path.address)); - state.cached_json(&headers, CacheStrategy::MempoolHash(hash), &uri, move |q| q.address_mempool_txids(path.address)).await + let hash = state.sync(|q| q.addr_mempool_hash(&path.addr)); + state.cached_json(&headers, CacheStrategy::MempoolHash(hash), &uri, move |q| q.addr_mempool_txids(path.addr)).await }, |op| op .id("get_address_mempool_txs") - .addresses_tag() + .addrs_tag() .summary("Address mempool transactions") .description("Get unconfirmed transaction IDs for an address from the mempool (up to 50).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-mempool)*") .ok_response::>() @@ -114,13 +114,13 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, + Path(path): Path, State(state): State | { - state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_utxos(path.address)).await + state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_utxos(path.addr)).await }, |op| op .id("get_address_utxos") - .addresses_tag() + .addrs_tag() .summary("Address UTXOs") .description("Get unspent transaction outputs (UTXOs) for an address. Returns txid, vout, value, and confirmation status for each UTXO.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-utxo)*") .ok_response::>() @@ -135,16 +135,16 @@ impl AddressRoutes for ApiRouter { get_with(async | uri: Uri, headers: HeaderMap, - Path(path): Path, + Path(path): Path, State(state): State | { - state.cached_json(&headers, CacheStrategy::Static, &uri, move |_q| Ok(AddressValidation::from_address(&path.address))).await + state.cached_json(&headers, CacheStrategy::Static, &uri, move |_q| Ok(AddrValidation::from_addr(&path.addr))).await }, |op| op .id("validate_address") - .addresses_tag() + .addrs_tag() .summary("Validate address") .description("Validate a Bitcoin address and get information about its type and scriptPubKey.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-validate)*") - .ok_response::() + .ok_response::() .not_modified() ), ) diff --git a/crates/brk_server/src/api/mod.rs b/crates/brk_server/src/api/mod.rs index 414b98654..9ad05ca43 100644 --- a/crates/brk_server/src/api/mod.rs +++ b/crates/brk_server/src/api/mod.rs @@ -14,7 +14,7 @@ use axum::{ use crate::{ Error, api::{ - addresses::AddressRoutes, blocks::BlockRoutes, mempool::MempoolRoutes, + addrs::AddrRoutes, blocks::BlockRoutes, mempool::MempoolRoutes, metrics_legacy::ApiMetricsLegacyRoutes, mining::MiningRoutes, series::ApiSeriesRoutes, server::ServerRoutes, transactions::TxRoutes, }, @@ -23,7 +23,7 @@ use crate::{ use super::AppState; -mod addresses; +mod addrs; mod blocks; mod mempool; mod metrics_legacy; @@ -46,7 +46,7 @@ impl ApiRoutes for ApiRouter { .add_metrics_legacy_routes() .add_block_routes() .add_tx_routes() - .add_addresses_routes() + .add_addr_routes() .add_mempool_routes() .add_mining_routes() .route("/api/server", get(Redirect::temporary("/api#tag/server"))) diff --git a/crates/brk_server/src/error.rs b/crates/brk_server/src/error.rs index b166d0eba..6019a7c0b 100644 --- a/crates/brk_server/src/error.rs +++ b/crates/brk_server/src/error.rs @@ -23,7 +23,7 @@ struct ErrorDetail { /// Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" #[schemars(with = "String")] r#type: &'static str, - /// Machine-readable error code (e.g. "invalid_address", "series_not_found") + /// Machine-readable error code (e.g. "invalid_addr", "series_not_found") #[schemars(with = "String")] code: &'static str, /// Human-readable description @@ -47,14 +47,14 @@ fn error_status(e: &BrkError) -> StatusCode { match e { BrkError::InvalidTxid | BrkError::InvalidNetwork - | BrkError::InvalidAddress + | BrkError::InvalidAddr | BrkError::UnsupportedType(_) | BrkError::Parse(_) | BrkError::NoSeries | BrkError::SeriesUnsupportedIndex { .. } | BrkError::WeightExceeded { .. } => StatusCode::BAD_REQUEST, - BrkError::UnknownAddress + BrkError::UnknownAddr | BrkError::UnknownTxid | BrkError::NotFound(_) | BrkError::NoData @@ -70,7 +70,7 @@ fn error_status(e: &BrkError) -> StatusCode { fn error_code(e: &BrkError) -> &'static str { match e { - BrkError::InvalidAddress => "invalid_address", + BrkError::InvalidAddr => "invalid_addr", BrkError::InvalidTxid => "invalid_txid", BrkError::InvalidNetwork => "invalid_network", BrkError::UnsupportedType(_) => "unsupported_type", @@ -78,7 +78,7 @@ fn error_code(e: &BrkError) -> &'static str { BrkError::NoSeries => "no_series", BrkError::SeriesUnsupportedIndex { .. } => "series_unsupported_index", BrkError::WeightExceeded { .. } => "weight_exceeded", - BrkError::UnknownAddress => "unknown_address", + BrkError::UnknownAddr => "unknown_addr", BrkError::UnknownTxid => "unknown_txid", BrkError::NotFound(_) => "not_found", BrkError::OutOfRange(_) => "out_of_range", diff --git a/crates/brk_server/src/extended/transform_operation.rs b/crates/brk_server/src/extended/transform_operation.rs index 47a2c67f0..a65ba777e 100644 --- a/crates/brk_server/src/extended/transform_operation.rs +++ b/crates/brk_server/src/extended/transform_operation.rs @@ -6,7 +6,7 @@ use schemars::JsonSchema; use crate::error::ErrorBody; pub trait TransformResponseExtended<'t> { - fn addresses_tag(self) -> Self; + fn addrs_tag(self) -> Self; fn blocks_tag(self) -> Self; fn mempool_tag(self) -> Self; fn metrics_tag(self) -> Self; @@ -40,7 +40,7 @@ pub trait TransformResponseExtended<'t> { } impl<'t> TransformResponseExtended<'t> for TransformOperation<'t> { - fn addresses_tag(self) -> Self { + fn addrs_tag(self) -> Self { self.tag("Addresses") } diff --git a/crates/brk_traversable_derive/src/lib.rs b/crates/brk_traversable_derive/src/lib.rs index 31e912077..feb1f7f96 100644 --- a/crates/brk_traversable_derive/src/lib.rs +++ b/crates/brk_traversable_derive/src/lib.rs @@ -59,9 +59,7 @@ struct FieldInfo<'a> { } /// Returns None for skip, Some((attr, rename, wrap, hidden)) for normal/flatten/hidden. -fn get_field_attr( - field: &syn::Field, -) -> Option<(FieldAttr, Option, Option, bool)> { +fn get_field_attr(field: &syn::Field) -> Option<(FieldAttr, Option, Option, bool)> { let mut attr_type = FieldAttr::Normal; let mut rename = None; let mut wrap = None; @@ -568,13 +566,19 @@ fn generate_iter_body( } fn generate_iterator_impl(infos: &[FieldInfo], struct_hidden: bool) -> proc_macro2::TokenStream { - let all_regular: Vec<_> = infos.iter().filter(|i| !i.is_option).map(|i| i.name).collect(); - let all_option: Vec<_> = infos.iter().filter(|i| i.is_option).map(|i| i.name).collect(); + let all_regular: Vec<_> = infos + .iter() + .filter(|i| !i.is_option) + .map(|i| i.name) + .collect(); + let all_option: Vec<_> = infos + .iter() + .filter(|i| i.is_option) + .map(|i| i.name) + .collect(); let exportable_body = generate_iter_body(&all_regular, &all_option, "iter_any_exportable"); - let has_hidden_fields = infos.iter().any(|i| i.hidden); - let visible_impl = if struct_hidden { // Entire struct is hidden — iter_any_visible returns nothing quote! { @@ -585,9 +589,18 @@ fn generate_iterator_impl(infos: &[FieldInfo], struct_hidden: bool) -> proc_macr } else { // Always generate iter_any_visible that calls iter_any_visible on children // (skipping hidden fields if any), so hidden propagates through the tree - let visible_regular: Vec<_> = infos.iter().filter(|i| !i.is_option && !i.hidden).map(|i| i.name).collect(); - let visible_option: Vec<_> = infos.iter().filter(|i| i.is_option && !i.hidden).map(|i| i.name).collect(); - let visible_body = generate_iter_body(&visible_regular, &visible_option, "iter_any_visible"); + let visible_regular: Vec<_> = infos + .iter() + .filter(|i| !i.is_option && !i.hidden) + .map(|i| i.name) + .collect(); + let visible_option: Vec<_> = infos + .iter() + .filter(|i| i.is_option && !i.hidden) + .map(|i| i.name) + .collect(); + let visible_body = + generate_iter_body(&visible_regular, &visible_option, "iter_any_visible"); quote! { fn iter_any_visible(&self) -> impl Iterator { #visible_body diff --git a/crates/brk_types/src/address.rs b/crates/brk_types/src/addr.rs similarity index 66% rename from crates/brk_types/src/address.rs rename to crates/brk_types/src/addr.rs index 166cd3e08..09b02dbfe 100644 --- a/crates/brk_types/src/address.rs +++ b/crates/brk_types/src/addr.rs @@ -4,65 +4,66 @@ use bitcoin::ScriptBuf; use brk_error::Error; use derive_more::Deref; use schemars::JsonSchema; -use serde::{Deserialize, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use vecdb::Formattable; -use crate::AddressBytes; +use crate::AddrBytes; use super::OutputType; /// Bitcoin address string -#[derive(Debug, Clone, Deref, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Deref, Serialize, Deserialize, JsonSchema)] #[serde(transparent)] #[schemars( example = &"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f", example = &"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", example = &"bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq" )] -pub struct Address(String); +pub struct Addr(String); -impl fmt::Display for Address { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(&self.0) +impl Addr { + /// Get the script for this address + pub fn script(&self) -> Result { + AddrBytes::addr_to_script(&self.0) } } -impl From for Address { +impl From for Addr { #[inline] - fn from(address: String) -> Self { - Self(address) + fn from(addr: String) -> Self { + Self(addr) } } -impl TryFrom<&ScriptBuf> for Address { +impl TryFrom<&ScriptBuf> for Addr { type Error = Error; fn try_from(script: &ScriptBuf) -> Result { Self::try_from((script, OutputType::from(script))) } } -impl TryFrom<(&ScriptBuf, OutputType)> for Address { +impl TryFrom<(&ScriptBuf, OutputType)> for Addr { type Error = Error; fn try_from((script, output_type): (&ScriptBuf, OutputType)) -> Result { match output_type { OutputType::P2PK65 | OutputType::P2PK33 => { // P2PK has no standard address encoding, use raw pubkey hex - let bytes = AddressBytes::try_from((script, output_type))?; + let bytes = AddrBytes::try_from((script, output_type))?; Ok(Self(bytes_to_hex(bytes.as_slice()))) } - _ if output_type.is_address() => { + _ if output_type.is_addr() => { let addr = bitcoin::Address::from_script(script, bitcoin::Network::Bitcoin) - .map_err(|_| Error::InvalidAddress)?; + .map_err(|_| Error::InvalidAddr)?; Ok(Self(addr.to_string())) } - _ => Err(Error::InvalidAddress), + _ => Err(Error::InvalidAddr), } } } -impl TryFrom<&AddressBytes> for Address { +impl TryFrom<&AddrBytes> for Addr { type Error = Error; - fn try_from(bytes: &AddressBytes) -> Result { + fn try_from(bytes: &AddrBytes) -> Result { Self::try_from(&bytes.to_script_pubkey()) } } @@ -76,32 +77,16 @@ fn bytes_to_hex(bytes: &[u8]) -> String { hex_string } -impl Serialize for Address { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.collect_str(&self.0) - } -} - -impl FromStr for Address { +impl FromStr for Addr { type Err = Error; fn from_str(s: &str) -> Result { - let _ = AddressBytes::address_to_script(s)?; + let _ = AddrBytes::addr_to_script(s)?; Ok(Self(s.to_string())) } } -impl Address { - /// Get the script for this address - pub fn script(&self) -> Result { - AddressBytes::address_to_script(&self.0) - } -} - -impl Formattable for Address { +impl Formattable for Addr { fn write_to(&self, buf: &mut Vec) { buf.extend_from_slice(self.0.as_bytes()); } @@ -112,3 +97,9 @@ impl Formattable for Address { buf.push(b'"'); } } + +impl fmt::Display for Addr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.0) + } +} diff --git a/crates/brk_types/src/address_bytes.rs b/crates/brk_types/src/addr_bytes.rs similarity index 71% rename from crates/brk_types/src/address_bytes.rs rename to crates/brk_types/src/addr_bytes.rs index 162355266..8bf268355 100644 --- a/crates/brk_types/src/address_bytes.rs +++ b/crates/brk_types/src/addr_bytes.rs @@ -9,7 +9,7 @@ use super::{ }; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum AddressBytes { +pub enum AddrBytes { P2PK65(P2PK65Bytes), // 65 P2PK33(P2PK33Bytes), // 33 P2PKH(P2PKHBytes), // 20 @@ -20,17 +20,17 @@ pub enum AddressBytes { P2A(P2ABytes), // 2 } -impl AddressBytes { +impl AddrBytes { pub fn as_slice(&self) -> &[u8] { match self { - AddressBytes::P2PK65(bytes) => &bytes[..], - AddressBytes::P2PK33(bytes) => &bytes[..], - AddressBytes::P2PKH(bytes) => &bytes[..], - AddressBytes::P2SH(bytes) => &bytes[..], - AddressBytes::P2WPKH(bytes) => &bytes[..], - AddressBytes::P2WSH(bytes) => &bytes[..], - AddressBytes::P2TR(bytes) => &bytes[..], - AddressBytes::P2A(bytes) => &bytes[..], + AddrBytes::P2PK65(bytes) => &bytes[..], + AddrBytes::P2PK33(bytes) => &bytes[..], + AddrBytes::P2PKH(bytes) => &bytes[..], + AddrBytes::P2SH(bytes) => &bytes[..], + AddrBytes::P2WPKH(bytes) => &bytes[..], + AddrBytes::P2WSH(bytes) => &bytes[..], + AddrBytes::P2TR(bytes) => &bytes[..], + AddrBytes::P2A(bytes) => &bytes[..], } } @@ -41,42 +41,42 @@ impl AddressBytes { /// Reconstruct the script_pubkey from the address bytes pub fn to_script_pubkey(&self) -> ScriptBuf { match self { - AddressBytes::P2PK65(b) => Builder::new() + AddrBytes::P2PK65(b) => Builder::new() .push_slice(***b) .push_opcode(opcodes::all::OP_CHECKSIG) .into_script(), - AddressBytes::P2PK33(b) => Builder::new() + AddrBytes::P2PK33(b) => Builder::new() .push_slice(***b) .push_opcode(opcodes::all::OP_CHECKSIG) .into_script(), - AddressBytes::P2PKH(b) => Builder::new() + AddrBytes::P2PKH(b) => Builder::new() .push_opcode(opcodes::all::OP_DUP) .push_opcode(opcodes::all::OP_HASH160) .push_slice(***b) .push_opcode(opcodes::all::OP_EQUALVERIFY) .push_opcode(opcodes::all::OP_CHECKSIG) .into_script(), - AddressBytes::P2SH(b) => Builder::new() + AddrBytes::P2SH(b) => Builder::new() .push_opcode(opcodes::all::OP_HASH160) .push_slice(***b) .push_opcode(opcodes::all::OP_EQUAL) .into_script(), - AddressBytes::P2WPKH(b) => Builder::new().push_int(0).push_slice(***b).into_script(), - AddressBytes::P2WSH(b) => Builder::new().push_int(0).push_slice(***b).into_script(), - AddressBytes::P2TR(b) => Builder::new().push_int(1).push_slice(***b).into_script(), - AddressBytes::P2A(b) => Builder::new().push_int(1).push_slice(***b).into_script(), + AddrBytes::P2WPKH(b) => Builder::new().push_int(0).push_slice(***b).into_script(), + AddrBytes::P2WSH(b) => Builder::new().push_int(0).push_slice(***b).into_script(), + AddrBytes::P2TR(b) => Builder::new().push_int(1).push_slice(***b).into_script(), + AddrBytes::P2A(b) => Builder::new().push_int(1).push_slice(***b).into_script(), } } } -impl TryFrom<&ScriptBuf> for AddressBytes { +impl TryFrom<&ScriptBuf> for AddrBytes { type Error = Error; fn try_from(script: &ScriptBuf) -> Result { Self::try_from((script, OutputType::from(script))) } } -impl TryFrom<(&ScriptBuf, OutputType)> for AddressBytes { +impl TryFrom<(&ScriptBuf, OutputType)> for AddrBytes { type Error = Error; fn try_from(tuple: (&ScriptBuf, OutputType)) -> Result { let (script, output_type) = tuple; @@ -135,90 +135,90 @@ impl TryFrom<(&ScriptBuf, OutputType)> for AddressBytes { Ok(Self::P2A(P2ABytes::from(bytes))) } OutputType::P2MS | OutputType::Unknown | OutputType::Empty | OutputType::OpReturn => { - Err(Error::WrongAddressType) + Err(Error::WrongAddrType) } } } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2PK65Bytes) -> Self { Self::P2PK65(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2PK33Bytes) -> Self { Self::P2PK33(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2PKHBytes) -> Self { Self::P2PKH(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2SHBytes) -> Self { Self::P2SH(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2WPKHBytes) -> Self { Self::P2WPKH(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2WSHBytes) -> Self { Self::P2WSH(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2TRBytes) -> Self { Self::P2TR(value) } } -impl From for AddressBytes { +impl From for AddrBytes { #[inline] fn from(value: P2ABytes) -> Self { Self::P2A(value) } } -impl AddressBytes { +impl AddrBytes { /// Parse an address string to a ScriptBuf - pub fn address_to_script(address: &str) -> Result { - if let Ok(address) = bitcoin::Address::from_str(address) { - if !address.is_valid_for_network(Network::Bitcoin) { + pub fn addr_to_script(addr: &str) -> Result { + if let Ok(addr) = bitcoin::Address::from_str(addr) { + if !addr.is_valid_for_network(Network::Bitcoin) { return Err(Error::InvalidNetwork); } - let address = address.assume_checked(); - Ok(address.script_pubkey()) - } else if let Ok(pubkey) = PublicKey::from_str(address) { + let addr = addr.assume_checked(); + Ok(addr.script_pubkey()) + } else if let Ok(pubkey) = PublicKey::from_str(addr) { Ok(ScriptBuf::new_p2pk(&pubkey)) } else { - Err(Error::InvalidAddress) + Err(Error::InvalidAddr) } } } -impl FromStr for AddressBytes { +impl FromStr for AddrBytes { type Err = Error; fn from_str(s: &str) -> Result { - let script = Self::address_to_script(s)?; + let script = Self::addr_to_script(s)?; let output_type = OutputType::from(&script); Self::try_from((&script, output_type)) } diff --git a/crates/brk_types/src/address_chain_stats.rs b/crates/brk_types/src/addr_chain_stats.rs similarity index 97% rename from crates/brk_types/src/address_chain_stats.rs rename to crates/brk_types/src/addr_chain_stats.rs index be6c32da8..05a45fdb9 100644 --- a/crates/brk_types/src/address_chain_stats.rs +++ b/crates/brk_types/src/addr_chain_stats.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; /// /// Based on mempool.space's format with type_index extension. #[derive(Debug, Default, Serialize, Deserialize, JsonSchema)] -pub struct AddressChainStats { +pub struct AddrChainStats { /// Total number of transaction outputs that funded this address #[schemars(example = 5)] pub funded_txo_count: u32, diff --git a/crates/brk_types/src/address_hash.rs b/crates/brk_types/src/addr_hash.rs similarity index 51% rename from crates/brk_types/src/address_hash.rs rename to crates/brk_types/src/addr_hash.rs index b7aeafe24..0334daee9 100644 --- a/crates/brk_types/src/address_hash.rs +++ b/crates/brk_types/src/addr_hash.rs @@ -2,33 +2,33 @@ use byteview::ByteView; use derive_more::Deref; use vecdb::Bytes; -use super::AddressBytes; +use super::AddrBytes; #[derive(Debug, Deref, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Bytes, Hash)] -pub struct AddressHash(u64); +pub struct AddrHash(u64); -impl From<&AddressBytes> for AddressHash { +impl From<&AddrBytes> for AddrHash { #[inline] - fn from(address_bytes: &AddressBytes) -> Self { - Self(address_bytes.hash()) + fn from(addr_bytes: &AddrBytes) -> Self { + Self(addr_bytes.hash()) } } -impl From for AddressHash { +impl From for AddrHash { #[inline] fn from(value: ByteView) -> Self { Self(u64::from_be_bytes((&*value).try_into().unwrap())) } } -impl From for ByteView { +impl From for ByteView { #[inline] - fn from(value: AddressHash) -> Self { + fn from(value: AddrHash) -> Self { Self::from(&value) } } -impl From<&AddressHash> for ByteView { +impl From<&AddrHash> for ByteView { #[inline] - fn from(value: &AddressHash) -> Self { + fn from(value: &AddrHash) -> Self { Self::new(&value.0.to_be_bytes()) } } diff --git a/crates/brk_types/src/any_address_index.rs b/crates/brk_types/src/addr_index_any.rs similarity index 52% rename from crates/brk_types/src/any_address_index.rs rename to crates/brk_types/src/addr_index_any.rs index ba27f8e7e..5ecf93b0a 100644 --- a/crates/brk_types/src/any_address_index.rs +++ b/crates/brk_types/src/addr_index_any.rs @@ -4,23 +4,23 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use vecdb::{Bytes, Formattable}; -use crate::{EmptyAddressIndex, FundedAddressIndex, TypeIndex}; +use crate::{EmptyAddrIndex, FundedAddrIndex, TypeIndex}; const MIN_EMPTY_INDEX: u32 = u32::MAX - 4_000_000_000; /// Unified index for any address type (funded or empty) #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Bytes, JsonSchema)] -pub struct AnyAddressIndex(TypeIndex); +pub struct AnyAddrIndex(TypeIndex); -impl AnyAddressIndex { - pub fn to_enum(&self) -> AnyAddressDataIndexEnum { - AnyAddressDataIndexEnum::from(*self) +impl AnyAddrIndex { + pub fn to_enum(&self) -> AnyAddrDataIndexEnum { + AnyAddrDataIndexEnum::from(*self) } } -impl From for AnyAddressIndex { +impl From for AnyAddrIndex { #[inline] - fn from(value: FundedAddressIndex) -> Self { + fn from(value: FundedAddrIndex) -> Self { if u32::from(value) >= MIN_EMPTY_INDEX { panic!("{value} is higher than MIN_EMPTY_INDEX ({MIN_EMPTY_INDEX})") } @@ -28,14 +28,14 @@ impl From for AnyAddressIndex { } } -impl From for AnyAddressIndex { +impl From for AnyAddrIndex { #[inline] - fn from(value: EmptyAddressIndex) -> Self { + fn from(value: EmptyAddrIndex) -> Self { Self(*value + MIN_EMPTY_INDEX) } } -impl Serialize for AnyAddressIndex { +impl Serialize for AnyAddrIndex { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -44,23 +44,23 @@ impl Serialize for AnyAddressIndex { } } -impl<'de> Deserialize<'de> for AnyAddressIndex { +impl<'de> Deserialize<'de> for AnyAddrIndex { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { - let variant = AnyAddressDataIndexEnum::deserialize(deserializer)?; + let variant = AnyAddrDataIndexEnum::deserialize(deserializer)?; Ok(Self::from(variant)) } } -impl fmt::Display for AnyAddressIndex { +impl fmt::Display for AnyAddrIndex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } -impl Formattable for AnyAddressIndex { +impl Formattable for AnyAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); @@ -69,29 +69,29 @@ impl Formattable for AnyAddressIndex { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] -pub enum AnyAddressDataIndexEnum { - Funded(FundedAddressIndex), - Empty(EmptyAddressIndex), +pub enum AnyAddrDataIndexEnum { + Funded(FundedAddrIndex), + Empty(EmptyAddrIndex), } -impl From for AnyAddressDataIndexEnum { +impl From for AnyAddrDataIndexEnum { #[inline] - fn from(value: AnyAddressIndex) -> Self { + fn from(value: AnyAddrIndex) -> Self { let uvalue = u32::from(value.0); if uvalue >= MIN_EMPTY_INDEX { - Self::Empty(EmptyAddressIndex::from(uvalue - MIN_EMPTY_INDEX)) + Self::Empty(EmptyAddrIndex::from(uvalue - MIN_EMPTY_INDEX)) } else { - Self::Funded(FundedAddressIndex::from(value.0)) + Self::Funded(FundedAddrIndex::from(value.0)) } } } -impl From for AnyAddressIndex { +impl From for AnyAddrIndex { #[inline] - fn from(value: AnyAddressDataIndexEnum) -> Self { + fn from(value: AnyAddrDataIndexEnum) -> Self { match value { - AnyAddressDataIndexEnum::Funded(idx) => Self::from(idx), - AnyAddressDataIndexEnum::Empty(idx) => Self::from(idx), + AnyAddrDataIndexEnum::Funded(idx) => Self::from(idx), + AnyAddrDataIndexEnum::Empty(idx) => Self::from(idx), } } } diff --git a/crates/brk_types/src/address_index_outpoint.rs b/crates/brk_types/src/addr_index_outpoint.rs similarity index 52% rename from crates/brk_types/src/address_index_outpoint.rs rename to crates/brk_types/src/addr_index_outpoint.rs index 01a7e80e2..3dd98da4a 100644 --- a/crates/brk_types/src/address_index_outpoint.rs +++ b/crates/brk_types/src/addr_index_outpoint.rs @@ -4,21 +4,21 @@ use byteview::ByteView; use serde::Serialize; use vecdb::Bytes; -use crate::{AddressIndexTxIndex, Vout}; +use crate::{AddrIndexTxIndex, Vout}; use super::{OutPoint, TxIndex, TypeIndex}; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Serialize)] #[repr(C)] -pub struct AddressIndexOutPoint { - address_index_tx_index: AddressIndexTxIndex, // u64 +pub struct AddrIndexOutPoint { + addr_index_tx_index: AddrIndexTxIndex, // u64 vout: Vout, // u16 } -impl AddressIndexOutPoint { +impl AddrIndexOutPoint { #[inline] pub fn tx_index(&self) -> TxIndex { - self.address_index_tx_index.tx_index() + self.addr_index_tx_index.tx_index() } #[inline] @@ -27,47 +27,47 @@ impl AddressIndexOutPoint { } } -impl Hash for AddressIndexOutPoint { +impl Hash for AddrIndexOutPoint { fn hash(&self, state: &mut H) { let mut buf = [0u8; 10]; - buf[0..8].copy_from_slice(&self.address_index_tx_index.to_bytes()); + buf[0..8].copy_from_slice(&self.addr_index_tx_index.to_bytes()); buf[8..].copy_from_slice(&self.vout.to_bytes()); state.write(&buf); } } -impl From<(TypeIndex, OutPoint)> for AddressIndexOutPoint { +impl From<(TypeIndex, OutPoint)> for AddrIndexOutPoint { #[inline] - fn from((address_index, outpoint): (TypeIndex, OutPoint)) -> Self { + fn from((addr_index, outpoint): (TypeIndex, OutPoint)) -> Self { Self { - address_index_tx_index: AddressIndexTxIndex::from((address_index, outpoint.tx_index())), + addr_index_tx_index: AddrIndexTxIndex::from((addr_index, outpoint.tx_index())), vout: outpoint.vout(), } } } -impl From for AddressIndexOutPoint { +impl From for AddrIndexOutPoint { #[inline] fn from(value: ByteView) -> Self { Self { - address_index_tx_index: AddressIndexTxIndex::from(ByteView::new(&value[..8])), + addr_index_tx_index: AddrIndexTxIndex::from(ByteView::new(&value[..8])), vout: Vout::from(u16::from_be_bytes([value[8], value[9]])), } } } -impl From for ByteView { +impl From for ByteView { #[inline] - fn from(value: AddressIndexOutPoint) -> Self { + fn from(value: AddrIndexOutPoint) -> Self { ByteView::from(&value) } } -impl From<&AddressIndexOutPoint> for ByteView { +impl From<&AddrIndexOutPoint> for ByteView { #[inline] - fn from(value: &AddressIndexOutPoint) -> Self { + fn from(value: &AddrIndexOutPoint) -> Self { ByteView::from( [ - &ByteView::from(value.address_index_tx_index), + &ByteView::from(value.addr_index_tx_index), value.vout.to_be_bytes().as_slice(), ] .concat(), diff --git a/crates/brk_types/src/addr_index_tx_index.rs b/crates/brk_types/src/addr_index_tx_index.rs new file mode 100644 index 000000000..61cd16cf4 --- /dev/null +++ b/crates/brk_types/src/addr_index_tx_index.rs @@ -0,0 +1,55 @@ +use std::hash::Hash; + +use byteview::ByteView; +use serde::Serialize; +use vecdb::Bytes; + +use super::{TxIndex, TypeIndex}; + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Serialize, Bytes, Hash)] +pub struct AddrIndexTxIndex(u64); + +impl AddrIndexTxIndex { + pub fn addr_index(&self) -> u32 { + (self.0 >> 32) as u32 + } + + pub fn tx_index(&self) -> TxIndex { + TxIndex::from(self.0 as u32) + } + + pub fn min_for_addr(addr_index: TypeIndex) -> Self { + Self(u64::from(addr_index) << 32) + } + + pub fn max_for_addr(addr_index: TypeIndex) -> Self { + Self((u64::from(addr_index) << 32) | u64::MAX >> 32) + } +} + +impl From<(TypeIndex, TxIndex)> for AddrIndexTxIndex { + #[inline] + fn from((addr_index, tx_index): (TypeIndex, TxIndex)) -> Self { + Self((u64::from(addr_index) << 32) | u64::from(tx_index)) + } +} + +impl From for AddrIndexTxIndex { + #[inline] + fn from(value: ByteView) -> Self { + Self(u64::from_be_bytes((&*value).try_into().unwrap())) + } +} + +impl From for ByteView { + #[inline] + fn from(value: AddrIndexTxIndex) -> Self { + ByteView::from(&value) + } +} +impl From<&AddrIndexTxIndex> for ByteView { + #[inline] + fn from(value: &AddrIndexTxIndex) -> Self { + ByteView::from(value.0.to_be_bytes()) + } +} diff --git a/crates/brk_types/src/address_mempool_stats.rs b/crates/brk_types/src/addr_mempool_stats.rs similarity index 96% rename from crates/brk_types/src/address_mempool_stats.rs rename to crates/brk_types/src/addr_mempool_stats.rs index 4b390aa35..682e0d79f 100644 --- a/crates/brk_types/src/address_mempool_stats.rs +++ b/crates/brk_types/src/addr_mempool_stats.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; /// Based on mempool.space's format. /// #[derive(Debug, Default, Clone, Hash, Serialize, Deserialize, JsonSchema)] -pub struct AddressMempoolStats { +pub struct AddrMempoolStats { /// Number of unconfirmed transaction outputs funding this address #[schemars(example = 0)] pub funded_txo_count: u32, @@ -30,7 +30,7 @@ pub struct AddressMempoolStats { pub tx_count: u32, } -impl AddressMempoolStats { +impl AddrMempoolStats { pub fn receiving(&mut self, txout: &TxOut) { self.funded_txo_count += 1; self.funded_txo_sum += txout.value; diff --git a/crates/brk_types/src/addr_param.rs b/crates/brk_types/src/addr_param.rs new file mode 100644 index 000000000..3057dd663 --- /dev/null +++ b/crates/brk_types/src/addr_param.rs @@ -0,0 +1,10 @@ +use schemars::JsonSchema; +use serde::Deserialize; + +use crate::Addr; + +#[derive(Deserialize, JsonSchema)] +pub struct AddrParam { + #[serde(rename = "address")] + pub addr: Addr, +} diff --git a/crates/brk_types/src/address_stats.rs b/crates/brk_types/src/addr_stats.rs similarity index 70% rename from crates/brk_types/src/address_stats.rs rename to crates/brk_types/src/addr_stats.rs index 7f7ace75a..0f9a3ebe7 100644 --- a/crates/brk_types/src/address_stats.rs +++ b/crates/brk_types/src/addr_stats.rs @@ -1,19 +1,20 @@ -use crate::{Address, AddressChainStats, AddressMempoolStats}; +use crate::{Addr, AddrChainStats, AddrMempoolStats}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; /// Address information compatible with mempool.space API format #[derive(Debug, Serialize, Deserialize, JsonSchema)] -pub struct AddressStats { +pub struct AddrStats { /// Bitcoin address string #[schemars( example = "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" )] - pub address: Address, + #[serde(rename = "address")] + pub addr: Addr, /// Statistics for confirmed transactions on the blockchain - pub chain_stats: AddressChainStats, + pub chain_stats: AddrChainStats, /// Statistics for unconfirmed transactions in the mempool - pub mempool_stats: Option, + pub mempool_stats: Option, } diff --git a/crates/brk_types/src/address_txids_param.rs b/crates/brk_types/src/addr_txids_param.rs similarity index 87% rename from crates/brk_types/src/address_txids_param.rs rename to crates/brk_types/src/addr_txids_param.rs index e50b220dc..367093ac5 100644 --- a/crates/brk_types/src/address_txids_param.rs +++ b/crates/brk_types/src/addr_txids_param.rs @@ -4,7 +4,7 @@ use serde::Deserialize; use crate::Txid; #[derive(Debug, Default, Deserialize, JsonSchema)] -pub struct AddressTxidsParam { +pub struct AddrTxidsParam { /// Txid to paginate from (return transactions before this one) pub after_txid: Option, } diff --git a/crates/brk_types/src/address_validation.rs b/crates/brk_types/src/addr_validation.rs similarity index 88% rename from crates/brk_types/src/address_validation.rs rename to crates/brk_types/src/addr_validation.rs index f7a1ea3d7..8b1234554 100644 --- a/crates/brk_types/src/address_validation.rs +++ b/crates/brk_types/src/addr_validation.rs @@ -2,17 +2,18 @@ use bitcoin::hex::DisplayHex; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::{AddressBytes, OutputType}; +use crate::{AddrBytes, OutputType}; /// Address validation result #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] -pub struct AddressValidation { +pub struct AddrValidation { /// Whether the address is valid pub isvalid: bool, /// The validated address #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option, + #[serde(rename = "address")] + pub addr: Option, /// The scriptPubKey in hex #[serde(skip_serializing_if = "Option::is_none")] @@ -36,12 +37,12 @@ pub struct AddressValidation { pub witness_program: Option, } -impl AddressValidation { +impl AddrValidation { /// Returns an invalid validation result pub fn invalid() -> Self { Self { isvalid: false, - address: None, + addr: None, script_pub_key: None, isscript: None, iswitness: None, @@ -51,8 +52,8 @@ impl AddressValidation { } /// Validate a Bitcoin address string and return details - pub fn from_address(address: &str) -> Self { - let Ok(script) = AddressBytes::address_to_script(address) else { + pub fn from_addr(addr: &str) -> Self { + let Ok(script) = AddrBytes::addr_to_script(addr) else { return Self::invalid(); }; @@ -79,7 +80,7 @@ impl AddressValidation { Self { isvalid: true, - address: Some(address.to_string()), + addr: Some(addr.to_string()), script_pub_key: Some(script_hex), isscript: Some(is_script), iswitness: Some(is_witness), diff --git a/crates/brk_types/src/address_index_tx_index.rs b/crates/brk_types/src/address_index_tx_index.rs deleted file mode 100644 index 0cbfb1044..000000000 --- a/crates/brk_types/src/address_index_tx_index.rs +++ /dev/null @@ -1,55 +0,0 @@ -use std::hash::Hash; - -use byteview::ByteView; -use serde::Serialize; -use vecdb::Bytes; - -use super::{TxIndex, TypeIndex}; - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Serialize, Bytes, Hash)] -pub struct AddressIndexTxIndex(u64); - -impl AddressIndexTxIndex { - pub fn address_index(&self) -> u32 { - (self.0 >> 32) as u32 - } - - pub fn tx_index(&self) -> TxIndex { - TxIndex::from(self.0 as u32) - } - - pub fn min_for_address(address_index: TypeIndex) -> Self { - Self(u64::from(address_index) << 32) - } - - pub fn max_for_address(address_index: TypeIndex) -> Self { - Self((u64::from(address_index) << 32) | u64::MAX >> 32) - } -} - -impl From<(TypeIndex, TxIndex)> for AddressIndexTxIndex { - #[inline] - fn from((address_index, tx_index): (TypeIndex, TxIndex)) -> Self { - Self((u64::from(address_index) << 32) | u64::from(tx_index)) - } -} - -impl From for AddressIndexTxIndex { - #[inline] - fn from(value: ByteView) -> Self { - Self(u64::from_be_bytes((&*value).try_into().unwrap())) - } -} - -impl From for ByteView { - #[inline] - fn from(value: AddressIndexTxIndex) -> Self { - ByteView::from(&value) - } -} -impl From<&AddressIndexTxIndex> for ByteView { - #[inline] - fn from(value: &AddressIndexTxIndex) -> Self { - ByteView::from(value.0.to_be_bytes()) - } -} diff --git a/crates/brk_types/src/address_param.rs b/crates/brk_types/src/address_param.rs deleted file mode 100644 index 8c0d74fea..000000000 --- a/crates/brk_types/src/address_param.rs +++ /dev/null @@ -1,9 +0,0 @@ -use schemars::JsonSchema; -use serde::Deserialize; - -use crate::Address; - -#[derive(Deserialize, JsonSchema)] -pub struct AddressParam { - pub address: Address, -} diff --git a/crates/brk_types/src/empty_address_data.rs b/crates/brk_types/src/empty_addr_data.rs similarity index 85% rename from crates/brk_types/src/empty_address_data.rs rename to crates/brk_types/src/empty_addr_data.rs index 2da33adc7..04bc1abb5 100644 --- a/crates/brk_types/src/empty_address_data.rs +++ b/crates/brk_types/src/empty_addr_data.rs @@ -2,12 +2,12 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use vecdb::{Bytes, Formattable}; -use crate::{FundedAddressData, Sats}; +use crate::{FundedAddrData, Sats}; /// Data of an empty address #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)] #[repr(C)] -pub struct EmptyAddressData { +pub struct EmptyAddrData { /// Total transaction count pub tx_count: u32, /// Total funded/spent transaction output count (equal since address is empty) @@ -16,16 +16,16 @@ pub struct EmptyAddressData { pub transfered: Sats, } -impl From for EmptyAddressData { +impl From for EmptyAddrData { #[inline] - fn from(value: FundedAddressData) -> Self { + fn from(value: FundedAddrData) -> Self { Self::from(&value) } } -impl From<&FundedAddressData> for EmptyAddressData { +impl From<&FundedAddrData> for EmptyAddrData { #[inline] - fn from(value: &FundedAddressData) -> Self { + fn from(value: &FundedAddrData) -> Self { if value.sent != value.received { dbg!(&value); panic!("Trying to convert not empty wallet to empty !"); @@ -38,7 +38,7 @@ impl From<&FundedAddressData> for EmptyAddressData { } } -impl std::fmt::Display for EmptyAddressData { +impl std::fmt::Display for EmptyAddrData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, @@ -48,7 +48,7 @@ impl std::fmt::Display for EmptyAddressData { } } -impl Formattable for EmptyAddressData { +impl Formattable for EmptyAddrData { fn write_to(&self, buf: &mut Vec) { use std::fmt::Write; let mut s = String::new(); @@ -73,7 +73,7 @@ impl Formattable for EmptyAddressData { } } -impl Bytes for EmptyAddressData { +impl Bytes for EmptyAddrData { type Array = [u8; size_of::()]; fn to_bytes(&self) -> Self::Array { diff --git a/crates/brk_types/src/empty_address_index.rs b/crates/brk_types/src/empty_addr_index.rs similarity index 68% rename from crates/brk_types/src/empty_address_index.rs rename to crates/brk_types/src/empty_addr_index.rs index 3d194baab..ef3890621 100644 --- a/crates/brk_types/src/empty_address_index.rs +++ b/crates/brk_types/src/empty_addr_index.rs @@ -22,65 +22,65 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct EmptyAddressIndex(TypeIndex); +pub struct EmptyAddrIndex(TypeIndex); -impl From for EmptyAddressIndex { +impl From for EmptyAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for EmptyAddressIndex { +impl From for EmptyAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl From for EmptyAddressIndex { +impl From for EmptyAddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { +impl From for usize { #[inline] - fn from(value: EmptyAddressIndex) -> Self { + fn from(value: EmptyAddrIndex) -> Self { usize::from(value.0) } } -impl Add for EmptyAddressIndex { +impl Add for EmptyAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(self.0 + rhs) } } -impl CheckedSub for EmptyAddressIndex { +impl CheckedSub for EmptyAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for EmptyAddressIndex { +impl PrintableIndex for EmptyAddrIndex { fn to_string() -> &'static str { - "empty_address_index" + "empty_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["emptyaddr", "empty_address_index"] + &["emptyaddr", "empty_addr_index"] } } -impl std::fmt::Display for EmptyAddressIndex { +impl std::fmt::Display for EmptyAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for EmptyAddressIndex { +impl Formattable for EmptyAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/funded_address_data.rs b/crates/brk_types/src/funded_addr_data.rs similarity index 91% rename from crates/brk_types/src/funded_address_data.rs rename to crates/brk_types/src/funded_addr_data.rs index b45421ff9..6327e94f5 100644 --- a/crates/brk_types/src/funded_address_data.rs +++ b/crates/brk_types/src/funded_addr_data.rs @@ -3,7 +3,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use vecdb::{Bytes, Formattable}; -use crate::{Cents, CentsSats, CentsSquaredSats, EmptyAddressData, Sats, SupplyState}; +use crate::{Cents, CentsSats, CentsSquaredSats, EmptyAddrData, Sats, SupplyState}; /// Snapshot of cost basis related state. /// Uses CentsSats (u64) for single-UTXO values, CentsSquaredSats (u128) for investor cap. @@ -34,7 +34,7 @@ impl CostBasisSnapshot { /// Data for a funded (non-empty) address with current balance #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)] #[repr(C)] -pub struct FundedAddressData { +pub struct FundedAddrData { /// Total transaction count pub tx_count: u32, /// Number of transaction outputs funded to this address @@ -53,7 +53,7 @@ pub struct FundedAddressData { pub investor_cap_raw: CentsSquaredSats, } -impl FundedAddressData { +impl FundedAddrData { pub fn balance(&self) -> Sats { (u64::from(self.received) - u64::from(self.sent)).into() } @@ -87,8 +87,8 @@ impl FundedAddressData { .checked_sub(self.spent_txo_count) .unwrap_or_else(|| { panic!( - "FundedAddressData corruption: spent_txo_count ({}) > funded_txo_count ({}). \ - Address data: {:?}", + "FundedAddrData corruption: spent_txo_count ({}) > funded_txo_count ({}). \ + Addr data: {:?}", self.spent_txo_count, self.funded_txo_count, self ) }) @@ -129,16 +129,16 @@ impl FundedAddressData { } } -impl From for FundedAddressData { +impl From for FundedAddrData { #[inline] - fn from(value: EmptyAddressData) -> Self { + fn from(value: EmptyAddrData) -> Self { Self::from(&value) } } -impl From<&EmptyAddressData> for FundedAddressData { +impl From<&EmptyAddrData> for FundedAddrData { #[inline] - fn from(value: &EmptyAddressData) -> Self { + fn from(value: &EmptyAddrData) -> Self { Self { tx_count: value.tx_count, funded_txo_count: value.funded_txo_count, @@ -152,7 +152,7 @@ impl From<&EmptyAddressData> for FundedAddressData { } } -impl std::fmt::Display for FundedAddressData { +impl std::fmt::Display for FundedAddrData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, @@ -168,7 +168,7 @@ impl std::fmt::Display for FundedAddressData { } } -impl Formattable for FundedAddressData { +impl Formattable for FundedAddrData { fn write_to(&self, buf: &mut Vec) { use std::fmt::Write; let mut s = String::new(); @@ -193,7 +193,7 @@ impl Formattable for FundedAddressData { } } -impl Bytes for FundedAddressData { +impl Bytes for FundedAddrData { type Array = [u8; size_of::()]; fn to_bytes(&self) -> Self::Array { diff --git a/crates/brk_types/src/funded_address_index.rs b/crates/brk_types/src/funded_addr_index.rs similarity index 65% rename from crates/brk_types/src/funded_address_index.rs rename to crates/brk_types/src/funded_addr_index.rs index b9d0e6c7b..61d3665c0 100644 --- a/crates/brk_types/src/funded_address_index.rs +++ b/crates/brk_types/src/funded_addr_index.rs @@ -22,61 +22,61 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct FundedAddressIndex(TypeIndex); +pub struct FundedAddrIndex(TypeIndex); -impl From for FundedAddressIndex { +impl From for FundedAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for FundedAddressIndex { +impl From for FundedAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { +impl From for usize { #[inline] - fn from(value: FundedAddressIndex) -> Self { + fn from(value: FundedAddrIndex) -> Self { usize::from(value.0) } } -impl From for u32 { +impl From for u32 { #[inline] - fn from(value: FundedAddressIndex) -> Self { + fn from(value: FundedAddrIndex) -> Self { u32::from(value.0) } } -impl Add for FundedAddressIndex { +impl Add for FundedAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(self.0 + rhs) } } -impl CheckedSub for FundedAddressIndex { +impl CheckedSub for FundedAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for FundedAddressIndex { +impl PrintableIndex for FundedAddrIndex { fn to_string() -> &'static str { - "funded_address_index" + "funded_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["fundedaddr", "funded_address_index"] + &["fundedaddr", "funded_addr_index"] } } -impl std::fmt::Display for FundedAddressIndex { +impl std::fmt::Display for FundedAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for FundedAddressIndex { +impl Formattable for FundedAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/index.rs b/crates/brk_types/src/index.rs index d3739e563..305d2a43c 100644 --- a/crates/brk_types/src/index.rs +++ b/crates/brk_types/src/index.rs @@ -6,10 +6,10 @@ use serde::{Deserialize, Serialize}; use vecdb::PrintableIndex; use super::{ - Date, Day1, Day3, EmptyAddressIndex, EmptyOutputIndex, Epoch, FundedAddressIndex, Halving, + Date, Day1, Day3, EmptyAddrIndex, EmptyOutputIndex, Epoch, FundedAddrIndex, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6, OpReturnIndex, - P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, - P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, Timestamp, + P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, + P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, P2WSHAddrIndex, Timestamp, TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, Week1, Year1, Year10, hour1::HOUR1_INTERVAL, hour4::HOUR4_INTERVAL, hour12::HOUR12_INTERVAL, minute10::MINUTE10_INTERVAL, minute30::MINUTE30_INTERVAL, timestamp::INDEX_EPOCH, @@ -47,30 +47,30 @@ pub enum Index { EmptyOutputIndex, #[serde(rename = "op_return_index")] OpReturnIndex, - #[serde(rename = "p2a_address_index")] - P2AAddressIndex, + #[serde(rename = "p2a_addr_index")] + P2AAddrIndex, #[serde(rename = "p2ms_output_index")] P2MSOutputIndex, - #[serde(rename = "p2pk33_address_index")] - P2PK33AddressIndex, - #[serde(rename = "p2pk65_address_index")] - P2PK65AddressIndex, - #[serde(rename = "p2pkh_address_index")] - P2PKHAddressIndex, - #[serde(rename = "p2sh_address_index")] - P2SHAddressIndex, - #[serde(rename = "p2tr_address_index")] - P2TRAddressIndex, - #[serde(rename = "p2wpkh_address_index")] - P2WPKHAddressIndex, - #[serde(rename = "p2wsh_address_index")] - P2WSHAddressIndex, + #[serde(rename = "p2pk33_addr_index")] + P2PK33AddrIndex, + #[serde(rename = "p2pk65_addr_index")] + P2PK65AddrIndex, + #[serde(rename = "p2pkh_addr_index")] + P2PKHAddrIndex, + #[serde(rename = "p2sh_addr_index")] + P2SHAddrIndex, + #[serde(rename = "p2tr_addr_index")] + P2TRAddrIndex, + #[serde(rename = "p2wpkh_addr_index")] + P2WPKHAddrIndex, + #[serde(rename = "p2wsh_addr_index")] + P2WSHAddrIndex, #[serde(rename = "unknown_output_index")] UnknownOutputIndex, - #[serde(rename = "funded_address_index")] - FundedAddressIndex, - #[serde(rename = "empty_address_index")] - EmptyAddressIndex, + #[serde(rename = "funded_addr_index")] + FundedAddrIndex, + #[serde(rename = "empty_addr_index")] + EmptyAddrIndex, } impl Index { @@ -97,18 +97,18 @@ impl Index { Self::TxOutIndex, Self::EmptyOutputIndex, Self::OpReturnIndex, - Self::P2AAddressIndex, + Self::P2AAddrIndex, Self::P2MSOutputIndex, - Self::P2PK33AddressIndex, - Self::P2PK65AddressIndex, - Self::P2PKHAddressIndex, - Self::P2SHAddressIndex, - Self::P2TRAddressIndex, - Self::P2WPKHAddressIndex, - Self::P2WSHAddressIndex, + Self::P2PK33AddrIndex, + Self::P2PK65AddrIndex, + Self::P2PKHAddrIndex, + Self::P2SHAddrIndex, + Self::P2TRAddrIndex, + Self::P2WPKHAddrIndex, + Self::P2WSHAddrIndex, Self::UnknownOutputIndex, - Self::FundedAddressIndex, - Self::EmptyAddressIndex, + Self::FundedAddrIndex, + Self::EmptyAddrIndex, ] } @@ -135,18 +135,18 @@ impl Index { Self::TxOutIndex => TxOutIndex::to_possible_strings(), Self::EmptyOutputIndex => EmptyOutputIndex::to_possible_strings(), Self::OpReturnIndex => OpReturnIndex::to_possible_strings(), - Self::P2AAddressIndex => P2AAddressIndex::to_possible_strings(), + Self::P2AAddrIndex => P2AAddrIndex::to_possible_strings(), Self::P2MSOutputIndex => P2MSOutputIndex::to_possible_strings(), - Self::P2PK33AddressIndex => P2PK33AddressIndex::to_possible_strings(), - Self::P2PK65AddressIndex => P2PK65AddressIndex::to_possible_strings(), - Self::P2PKHAddressIndex => P2PKHAddressIndex::to_possible_strings(), - Self::P2SHAddressIndex => P2SHAddressIndex::to_possible_strings(), - Self::P2TRAddressIndex => P2TRAddressIndex::to_possible_strings(), - Self::P2WPKHAddressIndex => P2WPKHAddressIndex::to_possible_strings(), - Self::P2WSHAddressIndex => P2WSHAddressIndex::to_possible_strings(), + Self::P2PK33AddrIndex => P2PK33AddrIndex::to_possible_strings(), + Self::P2PK65AddrIndex => P2PK65AddrIndex::to_possible_strings(), + Self::P2PKHAddrIndex => P2PKHAddrIndex::to_possible_strings(), + Self::P2SHAddrIndex => P2SHAddrIndex::to_possible_strings(), + Self::P2TRAddrIndex => P2TRAddrIndex::to_possible_strings(), + Self::P2WPKHAddrIndex => P2WPKHAddrIndex::to_possible_strings(), + Self::P2WSHAddrIndex => P2WSHAddrIndex::to_possible_strings(), Self::UnknownOutputIndex => UnknownOutputIndex::to_possible_strings(), - Self::FundedAddressIndex => FundedAddressIndex::to_possible_strings(), - Self::EmptyAddressIndex => EmptyAddressIndex::to_possible_strings(), + Self::FundedAddrIndex => FundedAddrIndex::to_possible_strings(), + Self::EmptyAddrIndex => EmptyAddrIndex::to_possible_strings(), } } @@ -180,18 +180,18 @@ impl Index { Self::TxOutIndex => ::to_string(), Self::EmptyOutputIndex => ::to_string(), Self::OpReturnIndex => ::to_string(), - Self::P2AAddressIndex => ::to_string(), + Self::P2AAddrIndex => ::to_string(), Self::P2MSOutputIndex => ::to_string(), - Self::P2PK33AddressIndex => ::to_string(), - Self::P2PK65AddressIndex => ::to_string(), - Self::P2PKHAddressIndex => ::to_string(), - Self::P2SHAddressIndex => ::to_string(), - Self::P2TRAddressIndex => ::to_string(), - Self::P2WPKHAddressIndex => ::to_string(), - Self::P2WSHAddressIndex => ::to_string(), + Self::P2PK33AddrIndex => ::to_string(), + Self::P2PK65AddrIndex => ::to_string(), + Self::P2PKHAddrIndex => ::to_string(), + Self::P2SHAddrIndex => ::to_string(), + Self::P2TRAddrIndex => ::to_string(), + Self::P2WPKHAddrIndex => ::to_string(), + Self::P2WSHAddrIndex => ::to_string(), Self::UnknownOutputIndex => ::to_string(), - Self::FundedAddressIndex => ::to_string(), - Self::EmptyAddressIndex => ::to_string(), + Self::FundedAddrIndex => ::to_string(), + Self::EmptyAddrIndex => ::to_string(), } } diff --git a/crates/brk_types/src/indexes.rs b/crates/brk_types/src/indexes.rs index fa517672e..ce3c9ca3e 100644 --- a/crates/brk_types/src/indexes.rs +++ b/crates/brk_types/src/indexes.rs @@ -1,7 +1,7 @@ use crate::{ - EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddressIndex, P2MSOutputIndex, - P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, - P2WPKHAddressIndex, P2WSHAddressIndex, TxInIndex, TxIndex, TxOutIndex, TypeIndex, + EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddrIndex, P2MSOutputIndex, + P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, + P2WPKHAddrIndex, P2WSHAddrIndex, TxInIndex, TxIndex, TxOutIndex, TypeIndex, UnknownOutputIndex, }; @@ -13,14 +13,14 @@ pub struct Indexes { pub height: Height, pub op_return_index: OpReturnIndex, pub p2ms_output_index: P2MSOutputIndex, - pub p2pk33_address_index: P2PK33AddressIndex, - pub p2pk65_address_index: P2PK65AddressIndex, - pub p2pkh_address_index: P2PKHAddressIndex, - pub p2sh_address_index: P2SHAddressIndex, - pub p2tr_address_index: P2TRAddressIndex, - pub p2wpkh_address_index: P2WPKHAddressIndex, - pub p2wsh_address_index: P2WSHAddressIndex, - pub p2a_address_index: P2AAddressIndex, + pub p2pk33_addr_index: P2PK33AddrIndex, + pub p2pk65_addr_index: P2PK65AddrIndex, + pub p2pkh_addr_index: P2PKHAddrIndex, + pub p2sh_addr_index: P2SHAddrIndex, + pub p2tr_addr_index: P2TRAddrIndex, + pub p2wpkh_addr_index: P2WPKHAddrIndex, + pub p2wsh_addr_index: P2WSHAddrIndex, + pub p2a_addr_index: P2AAddrIndex, pub tx_index: TxIndex, pub txin_index: TxInIndex, pub txout_index: TxOutIndex, @@ -32,15 +32,15 @@ impl Indexes { match output_type { OutputType::Empty => *self.empty_output_index, OutputType::OpReturn => *self.op_return_index, - OutputType::P2A => *self.p2a_address_index, + OutputType::P2A => *self.p2a_addr_index, OutputType::P2MS => *self.p2ms_output_index, - OutputType::P2PK33 => *self.p2pk33_address_index, - OutputType::P2PK65 => *self.p2pk65_address_index, - OutputType::P2PKH => *self.p2pkh_address_index, - OutputType::P2SH => *self.p2sh_address_index, - OutputType::P2TR => *self.p2tr_address_index, - OutputType::P2WPKH => *self.p2wpkh_address_index, - OutputType::P2WSH => *self.p2wsh_address_index, + OutputType::P2PK33 => *self.p2pk33_addr_index, + OutputType::P2PK65 => *self.p2pk65_addr_index, + OutputType::P2PKH => *self.p2pkh_addr_index, + OutputType::P2SH => *self.p2sh_addr_index, + OutputType::P2TR => *self.p2tr_addr_index, + OutputType::P2WPKH => *self.p2wpkh_addr_index, + OutputType::P2WSH => *self.p2wsh_addr_index, OutputType::Unknown => *self.unknown_output_index, } } @@ -48,16 +48,16 @@ impl Indexes { /// Increments the address index for the given address type and returns the previous value. /// Only call this for address types (P2PK65, P2PK33, P2PKH, P2SH, P2WPKH, P2WSH, P2TR, P2A). #[inline] - pub fn increment_address_index(&mut self, address_type: OutputType) -> TypeIndex { - match address_type { - OutputType::P2PK65 => self.p2pk65_address_index.copy_then_increment(), - OutputType::P2PK33 => self.p2pk33_address_index.copy_then_increment(), - OutputType::P2PKH => self.p2pkh_address_index.copy_then_increment(), - OutputType::P2SH => self.p2sh_address_index.copy_then_increment(), - OutputType::P2WPKH => self.p2wpkh_address_index.copy_then_increment(), - OutputType::P2WSH => self.p2wsh_address_index.copy_then_increment(), - OutputType::P2TR => self.p2tr_address_index.copy_then_increment(), - OutputType::P2A => self.p2a_address_index.copy_then_increment(), + pub fn increment_addr_index(&mut self, addr_type: OutputType) -> TypeIndex { + match addr_type { + OutputType::P2PK65 => self.p2pk65_addr_index.copy_then_increment(), + OutputType::P2PK33 => self.p2pk33_addr_index.copy_then_increment(), + OutputType::P2PKH => self.p2pkh_addr_index.copy_then_increment(), + OutputType::P2SH => self.p2sh_addr_index.copy_then_increment(), + OutputType::P2WPKH => self.p2wpkh_addr_index.copy_then_increment(), + OutputType::P2WSH => self.p2wsh_addr_index.copy_then_increment(), + OutputType::P2TR => self.p2tr_addr_index.copy_then_increment(), + OutputType::P2A => self.p2a_addr_index.copy_then_increment(), _ => unreachable!(), } } diff --git a/crates/brk_types/src/lib.rs b/crates/brk_types/src/lib.rs index 297f6af7f..9dddaca53 100644 --- a/crates/brk_types/src/lib.rs +++ b/crates/brk_types/src/lib.rs @@ -2,19 +2,19 @@ pub use vecdb::{CheckedSub, Exit, PrintableIndex, Version}; -mod address; -mod address_bytes; -mod address_chain_stats; -mod address_hash; -mod address_index_outpoint; -mod address_index_tx_index; -mod address_mempool_stats; -mod address_param; -mod address_stats; -mod address_txids_param; -mod address_validation; +mod addr; +mod addr_bytes; +mod addr_chain_stats; +mod addr_hash; +mod addr_index_any; +mod addr_index_outpoint; +mod addr_index_tx_index; +mod addr_mempool_stats; +mod addr_param; +mod addr_stats; +mod addr_txids_param; +mod addr_validation; mod age; -mod any_address_index; mod basis_points_16; mod basis_points_32; mod basis_points_signed_16; @@ -59,8 +59,8 @@ mod difficulty_adjustment_entry; mod difficulty_entry; mod disk_usage; mod dollars; -mod empty_address_data; -mod empty_address_index; +mod empty_addr_data; +mod empty_addr_index; mod empty_output_index; mod epoch; mod etag; @@ -69,8 +69,8 @@ mod feerate_percentiles; mod format; mod format_response; mod from_coarser; -mod funded_address_data; -mod funded_address_index; +mod funded_addr_data; +mod funded_addr_index; mod halving; mod hashrate_entry; mod hashrate_summary; @@ -101,22 +101,22 @@ mod oracle_bins; mod outpoint; mod output; mod output_type; -mod p2a_address_index; +mod p2a_addr_index; mod p2a_bytes; mod p2ms_output_index; -mod p2pk33_address_index; +mod p2pk33_addr_index; mod p2pk33_bytes; -mod p2pk65_address_index; +mod p2pk65_addr_index; mod p2pk65_bytes; -mod p2pkh_address_index; +mod p2pkh_addr_index; mod p2pkh_bytes; -mod p2sh_address_index; +mod p2sh_addr_index; mod p2sh_bytes; -mod p2tr_address_index; +mod p2tr_addr_index; mod p2tr_bytes; -mod p2wpkh_address_index; +mod p2wpkh_addr_index; mod p2wpkh_bytes; -mod p2wsh_address_index; +mod p2wsh_addr_index; mod p2wsh_bytes; mod pagination; mod pagination_index; @@ -187,7 +187,7 @@ mod type_index; mod unit; mod unknown_output_index; mod utxo; -mod validate_address_param; +mod validate_addr_param; mod vin; mod vout; mod vsize; @@ -197,19 +197,19 @@ mod year; mod year1; mod year10; -pub use address::*; -pub use address_bytes::*; -pub use address_chain_stats::*; -pub use address_hash::*; -pub use address_index_outpoint::*; -pub use address_index_tx_index::*; -pub use address_mempool_stats::*; -pub use address_param::*; -pub use address_stats::*; -pub use address_txids_param::*; -pub use address_validation::*; +pub use addr::*; +pub use addr_bytes::*; +pub use addr_chain_stats::*; +pub use addr_hash::*; +pub use addr_index_any::*; +pub use addr_index_outpoint::*; +pub use addr_index_tx_index::*; +pub use addr_mempool_stats::*; +pub use addr_param::*; +pub use addr_stats::*; +pub use addr_txids_param::*; +pub use addr_validation::*; pub use age::*; -pub use any_address_index::*; pub use basis_points_16::*; pub use basis_points_32::*; pub use basis_points_signed_16::*; @@ -254,8 +254,8 @@ pub use difficulty_adjustment_entry::*; pub use difficulty_entry::*; pub use disk_usage::*; pub use dollars::*; -pub use empty_address_data::*; -pub use empty_address_index::*; +pub use empty_addr_data::*; +pub use empty_addr_index::*; pub use empty_output_index::*; pub use epoch::*; pub use etag::*; @@ -264,8 +264,8 @@ pub use feerate_percentiles::*; pub use format::*; pub use format_response::*; pub use from_coarser::*; -pub use funded_address_data::*; -pub use funded_address_index::*; +pub use funded_addr_data::*; +pub use funded_addr_index::*; pub use halving::*; pub use hashrate_entry::*; pub use hashrate_summary::*; @@ -296,22 +296,22 @@ pub use oracle_bins::*; pub use outpoint::*; pub use output::*; pub use output_type::*; -pub use p2a_address_index::*; +pub use p2a_addr_index::*; pub use p2a_bytes::*; pub use p2ms_output_index::*; -pub use p2pk33_address_index::*; +pub use p2pk33_addr_index::*; pub use p2pk33_bytes::*; -pub use p2pk65_address_index::*; +pub use p2pk65_addr_index::*; pub use p2pk65_bytes::*; -pub use p2pkh_address_index::*; +pub use p2pkh_addr_index::*; pub use p2pkh_bytes::*; -pub use p2sh_address_index::*; +pub use p2sh_addr_index::*; pub use p2sh_bytes::*; -pub use p2tr_address_index::*; +pub use p2tr_addr_index::*; pub use p2tr_bytes::*; -pub use p2wpkh_address_index::*; +pub use p2wpkh_addr_index::*; pub use p2wpkh_bytes::*; -pub use p2wsh_address_index::*; +pub use p2wsh_addr_index::*; pub use p2wsh_bytes::*; pub use pagination::*; pub use pagination_index::*; @@ -382,7 +382,7 @@ pub use type_index::*; pub use unit::*; pub use unknown_output_index::*; pub use utxo::*; -pub use validate_address_param::*; +pub use validate_addr_param::*; pub use vin::*; pub use vout::*; pub use vsize::*; diff --git a/crates/brk_types/src/output_type.rs b/crates/brk_types/src/output_type.rs index 77a89b4b0..b55e4ed0a 100644 --- a/crates/brk_types/src/output_type.rs +++ b/crates/brk_types/src/output_type.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use strum::Display; use vecdb::{Bytes, Formattable, Pco, TransparentPco}; -use crate::AddressBytes; +use crate::AddrBytes; #[derive( Debug, @@ -41,7 +41,7 @@ pub enum OutputType { } impl OutputType { - pub const ADDRESS_TYPES: [Self; 8] = [ + pub const ADDR_TYPES: [Self; 8] = [ Self::P2PK65, Self::P2PK33, Self::P2PKH, @@ -73,7 +73,7 @@ impl OutputType { } } - pub fn is_address(&self) -> bool { + pub fn is_addr(&self) -> bool { match self { Self::P2PK65 => true, Self::P2PK33 => true, @@ -90,8 +90,8 @@ impl OutputType { } } - pub fn is_not_address(&self) -> bool { - !self.is_address() + pub fn is_not_addr(&self) -> bool { + !self.is_addr() } pub fn is_unspendable(&self) -> bool { @@ -173,18 +173,18 @@ impl From for OutputType { } } -impl From<&AddressBytes> for OutputType { +impl From<&AddrBytes> for OutputType { #[inline] - fn from(bytes: &AddressBytes) -> Self { + fn from(bytes: &AddrBytes) -> Self { match bytes { - AddressBytes::P2PK65(_) => Self::P2PK65, - AddressBytes::P2PK33(_) => Self::P2PK33, - AddressBytes::P2PKH(_) => Self::P2PKH, - AddressBytes::P2SH(_) => Self::P2SH, - AddressBytes::P2WPKH(_) => Self::P2WPKH, - AddressBytes::P2WSH(_) => Self::P2WSH, - AddressBytes::P2TR(_) => Self::P2TR, - AddressBytes::P2A(_) => Self::P2A, + AddrBytes::P2PK65(_) => Self::P2PK65, + AddrBytes::P2PK33(_) => Self::P2PK33, + AddrBytes::P2PKH(_) => Self::P2PKH, + AddrBytes::P2SH(_) => Self::P2SH, + AddrBytes::P2WPKH(_) => Self::P2WPKH, + AddrBytes::P2WSH(_) => Self::P2WSH, + AddrBytes::P2TR(_) => Self::P2TR, + AddrBytes::P2A(_) => Self::P2A, } } } diff --git a/crates/brk_types/src/p2a_address_index.rs b/crates/brk_types/src/p2a_addr_index.rs similarity index 63% rename from crates/brk_types/src/p2a_address_index.rs rename to crates/brk_types/src/p2a_addr_index.rs index 968dbed24..699774c77 100644 --- a/crates/brk_types/src/p2a_address_index.rs +++ b/crates/brk_types/src/p2a_addr_index.rs @@ -23,87 +23,87 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct P2AAddressIndex(TypeIndex); +pub struct P2AAddrIndex(TypeIndex); -impl From for P2AAddressIndex { +impl From for P2AAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for TypeIndex { +impl From for TypeIndex { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { value.0 } } -impl From for u32 { +impl From for u32 { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(*value) } } -impl From for u64 { +impl From for u64 { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(*value) } } -impl From for P2AAddressIndex { +impl From for P2AAddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { +impl From for usize { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(*value) } } -impl From for P2AAddressIndex { +impl From for P2AAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl Add for P2AAddressIndex { +impl Add for P2AAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } -impl CheckedSub for P2AAddressIndex { +impl CheckedSub for P2AAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for P2AAddressIndex { +impl PrintableIndex for P2AAddrIndex { fn to_string() -> &'static str { - "p2a_address_index" + "p2a_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["aaddr", "p2aaddr", "p2a_address_index"] + &["aaddr", "p2aaddr", "p2a_addr_index"] } } -impl std::fmt::Display for P2AAddressIndex { +impl std::fmt::Display for P2AAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for P2AAddressIndex { +impl Formattable for P2AAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/p2tr_address_index.rs b/crates/brk_types/src/p2pk33_addr_index.rs similarity index 62% rename from crates/brk_types/src/p2tr_address_index.rs rename to crates/brk_types/src/p2pk33_addr_index.rs index a29788189..b2eb6b949 100644 --- a/crates/brk_types/src/p2tr_address_index.rs +++ b/crates/brk_types/src/p2pk33_addr_index.rs @@ -23,87 +23,87 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct P2TRAddressIndex(TypeIndex); +pub struct P2PK33AddrIndex(TypeIndex); -impl From for P2TRAddressIndex { +impl From for P2PK33AddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for TypeIndex { +impl From for TypeIndex { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { value.0 } } -impl From for u32 { +impl From for u32 { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(*value) } } -impl From for u64 { +impl From for u64 { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(*value) } } -impl From for P2TRAddressIndex { +impl From for P2PK33AddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { +impl From for usize { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(*value) } } -impl From for P2TRAddressIndex { +impl From for P2PK33AddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl Add for P2TRAddressIndex { +impl Add for P2PK33AddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } -impl CheckedSub for P2TRAddressIndex { +impl CheckedSub for P2PK33AddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for P2TRAddressIndex { +impl PrintableIndex for P2PK33AddrIndex { fn to_string() -> &'static str { - "p2tr_address_index" + "p2pk33_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["traddr", "p2traddr", "p2tr_address_index"] + &["pk33addr", "p2pk33addr", "p2pk33_addr_index"] } } -impl std::fmt::Display for P2TRAddressIndex { +impl std::fmt::Display for P2PK33AddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for P2TRAddressIndex { +impl Formattable for P2PK33AddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/p2pk33_address_index.rs b/crates/brk_types/src/p2pk33_address_index.rs deleted file mode 100644 index e13e3045e..000000000 --- a/crates/brk_types/src/p2pk33_address_index.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::ops::Add; - -use derive_more::{Deref, DerefMut}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; - -use crate::TypeIndex; - -#[derive( - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Clone, - Copy, - Deref, - DerefMut, - Default, - Serialize, - Deserialize, - Pco, - JsonSchema, -)] -pub struct P2PK33AddressIndex(TypeIndex); - -impl From for P2PK33AddressIndex { - #[inline] - fn from(value: TypeIndex) -> Self { - Self(value) - } -} - -impl From for TypeIndex { - #[inline] - fn from(value: P2PK33AddressIndex) -> Self { - value.0 - } -} - -impl From for u32 { - #[inline] - fn from(value: P2PK33AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for u64 { - #[inline] - fn from(value: P2PK33AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2PK33AddressIndex { - #[inline] - fn from(value: u32) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl From for usize { - #[inline] - fn from(value: P2PK33AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2PK33AddressIndex { - #[inline] - fn from(value: usize) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl Add for P2PK33AddressIndex { - type Output = Self; - fn add(self, rhs: usize) -> Self::Output { - Self(*self + rhs) - } -} - -impl CheckedSub for P2PK33AddressIndex { - fn checked_sub(self, rhs: Self) -> Option { - self.0.checked_sub(rhs.0).map(Self) - } -} - -impl PrintableIndex for P2PK33AddressIndex { - fn to_string() -> &'static str { - "p2pk33_address_index" - } - - fn to_possible_strings() -> &'static [&'static str] { - &["pk33addr", "p2pk33addr", "p2pk33_address_index"] - } -} - -impl std::fmt::Display for P2PK33AddressIndex { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} - -impl Formattable for P2PK33AddressIndex { - #[inline(always)] - fn write_to(&self, buf: &mut Vec) { - self.0.write_to(buf); - } -} diff --git a/crates/brk_types/src/p2pk65_addr_index.rs b/crates/brk_types/src/p2pk65_addr_index.rs new file mode 100644 index 000000000..7a1d52dac --- /dev/null +++ b/crates/brk_types/src/p2pk65_addr_index.rs @@ -0,0 +1,110 @@ +use std::ops::Add; + +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; + +use crate::TypeIndex; + +#[derive( + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Copy, + Deref, + DerefMut, + Default, + Serialize, + Deserialize, + Pco, + JsonSchema, +)] +pub struct P2PK65AddrIndex(TypeIndex); + +impl From for P2PK65AddrIndex { + #[inline] + fn from(value: TypeIndex) -> Self { + Self(value) + } +} + +impl From for TypeIndex { + #[inline] + fn from(value: P2PK65AddrIndex) -> Self { + value.0 + } +} + +impl From for u32 { + #[inline] + fn from(value: P2PK65AddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for u64 { + #[inline] + fn from(value: P2PK65AddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for usize { + #[inline] + fn from(value: P2PK65AddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2PK65AddrIndex { + #[inline] + fn from(value: u32) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl From for P2PK65AddrIndex { + #[inline] + fn from(value: usize) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl Add for P2PK65AddrIndex { + type Output = Self; + fn add(self, rhs: usize) -> Self::Output { + Self(*self + rhs) + } +} + +impl CheckedSub for P2PK65AddrIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + +impl PrintableIndex for P2PK65AddrIndex { + fn to_string() -> &'static str { + "p2pk65_addr_index" + } + fn to_possible_strings() -> &'static [&'static str] { + &["pk65addr", "p2pk65addr", "p2pk65_addr_index"] + } +} + +impl std::fmt::Display for P2PK65AddrIndex { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + +impl Formattable for P2PK65AddrIndex { + #[inline(always)] + fn write_to(&self, buf: &mut Vec) { + self.0.write_to(buf); + } +} diff --git a/crates/brk_types/src/p2pk65_address_index.rs b/crates/brk_types/src/p2pk65_address_index.rs deleted file mode 100644 index bcf74c49d..000000000 --- a/crates/brk_types/src/p2pk65_address_index.rs +++ /dev/null @@ -1,110 +0,0 @@ -use std::ops::Add; - -use derive_more::{Deref, DerefMut}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; - -use crate::TypeIndex; - -#[derive( - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Clone, - Copy, - Deref, - DerefMut, - Default, - Serialize, - Deserialize, - Pco, - JsonSchema, -)] -pub struct P2PK65AddressIndex(TypeIndex); - -impl From for P2PK65AddressIndex { - #[inline] - fn from(value: TypeIndex) -> Self { - Self(value) - } -} - -impl From for TypeIndex { - #[inline] - fn from(value: P2PK65AddressIndex) -> Self { - value.0 - } -} - -impl From for u32 { - #[inline] - fn from(value: P2PK65AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for u64 { - #[inline] - fn from(value: P2PK65AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for usize { - #[inline] - fn from(value: P2PK65AddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2PK65AddressIndex { - #[inline] - fn from(value: u32) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl From for P2PK65AddressIndex { - #[inline] - fn from(value: usize) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl Add for P2PK65AddressIndex { - type Output = Self; - fn add(self, rhs: usize) -> Self::Output { - Self(*self + rhs) - } -} - -impl CheckedSub for P2PK65AddressIndex { - fn checked_sub(self, rhs: Self) -> Option { - self.0.checked_sub(rhs.0).map(Self) - } -} - -impl PrintableIndex for P2PK65AddressIndex { - fn to_string() -> &'static str { - "p2pk65_address_index" - } - fn to_possible_strings() -> &'static [&'static str] { - &["pk65addr", "p2pk65addr", "p2pk65_address_index"] - } -} - -impl std::fmt::Display for P2PK65AddressIndex { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} - -impl Formattable for P2PK65AddressIndex { - #[inline(always)] - fn write_to(&self, buf: &mut Vec) { - self.0.write_to(buf); - } -} diff --git a/crates/brk_types/src/p2wsh_address_index.rs b/crates/brk_types/src/p2pkh_addr_index.rs similarity index 62% rename from crates/brk_types/src/p2wsh_address_index.rs rename to crates/brk_types/src/p2pkh_addr_index.rs index 3ec026b09..3c89ff22a 100644 --- a/crates/brk_types/src/p2wsh_address_index.rs +++ b/crates/brk_types/src/p2pkh_addr_index.rs @@ -23,87 +23,87 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct P2WSHAddressIndex(TypeIndex); +pub struct P2PKHAddrIndex(TypeIndex); -impl From for P2WSHAddressIndex { +impl From for P2PKHAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for TypeIndex { +impl From for TypeIndex { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { value.0 } } -impl From for u32 { +impl From for usize { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { Self::from(*value) } } -impl From for u64 { +impl From for u64 { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { Self::from(*value) } } -impl From for P2WSHAddressIndex { +impl From for u32 { + #[inline] + fn from(value: P2PKHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2PKHAddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { - #[inline] - fn from(value: P2WSHAddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2WSHAddressIndex { +impl From for P2PKHAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl Add for P2WSHAddressIndex { +impl Add for P2PKHAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } -impl CheckedSub for P2WSHAddressIndex { +impl CheckedSub for P2PKHAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for P2WSHAddressIndex { +impl PrintableIndex for P2PKHAddrIndex { fn to_string() -> &'static str { - "p2wsh_address_index" + "p2pkh_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["wshaddr", "p2wshaddr", "p2wsh_address_index"] + &["pkhaddr", "p2pkhaddr", "p2pkh_addr_index"] } } -impl std::fmt::Display for P2WSHAddressIndex { +impl std::fmt::Display for P2PKHAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for P2WSHAddressIndex { +impl Formattable for P2PKHAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/p2sh_address_index.rs b/crates/brk_types/src/p2sh_addr_index.rs similarity index 63% rename from crates/brk_types/src/p2sh_address_index.rs rename to crates/brk_types/src/p2sh_addr_index.rs index 41730d526..d8fd0567b 100644 --- a/crates/brk_types/src/p2sh_address_index.rs +++ b/crates/brk_types/src/p2sh_addr_index.rs @@ -23,94 +23,94 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct P2SHAddressIndex(TypeIndex); +pub struct P2SHAddrIndex(TypeIndex); -impl From for P2SHAddressIndex { +impl From for P2SHAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for TypeIndex { +impl From for TypeIndex { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { value.0 } } -impl From for u32 { +impl From for u32 { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(*value) } } -impl From for u64 { +impl From for u64 { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(*value) } } -impl From for P2SHAddressIndex { +impl From for P2SHAddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for P2SHAddressIndex { +impl From for P2SHAddrIndex { #[inline] fn from(value: u64) -> Self { Self(TypeIndex::from(value)) } } -impl From for usize { +impl From for usize { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(*value) } } -impl From for P2SHAddressIndex { +impl From for P2SHAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl Add for P2SHAddressIndex { +impl Add for P2SHAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } -impl CheckedSub for P2SHAddressIndex { +impl CheckedSub for P2SHAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for P2SHAddressIndex { +impl PrintableIndex for P2SHAddrIndex { fn to_string() -> &'static str { - "p2sh_address_index" + "p2sh_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["shaddr", "p2shaddr", "p2sh_address_index"] + &["shaddr", "p2shaddr", "p2sh_addr_index"] } } -impl std::fmt::Display for P2SHAddressIndex { +impl std::fmt::Display for P2SHAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for P2SHAddressIndex { +impl Formattable for P2SHAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/p2pkh_address_index.rs b/crates/brk_types/src/p2tr_addr_index.rs similarity index 62% rename from crates/brk_types/src/p2pkh_address_index.rs rename to crates/brk_types/src/p2tr_addr_index.rs index 3ad300ac9..4f4c91d5a 100644 --- a/crates/brk_types/src/p2pkh_address_index.rs +++ b/crates/brk_types/src/p2tr_addr_index.rs @@ -23,87 +23,87 @@ use crate::TypeIndex; Pco, JsonSchema, )] -pub struct P2PKHAddressIndex(TypeIndex); +pub struct P2TRAddrIndex(TypeIndex); -impl From for P2PKHAddressIndex { +impl From for P2TRAddrIndex { #[inline] fn from(value: TypeIndex) -> Self { Self(value) } } -impl From for TypeIndex { +impl From for TypeIndex { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { value.0 } } -impl From for usize { +impl From for u32 { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { Self::from(*value) } } -impl From for u64 { +impl From for u64 { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { Self::from(*value) } } -impl From for u32 { - #[inline] - fn from(value: P2PKHAddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2PKHAddressIndex { +impl From for P2TRAddrIndex { #[inline] fn from(value: u32) -> Self { Self(TypeIndex::from(value)) } } -impl From for P2PKHAddressIndex { +impl From for usize { + #[inline] + fn from(value: P2TRAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2TRAddrIndex { #[inline] fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } -impl Add for P2PKHAddressIndex { +impl Add for P2TRAddrIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } -impl CheckedSub for P2PKHAddressIndex { +impl CheckedSub for P2TRAddrIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } -impl PrintableIndex for P2PKHAddressIndex { +impl PrintableIndex for P2TRAddrIndex { fn to_string() -> &'static str { - "p2pkh_address_index" + "p2tr_addr_index" } fn to_possible_strings() -> &'static [&'static str] { - &["pkhaddr", "p2pkhaddr", "p2pkh_address_index"] + &["traddr", "p2traddr", "p2tr_addr_index"] } } -impl std::fmt::Display for P2PKHAddressIndex { +impl std::fmt::Display for P2TRAddrIndex { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -impl Formattable for P2PKHAddressIndex { +impl Formattable for P2TRAddrIndex { #[inline(always)] fn write_to(&self, buf: &mut Vec) { self.0.write_to(buf); diff --git a/crates/brk_types/src/p2wpkh_addr_index.rs b/crates/brk_types/src/p2wpkh_addr_index.rs new file mode 100644 index 000000000..c7b9bbe61 --- /dev/null +++ b/crates/brk_types/src/p2wpkh_addr_index.rs @@ -0,0 +1,111 @@ +use std::ops::Add; + +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; + +use crate::TypeIndex; + +#[derive( + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Copy, + Deref, + DerefMut, + Default, + Serialize, + Deserialize, + Pco, + JsonSchema, +)] +pub struct P2WPKHAddrIndex(TypeIndex); + +impl From for P2WPKHAddrIndex { + #[inline] + fn from(value: TypeIndex) -> Self { + Self(value) + } +} + +impl From for TypeIndex { + #[inline] + fn from(value: P2WPKHAddrIndex) -> Self { + value.0 + } +} + +impl From for u32 { + #[inline] + fn from(value: P2WPKHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for u64 { + #[inline] + fn from(value: P2WPKHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for usize { + #[inline] + fn from(value: P2WPKHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2WPKHAddrIndex { + #[inline] + fn from(value: u32) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl From for P2WPKHAddrIndex { + #[inline] + fn from(value: usize) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl Add for P2WPKHAddrIndex { + type Output = Self; + fn add(self, rhs: usize) -> Self::Output { + Self(*self + rhs) + } +} + +impl CheckedSub for P2WPKHAddrIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + +impl PrintableIndex for P2WPKHAddrIndex { + fn to_string() -> &'static str { + "p2wpkh_addr_index" + } + + fn to_possible_strings() -> &'static [&'static str] { + &["wpkhaddr", "p2wpkhaddr", "p2wpkh_addr_index"] + } +} + +impl std::fmt::Display for P2WPKHAddrIndex { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + +impl Formattable for P2WPKHAddrIndex { + #[inline(always)] + fn write_to(&self, buf: &mut Vec) { + self.0.write_to(buf); + } +} diff --git a/crates/brk_types/src/p2wpkh_address_index.rs b/crates/brk_types/src/p2wpkh_address_index.rs deleted file mode 100644 index 7a2fde7e6..000000000 --- a/crates/brk_types/src/p2wpkh_address_index.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::ops::Add; - -use derive_more::{Deref, DerefMut}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; - -use crate::TypeIndex; - -#[derive( - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Clone, - Copy, - Deref, - DerefMut, - Default, - Serialize, - Deserialize, - Pco, - JsonSchema, -)] -pub struct P2WPKHAddressIndex(TypeIndex); - -impl From for P2WPKHAddressIndex { - #[inline] - fn from(value: TypeIndex) -> Self { - Self(value) - } -} - -impl From for TypeIndex { - #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { - value.0 - } -} - -impl From for u32 { - #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for u64 { - #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for usize { - #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { - Self::from(*value) - } -} - -impl From for P2WPKHAddressIndex { - #[inline] - fn from(value: u32) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl From for P2WPKHAddressIndex { - #[inline] - fn from(value: usize) -> Self { - Self(TypeIndex::from(value)) - } -} - -impl Add for P2WPKHAddressIndex { - type Output = Self; - fn add(self, rhs: usize) -> Self::Output { - Self(*self + rhs) - } -} - -impl CheckedSub for P2WPKHAddressIndex { - fn checked_sub(self, rhs: Self) -> Option { - self.0.checked_sub(rhs.0).map(Self) - } -} - -impl PrintableIndex for P2WPKHAddressIndex { - fn to_string() -> &'static str { - "p2wpkh_address_index" - } - - fn to_possible_strings() -> &'static [&'static str] { - &["wpkhaddr", "p2wpkhaddr", "p2wpkh_address_index"] - } -} - -impl std::fmt::Display for P2WPKHAddressIndex { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} - -impl Formattable for P2WPKHAddressIndex { - #[inline(always)] - fn write_to(&self, buf: &mut Vec) { - self.0.write_to(buf); - } -} diff --git a/crates/brk_types/src/p2wsh_addr_index.rs b/crates/brk_types/src/p2wsh_addr_index.rs new file mode 100644 index 000000000..8979766d5 --- /dev/null +++ b/crates/brk_types/src/p2wsh_addr_index.rs @@ -0,0 +1,111 @@ +use std::ops::Add; + +use derive_more::{Deref, DerefMut}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; + +use crate::TypeIndex; + +#[derive( + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Clone, + Copy, + Deref, + DerefMut, + Default, + Serialize, + Deserialize, + Pco, + JsonSchema, +)] +pub struct P2WSHAddrIndex(TypeIndex); + +impl From for P2WSHAddrIndex { + #[inline] + fn from(value: TypeIndex) -> Self { + Self(value) + } +} + +impl From for TypeIndex { + #[inline] + fn from(value: P2WSHAddrIndex) -> Self { + value.0 + } +} + +impl From for u32 { + #[inline] + fn from(value: P2WSHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for u64 { + #[inline] + fn from(value: P2WSHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2WSHAddrIndex { + #[inline] + fn from(value: u32) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl From for usize { + #[inline] + fn from(value: P2WSHAddrIndex) -> Self { + Self::from(*value) + } +} + +impl From for P2WSHAddrIndex { + #[inline] + fn from(value: usize) -> Self { + Self(TypeIndex::from(value)) + } +} + +impl Add for P2WSHAddrIndex { + type Output = Self; + fn add(self, rhs: usize) -> Self::Output { + Self(*self + rhs) + } +} + +impl CheckedSub for P2WSHAddrIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + +impl PrintableIndex for P2WSHAddrIndex { + fn to_string() -> &'static str { + "p2wsh_addr_index" + } + + fn to_possible_strings() -> &'static [&'static str] { + &["wshaddr", "p2wshaddr", "p2wsh_addr_index"] + } +} + +impl std::fmt::Display for P2WSHAddrIndex { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + +impl Formattable for P2WSHAddrIndex { + #[inline(always)] + fn write_to(&self, buf: &mut Vec) { + self.0.write_to(buf); + } +} diff --git a/crates/brk_types/src/pool.rs b/crates/brk_types/src/pool.rs index 4b2bbce77..7d96b3ca4 100644 --- a/crates/brk_types/src/pool.rs +++ b/crates/brk_types/src/pool.rs @@ -14,7 +14,7 @@ pub struct Pool { /// Known payout addresses for pool identification #[serde(skip)] - pub addresses: Box<[&'static str]>, + pub addrs: Box<[&'static str]>, /// Coinbase tags used to identify blocks mined by this pool #[serde(skip)] diff --git a/crates/brk_types/src/pool_detail.rs b/crates/brk_types/src/pool_detail.rs index 1df124153..185914a81 100644 --- a/crates/brk_types/src/pool_detail.rs +++ b/crates/brk_types/src/pool_detail.rs @@ -41,7 +41,7 @@ pub struct PoolDetailInfo { pub link: Cow<'static, str>, /// Known payout addresses - pub addresses: Vec>, + pub addrs: Vec>, /// Coinbase tag patterns (regexes) pub regexes: Vec>, @@ -56,7 +56,7 @@ impl From<&'static Pool> for PoolDetailInfo { id: pool.unique_id(), name: Cow::Borrowed(pool.name), link: Cow::Borrowed(pool.link), - addresses: pool.addresses.iter().map(|&s| Cow::Borrowed(s)).collect(), + addrs: pool.addrs.iter().map(|&s| Cow::Borrowed(s)).collect(), regexes: pool.tags.iter().map(|&s| Cow::Borrowed(s)).collect(), slug: pool.slug(), } diff --git a/crates/brk_types/src/pools.rs b/crates/brk_types/src/pools.rs index 23f7acb58..37e9846b3 100644 --- a/crates/brk_types/src/pools.rs +++ b/crates/brk_types/src/pools.rs @@ -14,7 +14,8 @@ const TESTNET_IDS: &[u16] = &[145, 146, 149, 150, 156, 163]; struct JsonPoolEntry { id: u16, name: String, - addresses: Vec, + #[serde(rename = "addresses")] + addrs: Vec, tags: Vec, link: String, } @@ -27,7 +28,7 @@ fn empty_pool(id: usize) -> Pool { Pool { slug: PoolSlug::from(id as u8), name: "", - addresses: Box::new([]), + addrs: Box::new([]), tags: Box::new([]), tags_lowercase: Box::new([]), link: "", @@ -47,8 +48,8 @@ impl Pools { }) } - pub fn find_from_address(&self, address: &str) -> Option<&Pool> { - self.iter().find(|pool| pool.addresses.contains(&address)) + pub fn find_from_addr(&self, addr: &str) -> Option<&Pool> { + self.iter().find(|pool| pool.addrs.contains(&addr)) } pub fn get_unknown(&self) -> &Pool { @@ -82,7 +83,7 @@ pub fn pools() -> &'static Pools { pools[0] = Pool { slug: PoolSlug::Unknown, name: "Unknown", - addresses: Box::new([]), + addrs: Box::new([]), tags: Box::new([]), tags_lowercase: Box::new([]), link: "", @@ -104,8 +105,8 @@ pub fn pools() -> &'static Pools { slug, name: leak_str(entry.name), link: leak_str(entry.link), - addresses: entry - .addresses + addrs: entry + .addrs .into_iter() .map(leak_str) .collect::>() diff --git a/crates/brk_types/src/stored_u16.rs b/crates/brk_types/src/stored_u16.rs index 7ed663b53..1d22be88e 100644 --- a/crates/brk_types/src/stored_u16.rs +++ b/crates/brk_types/src/stored_u16.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ - EmptyOutputIndex, OpReturnIndex, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, - P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, - P2WSHAddressIndex, UnknownOutputIndex, + EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, + P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, + P2WSHAddrIndex, UnknownOutputIndex, }; #[derive( @@ -103,23 +103,23 @@ impl From for usize { } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2PK65AddressIndex) -> Self { + fn from(value: P2PK65AddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2PK33AddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { Self::from(usize::from(value)) } } @@ -138,37 +138,37 @@ impl From for StoredU16 { } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2WSHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { + fn from(value: P2WPKHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU16 { +impl From for StoredU16 { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(usize::from(value)) } } diff --git a/crates/brk_types/src/stored_u32.rs b/crates/brk_types/src/stored_u32.rs index e249430ce..7ee2de194 100644 --- a/crates/brk_types/src/stored_u32.rs +++ b/crates/brk_types/src/stored_u32.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ - EmptyOutputIndex, OpReturnIndex, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, - P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, - P2WSHAddressIndex, UnknownOutputIndex, + EmptyOutputIndex, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, P2PK33AddrIndex, + P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, P2WPKHAddrIndex, + P2WSHAddrIndex, UnknownOutputIndex, }; /// Fixed-size 32-bit unsigned integer optimized for on-disk storage @@ -155,23 +155,23 @@ impl From for usize { } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2PK65AddressIndex) -> Self { + fn from(value: P2PK65AddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2PK33AddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { Self::from(usize::from(value)) } } @@ -190,37 +190,37 @@ impl From for StoredU32 { } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2WSHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { + fn from(value: P2WPKHAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { Self::from(usize::from(value)) } } -impl From for StoredU32 { +impl From for StoredU32 { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(usize::from(value)) } } diff --git a/crates/brk_types/src/stored_u64.rs b/crates/brk_types/src/stored_u64.rs index 35c3f77c3..07489157b 100644 --- a/crates/brk_types/src/stored_u64.rs +++ b/crates/brk_types/src/stored_u64.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; use vecdb::{CheckedSub, Formattable, Pco, PrintableIndex}; use super::{ - Day1, EmptyOutputIndex, Height, Month1, OpReturnIndex, P2AAddressIndex, P2MSOutputIndex, - P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, - P2WPKHAddressIndex, P2WSHAddressIndex, StoredU32, TxInIndex, TxIndex, TxOutIndex, + Day1, EmptyOutputIndex, Height, Month1, OpReturnIndex, P2AAddrIndex, P2MSOutputIndex, + P2PK33AddrIndex, P2PK65AddrIndex, P2PKHAddrIndex, P2SHAddrIndex, P2TRAddrIndex, + P2WPKHAddrIndex, P2WSHAddrIndex, StoredU32, TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, Year1, }; @@ -176,23 +176,23 @@ impl From for StoredU64 { } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2PK65AddressIndex) -> Self { + fn from(value: P2PK65AddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2PK33AddressIndex) -> Self { + fn from(value: P2PK33AddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2PKHAddressIndex) -> Self { + fn from(value: P2PKHAddrIndex) -> Self { Self::from(u64::from(value)) } } @@ -211,37 +211,37 @@ impl From for StoredU64 { } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2SHAddressIndex) -> Self { + fn from(value: P2SHAddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2WSHAddressIndex) -> Self { + fn from(value: P2WSHAddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2WPKHAddressIndex) -> Self { + fn from(value: P2WPKHAddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2TRAddressIndex) -> Self { + fn from(value: P2TRAddrIndex) -> Self { Self::from(u64::from(value)) } } -impl From for StoredU64 { +impl From for StoredU64 { #[inline] - fn from(value: P2AAddressIndex) -> Self { + fn from(value: P2AAddrIndex) -> Self { Self::from(u64::from(value)) } } diff --git a/crates/brk_types/src/supply_state.rs b/crates/brk_types/src/supply_state.rs index f322d5ecd..31fefe891 100644 --- a/crates/brk_types/src/supply_state.rs +++ b/crates/brk_types/src/supply_state.rs @@ -7,7 +7,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use vecdb::{Bytes, Formattable}; -use crate::{CheckedSub, FundedAddressData, Sats}; +use crate::{CheckedSub, FundedAddrData, Sats}; /// Current supply state tracking UTXO count and total value #[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, JsonSchema)] @@ -48,16 +48,16 @@ impl SubAssign<&SupplyState> for SupplyState { .checked_sub(rhs.utxo_count) .unwrap_or_else(|| { panic!( - "SupplyState underflow: cohort utxo_count {} < address utxo_count {}. \ - This indicates a desync between cohort state and address data. \ + "SupplyState underflow: cohort utxo_count {} < addr utxo_count {}. \ + This indicates a desync between cohort state and addr data. \ Try deleting the compute cache and restarting fresh.", self.utxo_count, rhs.utxo_count ) }); self.value = self.value.checked_sub(rhs.value).unwrap_or_else(|| { panic!( - "SupplyState underflow: cohort value {} < address value {}. \ - This indicates a desync between cohort state and address data. \ + "SupplyState underflow: cohort value {} < addr value {}. \ + This indicates a desync between cohort state and addr data. \ Try deleting the compute cache and restarting fresh.", self.value, rhs.value ) @@ -65,9 +65,9 @@ impl SubAssign<&SupplyState> for SupplyState { } } -impl From<&FundedAddressData> for SupplyState { +impl From<&FundedAddrData> for SupplyState { #[inline] - fn from(value: &FundedAddressData) -> Self { + fn from(value: &FundedAddrData) -> Self { Self { utxo_count: value.utxo_count() as u64, value: value.balance(), diff --git a/crates/brk_types/src/txout.rs b/crates/brk_types/src/txout.rs index e1583c05c..10986ce55 100644 --- a/crates/brk_types/src/txout.rs +++ b/crates/brk_types/src/txout.rs @@ -1,4 +1,4 @@ -use crate::{Address, AddressBytes, OutputType, Sats}; +use crate::{Addr, AddrBytes, OutputType, Sats}; use bitcoin::ScriptBuf; use schemars::JsonSchema; use serde::{Deserialize, Serialize, Serializer, ser::SerializeStruct}; @@ -35,8 +35,8 @@ pub struct TxOut { /// Bitcoin address (if applicable, None for OP_RETURN) #[allow(dead_code)] #[serde(skip, rename = "scriptpubkey_address")] - #[schemars(with = "Option
", example = Some("bc1q8vryck26jhuh0uqr2ttwj96szfnu4nwxfmu39y".to_string()))] - script_pubkey_address: (), + #[schemars(with = "Option", example = Some("bc1q8vryck26jhuh0uqr2ttwj96szfnu4nwxfmu39y".to_string()))] + script_pubkey_addr: (), /// Value of the output in satoshis #[schemars(example = Sats::new(7782))] @@ -44,12 +44,12 @@ pub struct TxOut { } impl TxOut { - pub fn address(&self) -> Option
{ - Address::try_from(&self.script_pubkey).ok() + pub fn addr(&self) -> Option { + Addr::try_from(&self.script_pubkey).ok() } - pub fn address_bytes(&self) -> Option { - AddressBytes::try_from(&self.script_pubkey).ok() + pub fn addr_bytes(&self) -> Option { + AddrBytes::try_from(&self.script_pubkey).ok() } pub fn type_(&self) -> OutputType { @@ -68,7 +68,7 @@ impl From for TxOut { script_pubkey: txout.script_pubkey, value: txout.value.into(), script_pubkey_asm: (), - script_pubkey_address: (), + script_pubkey_addr: (), script_pubkey_type: (), } } @@ -79,7 +79,7 @@ impl From<(ScriptBuf, Sats)> for TxOut { fn from((script, value): (ScriptBuf, Sats)) -> Self { Self { script_pubkey: script, - script_pubkey_address: (), + script_pubkey_addr: (), script_pubkey_asm: (), script_pubkey_type: (), value, @@ -96,7 +96,7 @@ impl Serialize for TxOut { state.serialize_field("scriptpubkey", &self.script_pubkey.to_hex_string())?; state.serialize_field("scriptpubkey_asm", &self.script_pubkey_asm())?; state.serialize_field("scriptpubkey_type", &self.type_())?; - state.serialize_field("scriptpubkey_address", &self.address())?; + state.serialize_field("scriptpubkey_address", &self.addr())?; state.serialize_field("value", &self.value)?; state.end() } diff --git a/crates/brk_types/src/validate_address_param.rs b/crates/brk_types/src/validate_addr_param.rs similarity index 76% rename from crates/brk_types/src/validate_address_param.rs rename to crates/brk_types/src/validate_addr_param.rs index 0541c04c7..1789e0b84 100644 --- a/crates/brk_types/src/validate_address_param.rs +++ b/crates/brk_types/src/validate_addr_param.rs @@ -2,13 +2,14 @@ use schemars::JsonSchema; use serde::Deserialize; #[derive(Deserialize, JsonSchema)] -pub struct ValidateAddressParam { +pub struct ValidateAddrParam { /// Bitcoin address to validate (can be any string) #[schemars( example = &"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f", example = &"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", - example = &"not-a-valid-address", + example = &"not-a-valid-addr", example = &"bc1qinvalid" )] - pub address: String, + #[serde(rename = "address")] + pub addr: String, } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 3187ff29f..3c25dabc6 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -6,14 +6,14 @@ /** * Bitcoin address string * - * @typedef {string} Address + * @typedef {string} Addr */ /** * Address statistics on the blockchain (confirmed transactions only) * * Based on mempool.space's format with type_index extension. * - * @typedef {Object} AddressChainStats + * @typedef {Object} AddrChainStats * @property {number} fundedTxoCount - Total number of transaction outputs that funded this address * @property {Sats} fundedTxoSum - Total amount in satoshis received by this address across all funded outputs * @property {number} spentTxoCount - Total number of transaction outputs spent from this address @@ -26,7 +26,7 @@ * * Based on mempool.space's format. * - * @typedef {Object} AddressMempoolStats + * @typedef {Object} AddrMempoolStats * @property {number} fundedTxoCount - Number of unconfirmed transaction outputs funding this address * @property {Sats} fundedTxoSum - Total amount in satoshis being received in unconfirmed transactions * @property {number} spentTxoCount - Number of unconfirmed transaction inputs spending from this address @@ -34,25 +34,25 @@ * @property {number} txCount - Number of unconfirmed transactions involving this address */ /** - * @typedef {Object} AddressParam - * @property {Address} address + * @typedef {Object} AddrParam + * @property {Addr} address */ /** * Address information compatible with mempool.space API format * - * @typedef {Object} AddressStats - * @property {Address} address - Bitcoin address string - * @property {AddressChainStats} chainStats - Statistics for confirmed transactions on the blockchain - * @property {(AddressMempoolStats|null)=} mempoolStats - Statistics for unconfirmed transactions in the mempool + * @typedef {Object} AddrStats + * @property {Addr} address - Bitcoin address string + * @property {AddrChainStats} chainStats - Statistics for confirmed transactions on the blockchain + * @property {(AddrMempoolStats|null)=} mempoolStats - Statistics for unconfirmed transactions in the mempool */ /** - * @typedef {Object} AddressTxidsParam + * @typedef {Object} AddrTxidsParam * @property {(Txid|null)=} afterTxid - Txid to paginate from (return transactions before this one) */ /** * Address validation result * - * @typedef {Object} AddressValidation + * @typedef {Object} AddrValidation * @property {boolean} isvalid - Whether the address is valid * @property {?string=} address - The validated address * @property {?string=} scriptPubKey - The scriptPubKey in hex @@ -64,7 +64,7 @@ /** * Unified index for any address type (funded or empty) * - * @typedef {TypeIndex} AnyAddressIndex + * @typedef {TypeIndex} AnyAddrIndex */ /** * Unsigned basis points stored as u16. @@ -99,6 +99,11 @@ * * @typedef {number} Bitcoin */ +/** + * Position within a .blk file, encoding file index and byte offset + * + * @typedef {number} BlkPosition + */ /** * @typedef {Object} BlockCountParam * @property {number} blockCount - Number of recent blocks to include @@ -334,12 +339,12 @@ /** * Data of an empty address * - * @typedef {Object} EmptyAddressData + * @typedef {Object} EmptyAddrData * @property {number} txCount - Total transaction count * @property {number} fundedTxoCount - Total funded/spent transaction output count (equal since address is empty) * @property {Sats} transfered - Total satoshis transferred */ -/** @typedef {TypeIndex} EmptyAddressIndex */ +/** @typedef {TypeIndex} EmptyAddrIndex */ /** @typedef {TypeIndex} EmptyOutputIndex */ /** @typedef {number} Epoch */ /** @@ -349,7 +354,7 @@ /** * @typedef {Object} ErrorDetail * @property {string} type - Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" - * @property {string} code - Machine-readable error code (e.g. "invalid_address", "series_not_found") + * @property {string} code - Machine-readable error code (e.g. "invalid_addr", "series_not_found") * @property {string} message - Human-readable description * @property {string} docUrl - Link to API documentation */ @@ -366,7 +371,7 @@ /** * Data for a funded (non-empty) address with current balance * - * @typedef {Object} FundedAddressData + * @typedef {Object} FundedAddrData * @property {number} txCount - Total transaction count * @property {number} fundedTxoCount - Number of transaction outputs funded to this address * @property {number} spentTxoCount - Number of transaction outputs spent by this address @@ -375,7 +380,7 @@ * @property {CentsSats} realizedCapRaw - The realized capitalization: Σ(price × sats) * @property {CentsSquaredSats} investorCapRaw - The investor capitalization: Σ(price² × sats) */ -/** @typedef {TypeIndex} FundedAddressIndex */ +/** @typedef {TypeIndex} FundedAddrIndex */ /** @typedef {number} Halving */ /** * A single hashrate data point. @@ -436,7 +441,7 @@ * Aggregation dimension for querying series. Includes time-based (date, week, month, year), * block-based (height, tx_index), and address/output type indexes. * - * @typedef {("minute10"|"minute30"|"hour1"|"hour4"|"hour12"|"day1"|"day3"|"week1"|"month1"|"month3"|"month6"|"year1"|"year10"|"halving"|"epoch"|"height"|"tx_index"|"txin_index"|"txout_index"|"empty_output_index"|"op_return_index"|"p2a_address_index"|"p2ms_output_index"|"p2pk33_address_index"|"p2pk65_address_index"|"p2pkh_address_index"|"p2sh_address_index"|"p2tr_address_index"|"p2wpkh_address_index"|"p2wsh_address_index"|"unknown_output_index"|"funded_address_index"|"empty_address_index")} Index + * @typedef {("minute10"|"minute30"|"hour1"|"hour4"|"hour12"|"day1"|"day3"|"week1"|"month1"|"month3"|"month6"|"year1"|"year10"|"halving"|"epoch"|"height"|"tx_index"|"txin_index"|"txout_index"|"empty_output_index"|"op_return_index"|"p2a_addr_index"|"p2ms_output_index"|"p2pk33_addr_index"|"p2pk65_addr_index"|"p2pkh_addr_index"|"p2sh_addr_index"|"p2tr_addr_index"|"p2wpkh_addr_index"|"p2wsh_addr_index"|"unknown_output_index"|"funded_addr_index"|"empty_addr_index")} Index */ /** * Information about an available index and its query aliases @@ -531,22 +536,22 @@ * * @typedef {("p2pk65"|"p2pk33"|"p2pkh"|"p2ms"|"p2sh"|"opreturn"|"p2wpkh"|"p2wsh"|"p2tr"|"p2a"|"empty"|"unknown")} OutputType */ -/** @typedef {TypeIndex} P2AAddressIndex */ +/** @typedef {TypeIndex} P2AAddrIndex */ /** @typedef {U8x2} P2ABytes */ /** @typedef {TypeIndex} P2MSOutputIndex */ -/** @typedef {TypeIndex} P2PK33AddressIndex */ +/** @typedef {TypeIndex} P2PK33AddrIndex */ /** @typedef {U8x33} P2PK33Bytes */ -/** @typedef {TypeIndex} P2PK65AddressIndex */ +/** @typedef {TypeIndex} P2PK65AddrIndex */ /** @typedef {U8x65} P2PK65Bytes */ -/** @typedef {TypeIndex} P2PKHAddressIndex */ +/** @typedef {TypeIndex} P2PKHAddrIndex */ /** @typedef {U8x20} P2PKHBytes */ -/** @typedef {TypeIndex} P2SHAddressIndex */ +/** @typedef {TypeIndex} P2SHAddrIndex */ /** @typedef {U8x20} P2SHBytes */ -/** @typedef {TypeIndex} P2TRAddressIndex */ +/** @typedef {TypeIndex} P2TRAddrIndex */ /** @typedef {U8x32} P2TRBytes */ -/** @typedef {TypeIndex} P2WPKHAddressIndex */ +/** @typedef {TypeIndex} P2WPKHAddrIndex */ /** @typedef {U8x20} P2WPKHBytes */ -/** @typedef {TypeIndex} P2WSHAddressIndex */ +/** @typedef {TypeIndex} P2WSHAddrIndex */ /** @typedef {U8x32} P2WSHBytes */ /** * A paginated list of available series names (1000 per page) @@ -599,7 +604,7 @@ * @property {number} id - Unique pool identifier * @property {string} name - Pool name * @property {string} link - Pool website URL - * @property {string[]} addresses - Known payout addresses + * @property {string[]} addrs - Known payout addresses * @property {string[]} regexes - Coinbase tag patterns (regexes) * @property {PoolSlug} slug - URL-friendly pool identifier */ @@ -937,7 +942,7 @@ * @typedef {number} VSize */ /** - * @typedef {Object} ValidateAddressParam + * @typedef {Object} ValidateAddrParam * @property {string} address - Bitcoin address to validate (can be any string) */ /** @@ -1477,18 +1482,18 @@ const _i20 = /** @type {const} */ (["txin_index"]); const _i21 = /** @type {const} */ (["txout_index"]); const _i22 = /** @type {const} */ (["empty_output_index"]); const _i23 = /** @type {const} */ (["op_return_index"]); -const _i24 = /** @type {const} */ (["p2a_address_index"]); +const _i24 = /** @type {const} */ (["p2a_addr_index"]); const _i25 = /** @type {const} */ (["p2ms_output_index"]); -const _i26 = /** @type {const} */ (["p2pk33_address_index"]); -const _i27 = /** @type {const} */ (["p2pk65_address_index"]); -const _i28 = /** @type {const} */ (["p2pkh_address_index"]); -const _i29 = /** @type {const} */ (["p2sh_address_index"]); -const _i30 = /** @type {const} */ (["p2tr_address_index"]); -const _i31 = /** @type {const} */ (["p2wpkh_address_index"]); -const _i32 = /** @type {const} */ (["p2wsh_address_index"]); +const _i26 = /** @type {const} */ (["p2pk33_addr_index"]); +const _i27 = /** @type {const} */ (["p2pk65_addr_index"]); +const _i28 = /** @type {const} */ (["p2pkh_addr_index"]); +const _i29 = /** @type {const} */ (["p2sh_addr_index"]); +const _i30 = /** @type {const} */ (["p2tr_addr_index"]); +const _i31 = /** @type {const} */ (["p2wpkh_addr_index"]); +const _i32 = /** @type {const} */ (["p2wsh_addr_index"]); const _i33 = /** @type {const} */ (["unknown_output_index"]); -const _i34 = /** @type {const} */ (["funded_address_index"]); -const _i35 = /** @type {const} */ (["empty_address_index"]); +const _i34 = /** @type {const} */ (["funded_addr_index"]); +const _i35 = /** @type {const} */ (["empty_addr_index"]); /** * Generic series pattern factory. @@ -1585,40 +1590,40 @@ function createSeriesPattern22(client, name) { return /** @type {SeriesPattern22 /** @template T @typedef {{ name: string, by: { readonly op_return_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern23 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern23} */ function createSeriesPattern23(client, name) { return /** @type {SeriesPattern23} */ (_mp(client, name, _i23)); } -/** @template T @typedef {{ name: string, by: { readonly p2a_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern24 */ +/** @template T @typedef {{ name: string, by: { readonly p2a_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern24 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern24} */ function createSeriesPattern24(client, name) { return /** @type {SeriesPattern24} */ (_mp(client, name, _i24)); } /** @template T @typedef {{ name: string, by: { readonly p2ms_output_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern25 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern25} */ function createSeriesPattern25(client, name) { return /** @type {SeriesPattern25} */ (_mp(client, name, _i25)); } -/** @template T @typedef {{ name: string, by: { readonly p2pk33_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern26 */ +/** @template T @typedef {{ name: string, by: { readonly p2pk33_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern26 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern26} */ function createSeriesPattern26(client, name) { return /** @type {SeriesPattern26} */ (_mp(client, name, _i26)); } -/** @template T @typedef {{ name: string, by: { readonly p2pk65_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern27 */ +/** @template T @typedef {{ name: string, by: { readonly p2pk65_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern27 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern27} */ function createSeriesPattern27(client, name) { return /** @type {SeriesPattern27} */ (_mp(client, name, _i27)); } -/** @template T @typedef {{ name: string, by: { readonly p2pkh_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern28 */ +/** @template T @typedef {{ name: string, by: { readonly p2pkh_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern28 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern28} */ function createSeriesPattern28(client, name) { return /** @type {SeriesPattern28} */ (_mp(client, name, _i28)); } -/** @template T @typedef {{ name: string, by: { readonly p2sh_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern29 */ +/** @template T @typedef {{ name: string, by: { readonly p2sh_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern29 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern29} */ function createSeriesPattern29(client, name) { return /** @type {SeriesPattern29} */ (_mp(client, name, _i29)); } -/** @template T @typedef {{ name: string, by: { readonly p2tr_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern30 */ +/** @template T @typedef {{ name: string, by: { readonly p2tr_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern30 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern30} */ function createSeriesPattern30(client, name) { return /** @type {SeriesPattern30} */ (_mp(client, name, _i30)); } -/** @template T @typedef {{ name: string, by: { readonly p2wpkh_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern31 */ +/** @template T @typedef {{ name: string, by: { readonly p2wpkh_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern31 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern31} */ function createSeriesPattern31(client, name) { return /** @type {SeriesPattern31} */ (_mp(client, name, _i31)); } -/** @template T @typedef {{ name: string, by: { readonly p2wsh_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern32 */ +/** @template T @typedef {{ name: string, by: { readonly p2wsh_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern32 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern32} */ function createSeriesPattern32(client, name) { return /** @type {SeriesPattern32} */ (_mp(client, name, _i32)); } /** @template T @typedef {{ name: string, by: { readonly unknown_output_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern33 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern33} */ function createSeriesPattern33(client, name) { return /** @type {SeriesPattern33} */ (_mp(client, name, _i33)); } -/** @template T @typedef {{ name: string, by: { readonly funded_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern34 */ +/** @template T @typedef {{ name: string, by: { readonly funded_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern34 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern34} */ function createSeriesPattern34(client, name) { return /** @type {SeriesPattern34} */ (_mp(client, name, _i34)); } -/** @template T @typedef {{ name: string, by: { readonly empty_address_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern35 */ +/** @template T @typedef {{ name: string, by: { readonly empty_addr_index: SeriesEndpoint }, indexes: () => readonly Index[], get: (index: Index) => SeriesEndpoint|undefined }} SeriesPattern35 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {SeriesPattern35} */ function createSeriesPattern35(client, name) { return /** @type {SeriesPattern35} */ (_mp(client, name, _i35)); } @@ -2446,8 +2451,8 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { } /** - * @typedef {Object} AddressOutputsRealizedSupplyUnrealizedPattern - * @property {BaseDeltaPattern} addressCount + * @typedef {Object} AddrOutputsRealizedSupplyUnrealizedPattern + * @property {BaseDeltaPattern} addrCount * @property {UnspentPattern} outputs * @property {CapLossMvrvPriceProfitSoprPattern} realized * @property {DeltaHalfTotalPattern} supply @@ -2455,14 +2460,14 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { */ /** - * Create a AddressOutputsRealizedSupplyUnrealizedPattern pattern node + * Create a AddrOutputsRealizedSupplyUnrealizedPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated series name - * @returns {AddressOutputsRealizedSupplyUnrealizedPattern} + * @returns {AddrOutputsRealizedSupplyUnrealizedPattern} */ -function createAddressOutputsRealizedSupplyUnrealizedPattern(client, acc) { +function createAddrOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { - addressCount: createBaseDeltaPattern(client, _m(acc, 'address_count')), + addrCount: createBaseDeltaPattern(client, _m(acc, 'addr_count')), outputs: createUnspentPattern(client, _m(acc, 'utxo_count')), realized: createCapLossMvrvPriceProfitSoprPattern(client, acc), supply: createDeltaHalfTotalPattern(client, _m(acc, 'supply')), @@ -2472,11 +2477,11 @@ function createAddressOutputsRealizedSupplyUnrealizedPattern(client, acc) { /** * @typedef {Object} BaseCumulativeInSumPattern - * @property {SeriesPattern1} base - * @property {SeriesPattern1} cumulative + * @property {BtcCentsSatsUsdPattern} base + * @property {BtcCentsSatsUsdPattern} cumulative * @property {BaseCumulativeSumPattern4} inLoss * @property {BaseCumulativeSumPattern4} inProfit - * @property {_1m1w1y24hPattern} sum + * @property {_1m1w1y24hPattern5} sum */ /** @@ -2487,11 +2492,11 @@ function createAddressOutputsRealizedSupplyUnrealizedPattern(client, acc) { */ function createBaseCumulativeInSumPattern(client, acc) { return { - base: createSeriesPattern1(client, acc), - cumulative: createSeriesPattern1(client, _m(acc, 'cumulative')), + base: createBtcCentsSatsUsdPattern(client, acc), + cumulative: createBtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')), inLoss: createBaseCumulativeSumPattern4(client, _m(acc, 'in_loss')), inProfit: createBaseCumulativeSumPattern4(client, _m(acc, 'in_profit')), - sum: create_1m1w1y24hPattern(client, _m(acc, 'sum')), + sum: create_1m1w1y24hPattern5(client, _m(acc, 'sum')), }; } @@ -3875,9 +3880,10 @@ function createUnspentPattern(client, acc) { * @property {SeriesTree_Transactions} transactions * @property {SeriesTree_Inputs} inputs * @property {SeriesTree_Outputs} outputs - * @property {SeriesTree_Addresses} addresses + * @property {SeriesTree_Addrs} addrs * @property {SeriesTree_Scripts} scripts * @property {SeriesTree_Mining} mining + * @property {SeriesTree_Positions} positions * @property {SeriesTree_Cointime} cointime * @property {SeriesTree_Constants} constants * @property {SeriesTree_Indexes} indexes @@ -4128,100 +4134,100 @@ function createUnspentPattern(client, acc) { */ /** - * @typedef {Object} SeriesTree_Addresses - * @property {SeriesTree_Addresses_Raw} raw - * @property {SeriesTree_Addresses_Indexes} indexes - * @property {SeriesTree_Addresses_Data} data + * @typedef {Object} SeriesTree_Addrs + * @property {SeriesTree_Addrs_Raw} raw + * @property {SeriesTree_Addrs_Indexes} indexes + * @property {SeriesTree_Addrs_Data} data * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} funded * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} empty - * @property {SeriesTree_Addresses_Activity} activity + * @property {SeriesTree_Addrs_Activity} activity * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3} total - * @property {SeriesTree_Addresses_New} new - * @property {SeriesTree_Addresses_Delta} delta + * @property {SeriesTree_Addrs_New} new + * @property {SeriesTree_Addrs_Delta} delta */ /** - * @typedef {Object} SeriesTree_Addresses_Raw - * @property {SeriesTree_Addresses_Raw_P2pk65} p2pk65 - * @property {SeriesTree_Addresses_Raw_P2pk33} p2pk33 - * @property {SeriesTree_Addresses_Raw_P2pkh} p2pkh - * @property {SeriesTree_Addresses_Raw_P2sh} p2sh - * @property {SeriesTree_Addresses_Raw_P2wpkh} p2wpkh - * @property {SeriesTree_Addresses_Raw_P2wsh} p2wsh - * @property {SeriesTree_Addresses_Raw_P2tr} p2tr - * @property {SeriesTree_Addresses_Raw_P2a} p2a + * @typedef {Object} SeriesTree_Addrs_Raw + * @property {SeriesTree_Addrs_Raw_P2pk65} p2pk65 + * @property {SeriesTree_Addrs_Raw_P2pk33} p2pk33 + * @property {SeriesTree_Addrs_Raw_P2pkh} p2pkh + * @property {SeriesTree_Addrs_Raw_P2sh} p2sh + * @property {SeriesTree_Addrs_Raw_P2wpkh} p2wpkh + * @property {SeriesTree_Addrs_Raw_P2wsh} p2wsh + * @property {SeriesTree_Addrs_Raw_P2tr} p2tr + * @property {SeriesTree_Addrs_Raw_P2a} p2a */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2pk65 - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2pk65 + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern27} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2pk33 - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2pk33 + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern26} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2pkh - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2pkh + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern28} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2sh - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2sh + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern29} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2wpkh - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2wpkh + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern31} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2wsh - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2wsh + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern32} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2tr - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2tr + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern30} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Raw_P2a - * @property {SeriesPattern18} firstIndex + * @typedef {Object} SeriesTree_Addrs_Raw_P2a + * @property {SeriesPattern18} firstIndex * @property {SeriesPattern24} bytes */ /** - * @typedef {Object} SeriesTree_Addresses_Indexes - * @property {SeriesPattern24} p2a - * @property {SeriesPattern26} p2pk33 - * @property {SeriesPattern27} p2pk65 - * @property {SeriesPattern28} p2pkh - * @property {SeriesPattern29} p2sh - * @property {SeriesPattern30} p2tr - * @property {SeriesPattern31} p2wpkh - * @property {SeriesPattern32} p2wsh - * @property {SeriesPattern34} funded - * @property {SeriesPattern35} empty + * @typedef {Object} SeriesTree_Addrs_Indexes + * @property {SeriesPattern24} p2a + * @property {SeriesPattern26} p2pk33 + * @property {SeriesPattern27} p2pk65 + * @property {SeriesPattern28} p2pkh + * @property {SeriesPattern29} p2sh + * @property {SeriesPattern30} p2tr + * @property {SeriesPattern31} p2wpkh + * @property {SeriesPattern32} p2wsh + * @property {SeriesPattern34} funded + * @property {SeriesPattern35} empty */ /** - * @typedef {Object} SeriesTree_Addresses_Data - * @property {SeriesPattern34} funded - * @property {SeriesPattern35} empty + * @typedef {Object} SeriesTree_Addrs_Data + * @property {SeriesPattern34} funded + * @property {SeriesPattern35} empty */ /** - * @typedef {Object} SeriesTree_Addresses_Activity + * @typedef {Object} SeriesTree_Addrs_Activity * @property {BothReactivatedReceivingSendingPattern} all * @property {BothReactivatedReceivingSendingPattern} p2pk65 * @property {BothReactivatedReceivingSendingPattern} p2pk33 @@ -4234,7 +4240,7 @@ function createUnspentPattern(client, acc) { */ /** - * @typedef {Object} SeriesTree_Addresses_New + * @typedef {Object} SeriesTree_Addrs_New * @property {BaseCumulativeSumPattern} all * @property {BaseCumulativeSumPattern} p2pk65 * @property {BaseCumulativeSumPattern} p2pk33 @@ -4247,7 +4253,7 @@ function createUnspentPattern(client, acc) { */ /** - * @typedef {Object} SeriesTree_Addresses_Delta + * @typedef {Object} SeriesTree_Addrs_Delta * @property {AbsoluteRatePattern} all * @property {AbsoluteRatePattern} p2pk65 * @property {AbsoluteRatePattern} p2pk33 @@ -4397,6 +4403,12 @@ function createUnspentPattern(client, acc) { * @property {SeriesPattern1} _1y */ +/** + * @typedef {Object} SeriesTree_Positions + * @property {SeriesPattern18} block + * @property {SeriesPattern19} tx + */ + /** * @typedef {Object} SeriesTree_Cointime * @property {SeriesTree_Cointime_Activity} activity @@ -4492,7 +4504,7 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} SeriesTree_Indexes - * @property {SeriesTree_Indexes_Address} address + * @property {SeriesTree_Indexes_Addr} addr * @property {SeriesTree_Indexes_Height} height * @property {SeriesTree_Indexes_Epoch} epoch * @property {SeriesTree_Indexes_Halving} halving @@ -4515,86 +4527,86 @@ function createUnspentPattern(client, acc) { */ /** - * @typedef {Object} SeriesTree_Indexes_Address - * @property {SeriesTree_Indexes_Address_P2pk33} p2pk33 - * @property {SeriesTree_Indexes_Address_P2pk65} p2pk65 - * @property {SeriesTree_Indexes_Address_P2pkh} p2pkh - * @property {SeriesTree_Indexes_Address_P2sh} p2sh - * @property {SeriesTree_Indexes_Address_P2tr} p2tr - * @property {SeriesTree_Indexes_Address_P2wpkh} p2wpkh - * @property {SeriesTree_Indexes_Address_P2wsh} p2wsh - * @property {SeriesTree_Indexes_Address_P2a} p2a - * @property {SeriesTree_Indexes_Address_P2ms} p2ms - * @property {SeriesTree_Indexes_Address_Empty} empty - * @property {SeriesTree_Indexes_Address_Unknown} unknown - * @property {SeriesTree_Indexes_Address_OpReturn} opReturn + * @typedef {Object} SeriesTree_Indexes_Addr + * @property {SeriesTree_Indexes_Addr_P2pk33} p2pk33 + * @property {SeriesTree_Indexes_Addr_P2pk65} p2pk65 + * @property {SeriesTree_Indexes_Addr_P2pkh} p2pkh + * @property {SeriesTree_Indexes_Addr_P2sh} p2sh + * @property {SeriesTree_Indexes_Addr_P2tr} p2tr + * @property {SeriesTree_Indexes_Addr_P2wpkh} p2wpkh + * @property {SeriesTree_Indexes_Addr_P2wsh} p2wsh + * @property {SeriesTree_Indexes_Addr_P2a} p2a + * @property {SeriesTree_Indexes_Addr_P2ms} p2ms + * @property {SeriesTree_Indexes_Addr_Empty} empty + * @property {SeriesTree_Indexes_Addr_Unknown} unknown + * @property {SeriesTree_Indexes_Addr_OpReturn} opReturn */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2pk33 - * @property {SeriesPattern26} identity - * @property {SeriesPattern26
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2pk33 + * @property {SeriesPattern26} identity + * @property {SeriesPattern26} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2pk65 - * @property {SeriesPattern27} identity - * @property {SeriesPattern27
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2pk65 + * @property {SeriesPattern27} identity + * @property {SeriesPattern27} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2pkh - * @property {SeriesPattern28} identity - * @property {SeriesPattern28
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2pkh + * @property {SeriesPattern28} identity + * @property {SeriesPattern28} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2sh - * @property {SeriesPattern29} identity - * @property {SeriesPattern29
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2sh + * @property {SeriesPattern29} identity + * @property {SeriesPattern29} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2tr - * @property {SeriesPattern30} identity - * @property {SeriesPattern30
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2tr + * @property {SeriesPattern30} identity + * @property {SeriesPattern30} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2wpkh - * @property {SeriesPattern31} identity - * @property {SeriesPattern31
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2wpkh + * @property {SeriesPattern31} identity + * @property {SeriesPattern31} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2wsh - * @property {SeriesPattern32} identity - * @property {SeriesPattern32
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2wsh + * @property {SeriesPattern32} identity + * @property {SeriesPattern32} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2a - * @property {SeriesPattern24} identity - * @property {SeriesPattern24
} address + * @typedef {Object} SeriesTree_Indexes_Addr_P2a + * @property {SeriesPattern24} identity + * @property {SeriesPattern24} addr */ /** - * @typedef {Object} SeriesTree_Indexes_Address_P2ms + * @typedef {Object} SeriesTree_Indexes_Addr_P2ms * @property {SeriesPattern25} identity */ /** - * @typedef {Object} SeriesTree_Indexes_Address_Empty + * @typedef {Object} SeriesTree_Indexes_Addr_Empty * @property {SeriesPattern22} identity */ /** - * @typedef {Object} SeriesTree_Indexes_Address_Unknown + * @typedef {Object} SeriesTree_Indexes_Addr_Unknown * @property {SeriesPattern33} identity */ /** - * @typedef {Object} SeriesTree_Indexes_Address_OpReturn + * @typedef {Object} SeriesTree_Indexes_Addr_OpReturn * @property {SeriesPattern23} identity */ @@ -5302,7 +5314,7 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} SeriesTree_Cohorts * @property {SeriesTree_Cohorts_Utxo} utxo - * @property {SeriesTree_Cohorts_Address} address + * @property {SeriesTree_Cohorts_Addr} addr */ /** @@ -6196,63 +6208,63 @@ function createUnspentPattern(client, acc) { */ /** - * @typedef {Object} SeriesTree_Cohorts_Address - * @property {SeriesTree_Cohorts_Address_OverAmount} overAmount - * @property {SeriesTree_Cohorts_Address_AmountRange} amountRange - * @property {SeriesTree_Cohorts_Address_UnderAmount} underAmount + * @typedef {Object} SeriesTree_Cohorts_Addr + * @property {SeriesTree_Cohorts_Addr_OverAmount} overAmount + * @property {SeriesTree_Cohorts_Addr_AmountRange} amountRange + * @property {SeriesTree_Cohorts_Addr_UnderAmount} underAmount */ /** - * @typedef {Object} SeriesTree_Cohorts_Address_OverAmount - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1sat - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @typedef {Object} SeriesTree_Cohorts_Addr_OverAmount + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1sat + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kBtc */ /** - * @typedef {Object} SeriesTree_Cohorts_Address_AmountRange - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _0sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1satTo10sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} over100kBtc + * @typedef {Object} SeriesTree_Cohorts_Addr_AmountRange + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _0sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1satTo10sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} over100kBtc */ /** - * @typedef {Object} SeriesTree_Cohorts_Address_UnderAmount - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _10kBtc - * @property {AddressOutputsRealizedSupplyUnrealizedPattern} _100kBtc + * @typedef {Object} SeriesTree_Cohorts_Addr_UnderAmount + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100sats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100kSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10mSats + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100btc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _1kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @property {AddrOutputsRealizedSupplyUnrealizedPattern} _100kBtc */ /** @@ -6284,18 +6296,18 @@ class BrkClient extends BrkClientBase { "txout_index", "empty_output_index", "op_return_index", - "p2a_address_index", + "p2a_addr_index", "p2ms_output_index", - "p2pk33_address_index", - "p2pk65_address_index", - "p2pkh_address_index", - "p2sh_address_index", - "p2tr_address_index", - "p2wpkh_address_index", - "p2wsh_address_index", + "p2pk33_addr_index", + "p2pk65_addr_index", + "p2pkh_addr_index", + "p2sh_addr_index", + "p2tr_addr_index", + "p2wpkh_addr_index", + "p2wsh_addr_index", "unknown_output_index", - "funded_address_index", - "empty_address_index" + "funded_addr_index", + "empty_addr_index" ]); POOL_ID_TO_POOL_NAME = /** @type {const} */ ({ @@ -7585,7 +7597,7 @@ class BrkClient extends BrkClientBase { v3: createBaseCumulativeSumPattern(this, 'tx_v3'), }, volume: { - transferVolume: createBaseCumulativeSumPattern4(this, 'exact_transfer_volume'), + transferVolume: createBaseCumulativeSumPattern4(this, 'transfer_volume_bis'), outputVolume: createBaseCumulativeSumPattern4(this, 'output_volume'), txPerSec: createSeriesPattern1(this, 'tx_per_sec'), outputsPerSec: createSeriesPattern1(this, 'outputs_per_sec'), @@ -7619,95 +7631,95 @@ class BrkClient extends BrkClientBase { }, count: { total: createAverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern(this, 'output_count'), - unspent: createSeriesPattern1(this, 'exact_utxo_count'), + unspent: createSeriesPattern1(this, 'utxo_count_bis'), }, }, - addresses: { + addrs: { raw: { p2pk65: { - firstIndex: createSeriesPattern18(this, 'first_p2pk65_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2pk65_addr_index'), bytes: createSeriesPattern27(this, 'p2pk65_bytes'), }, p2pk33: { - firstIndex: createSeriesPattern18(this, 'first_p2pk33_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2pk33_addr_index'), bytes: createSeriesPattern26(this, 'p2pk33_bytes'), }, p2pkh: { - firstIndex: createSeriesPattern18(this, 'first_p2pkh_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2pkh_addr_index'), bytes: createSeriesPattern28(this, 'p2pkh_bytes'), }, p2sh: { - firstIndex: createSeriesPattern18(this, 'first_p2sh_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2sh_addr_index'), bytes: createSeriesPattern29(this, 'p2sh_bytes'), }, p2wpkh: { - firstIndex: createSeriesPattern18(this, 'first_p2wpkh_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2wpkh_addr_index'), bytes: createSeriesPattern31(this, 'p2wpkh_bytes'), }, p2wsh: { - firstIndex: createSeriesPattern18(this, 'first_p2wsh_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2wsh_addr_index'), bytes: createSeriesPattern32(this, 'p2wsh_bytes'), }, p2tr: { - firstIndex: createSeriesPattern18(this, 'first_p2tr_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2tr_addr_index'), bytes: createSeriesPattern30(this, 'p2tr_bytes'), }, p2a: { - firstIndex: createSeriesPattern18(this, 'first_p2a_address_index'), + firstIndex: createSeriesPattern18(this, 'first_p2a_addr_index'), bytes: createSeriesPattern24(this, 'p2a_bytes'), }, }, indexes: { - p2a: createSeriesPattern24(this, 'any_address_index'), - p2pk33: createSeriesPattern26(this, 'any_address_index'), - p2pk65: createSeriesPattern27(this, 'any_address_index'), - p2pkh: createSeriesPattern28(this, 'any_address_index'), - p2sh: createSeriesPattern29(this, 'any_address_index'), - p2tr: createSeriesPattern30(this, 'any_address_index'), - p2wpkh: createSeriesPattern31(this, 'any_address_index'), - p2wsh: createSeriesPattern32(this, 'any_address_index'), - funded: createSeriesPattern34(this, 'funded_address_index'), - empty: createSeriesPattern35(this, 'empty_address_index'), + p2a: createSeriesPattern24(this, 'any_addr_index'), + p2pk33: createSeriesPattern26(this, 'any_addr_index'), + p2pk65: createSeriesPattern27(this, 'any_addr_index'), + p2pkh: createSeriesPattern28(this, 'any_addr_index'), + p2sh: createSeriesPattern29(this, 'any_addr_index'), + p2tr: createSeriesPattern30(this, 'any_addr_index'), + p2wpkh: createSeriesPattern31(this, 'any_addr_index'), + p2wsh: createSeriesPattern32(this, 'any_addr_index'), + funded: createSeriesPattern34(this, 'funded_addr_index'), + empty: createSeriesPattern35(this, 'empty_addr_index'), }, data: { - funded: createSeriesPattern34(this, 'funded_address_data'), - empty: createSeriesPattern35(this, 'empty_address_data'), + funded: createSeriesPattern34(this, 'funded_addr_data'), + empty: createSeriesPattern35(this, 'empty_addr_data'), }, - funded: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'address_count'), - empty: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'empty_address_count'), + funded: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'addr_count'), + empty: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'empty_addr_count'), activity: { - all: createBothReactivatedReceivingSendingPattern(this, 'address_activity'), - p2pk65: createBothReactivatedReceivingSendingPattern(this, 'p2pk65_address_activity'), - p2pk33: createBothReactivatedReceivingSendingPattern(this, 'p2pk33_address_activity'), - p2pkh: createBothReactivatedReceivingSendingPattern(this, 'p2pkh_address_activity'), - p2sh: createBothReactivatedReceivingSendingPattern(this, 'p2sh_address_activity'), - p2wpkh: createBothReactivatedReceivingSendingPattern(this, 'p2wpkh_address_activity'), - p2wsh: createBothReactivatedReceivingSendingPattern(this, 'p2wsh_address_activity'), - p2tr: createBothReactivatedReceivingSendingPattern(this, 'p2tr_address_activity'), - p2a: createBothReactivatedReceivingSendingPattern(this, 'p2a_address_activity'), + all: createBothReactivatedReceivingSendingPattern(this, 'addr_activity'), + p2pk65: createBothReactivatedReceivingSendingPattern(this, 'p2pk65_addr_activity'), + p2pk33: createBothReactivatedReceivingSendingPattern(this, 'p2pk33_addr_activity'), + p2pkh: createBothReactivatedReceivingSendingPattern(this, 'p2pkh_addr_activity'), + p2sh: createBothReactivatedReceivingSendingPattern(this, 'p2sh_addr_activity'), + p2wpkh: createBothReactivatedReceivingSendingPattern(this, 'p2wpkh_addr_activity'), + p2wsh: createBothReactivatedReceivingSendingPattern(this, 'p2wsh_addr_activity'), + p2tr: createBothReactivatedReceivingSendingPattern(this, 'p2tr_addr_activity'), + p2a: createBothReactivatedReceivingSendingPattern(this, 'p2a_addr_activity'), }, - total: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'total_address_count'), + total: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(this, 'total_addr_count'), new: { - all: createBaseCumulativeSumPattern(this, 'new_address_count'), - p2pk65: createBaseCumulativeSumPattern(this, 'p2pk65_new_address_count'), - p2pk33: createBaseCumulativeSumPattern(this, 'p2pk33_new_address_count'), - p2pkh: createBaseCumulativeSumPattern(this, 'p2pkh_new_address_count'), - p2sh: createBaseCumulativeSumPattern(this, 'p2sh_new_address_count'), - p2wpkh: createBaseCumulativeSumPattern(this, 'p2wpkh_new_address_count'), - p2wsh: createBaseCumulativeSumPattern(this, 'p2wsh_new_address_count'), - p2tr: createBaseCumulativeSumPattern(this, 'p2tr_new_address_count'), - p2a: createBaseCumulativeSumPattern(this, 'p2a_new_address_count'), + all: createBaseCumulativeSumPattern(this, 'new_addr_count'), + p2pk65: createBaseCumulativeSumPattern(this, 'p2pk65_new_addr_count'), + p2pk33: createBaseCumulativeSumPattern(this, 'p2pk33_new_addr_count'), + p2pkh: createBaseCumulativeSumPattern(this, 'p2pkh_new_addr_count'), + p2sh: createBaseCumulativeSumPattern(this, 'p2sh_new_addr_count'), + p2wpkh: createBaseCumulativeSumPattern(this, 'p2wpkh_new_addr_count'), + p2wsh: createBaseCumulativeSumPattern(this, 'p2wsh_new_addr_count'), + p2tr: createBaseCumulativeSumPattern(this, 'p2tr_new_addr_count'), + p2a: createBaseCumulativeSumPattern(this, 'p2a_new_addr_count'), }, delta: { - all: createAbsoluteRatePattern(this, 'address_count'), - p2pk65: createAbsoluteRatePattern(this, 'p2pk65_address_count'), - p2pk33: createAbsoluteRatePattern(this, 'p2pk33_address_count'), - p2pkh: createAbsoluteRatePattern(this, 'p2pkh_address_count'), - p2sh: createAbsoluteRatePattern(this, 'p2sh_address_count'), - p2wpkh: createAbsoluteRatePattern(this, 'p2wpkh_address_count'), - p2wsh: createAbsoluteRatePattern(this, 'p2wsh_address_count'), - p2tr: createAbsoluteRatePattern(this, 'p2tr_address_count'), - p2a: createAbsoluteRatePattern(this, 'p2a_address_count'), + all: createAbsoluteRatePattern(this, 'addr_count'), + p2pk65: createAbsoluteRatePattern(this, 'p2pk65_addr_count'), + p2pk33: createAbsoluteRatePattern(this, 'p2pk33_addr_count'), + p2pkh: createAbsoluteRatePattern(this, 'p2pkh_addr_count'), + p2sh: createAbsoluteRatePattern(this, 'p2sh_addr_count'), + p2wpkh: createAbsoluteRatePattern(this, 'p2wpkh_addr_count'), + p2wsh: createAbsoluteRatePattern(this, 'p2wsh_addr_count'), + p2tr: createAbsoluteRatePattern(this, 'p2tr_addr_count'), + p2a: createAbsoluteRatePattern(this, 'p2a_addr_count'), }, }, scripts: { @@ -7799,6 +7811,10 @@ class BrkClient extends BrkClientBase { value: createPhsReboundThsPattern(this, 'hash_value'), }, }, + positions: { + block: createSeriesPattern18(this, 'position'), + tx: createSeriesPattern19(this, 'position'), + }, cointime: { activity: { coinblocksCreated: createBaseCumulativeSumPattern(this, 'coinblocks_created'), @@ -7868,38 +7884,38 @@ class BrkClient extends BrkClientBase { minus4: createSeriesPattern1(this, 'constant_minus_4'), }, indexes: { - address: { + addr: { p2pk33: { - identity: createSeriesPattern26(this, 'p2pk33_address_index'), - address: createSeriesPattern26(this, 'p2pk33_address'), + identity: createSeriesPattern26(this, 'p2pk33_addr_index'), + addr: createSeriesPattern26(this, 'p2pk33_addr'), }, p2pk65: { - identity: createSeriesPattern27(this, 'p2pk65_address_index'), - address: createSeriesPattern27(this, 'p2pk65_address'), + identity: createSeriesPattern27(this, 'p2pk65_addr_index'), + addr: createSeriesPattern27(this, 'p2pk65_addr'), }, p2pkh: { - identity: createSeriesPattern28(this, 'p2pkh_address_index'), - address: createSeriesPattern28(this, 'p2pkh_address'), + identity: createSeriesPattern28(this, 'p2pkh_addr_index'), + addr: createSeriesPattern28(this, 'p2pkh_addr'), }, p2sh: { - identity: createSeriesPattern29(this, 'p2sh_address_index'), - address: createSeriesPattern29(this, 'p2sh_address'), + identity: createSeriesPattern29(this, 'p2sh_addr_index'), + addr: createSeriesPattern29(this, 'p2sh_addr'), }, p2tr: { - identity: createSeriesPattern30(this, 'p2tr_address_index'), - address: createSeriesPattern30(this, 'p2tr_address'), + identity: createSeriesPattern30(this, 'p2tr_addr_index'), + addr: createSeriesPattern30(this, 'p2tr_addr'), }, p2wpkh: { - identity: createSeriesPattern31(this, 'p2wpkh_address_index'), - address: createSeriesPattern31(this, 'p2wpkh_address'), + identity: createSeriesPattern31(this, 'p2wpkh_addr_index'), + addr: createSeriesPattern31(this, 'p2wpkh_addr'), }, p2wsh: { - identity: createSeriesPattern32(this, 'p2wsh_address_index'), - address: createSeriesPattern32(this, 'p2wsh_address'), + identity: createSeriesPattern32(this, 'p2wsh_addr_index'), + addr: createSeriesPattern32(this, 'p2wsh_addr'), }, p2a: { - identity: createSeriesPattern24(this, 'p2a_address_index'), - address: createSeriesPattern24(this, 'p2a_address'), + identity: createSeriesPattern24(this, 'p2a_addr_index'), + addr: createSeriesPattern24(this, 'p2a_addr'), }, p2ms: { identity: createSeriesPattern25(this, 'p2ms_output_index'), @@ -9154,53 +9170,53 @@ class BrkClient extends BrkClientBase { over15y: createBaseCumulativeSumPattern4(this, 'utxos_over_15y_old_matured_supply'), }, }, - address: { + addr: { overAmount: { - _1sat: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1sat'), - _10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10sats'), - _100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100sats'), - _1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_sats'), - _10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_sats'), - _100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_sats'), - _1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1m_sats'), - _10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10m_sats'), - _1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1btc'), - _10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10btc'), - _100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100btc'), - _1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_btc'), - _10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_btc'), + _1sat: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1sat'), + _10sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10sats'), + _100sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100sats'), + _1kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_sats'), + _10kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_sats'), + _100kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_sats'), + _1mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1m_sats'), + _10mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10m_sats'), + _1btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1btc'), + _10btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10btc'), + _100btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100btc'), + _1kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_btc'), + _10kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_btc'), }, amountRange: { - _0sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_0sats'), - _1satTo10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1sat_to_10sats'), - _10satsTo100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10sats_to_100sats'), - _100satsTo1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100sats_to_1k_sats'), - _1kSatsTo10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_sats_to_10k_sats'), - _10kSatsTo100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_sats_to_100k_sats'), - _100kSatsTo1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100k_sats_to_1m_sats'), - _1mSatsTo10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1m_sats_to_10m_sats'), - _10mSatsTo1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10m_sats_to_1btc'), - _1btcTo10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1btc_to_10btc'), - _10btcTo100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10btc_to_100btc'), - _100btcTo1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100btc_to_1k_btc'), - _1kBtcTo10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_btc_to_10k_btc'), - _10kBtcTo100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_btc_to_100k_btc'), - over100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_btc'), + _0sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_0sats'), + _1satTo10sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1sat_to_10sats'), + _10satsTo100sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10sats_to_100sats'), + _100satsTo1kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100sats_to_1k_sats'), + _1kSatsTo10kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_sats_to_10k_sats'), + _10kSatsTo100kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_sats_to_100k_sats'), + _100kSatsTo1mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100k_sats_to_1m_sats'), + _1mSatsTo10mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1m_sats_to_10m_sats'), + _10mSatsTo1btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10m_sats_to_1btc'), + _1btcTo10btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1btc_to_10btc'), + _10btcTo100btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10btc_to_100btc'), + _100btcTo1kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_100btc_to_1k_btc'), + _1kBtcTo10kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_1k_btc_to_10k_btc'), + _10kBtcTo100kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_10k_btc_to_100k_btc'), + over100kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_btc'), }, underAmount: { - _10sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10sats'), - _100sats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100sats'), - _1kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_sats'), - _10kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_sats'), - _100kSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_sats'), - _1mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1m_sats'), - _10mSats: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10m_sats'), - _1btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1btc'), - _10btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10btc'), - _100btc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100btc'), - _1kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_btc'), - _10kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_btc'), - _100kBtc: createAddressOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_btc'), + _10sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10sats'), + _100sats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100sats'), + _1kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_sats'), + _10kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_sats'), + _100kSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_sats'), + _1mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1m_sats'), + _10mSats: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10m_sats'), + _1btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1btc'), + _10btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10btc'), + _100btc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100btc'), + _1kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_btc'), + _10kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_btc'), + _100kBtc: createAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_btc'), }, }, }, @@ -9242,8 +9258,8 @@ class BrkClient extends BrkClientBase { * * Endpoint: `GET /api/address/{address}` * - * @param {Address} address - * @returns {Promise} + * @param {Addr} address + * @returns {Promise} */ async getAddress(address) { return this.getJson(`/api/address/${address}`); @@ -9258,7 +9274,7 @@ class BrkClient extends BrkClientBase { * * Endpoint: `GET /api/address/{address}/txs` * - * @param {Address} address + * @param {Addr} address * @param {Txid=} [after_txid] - Txid to paginate from (return transactions before this one) * @returns {Promise} */ @@ -9279,7 +9295,7 @@ class BrkClient extends BrkClientBase { * * Endpoint: `GET /api/address/{address}/txs/chain` * - * @param {Address} address + * @param {Addr} address * @param {Txid=} [after_txid] - Txid to paginate from (return transactions before this one) * @returns {Promise} */ @@ -9300,7 +9316,7 @@ class BrkClient extends BrkClientBase { * * Endpoint: `GET /api/address/{address}/txs/mempool` * - * @param {Address} address + * @param {Addr} address * @returns {Promise} */ async getAddressMempoolTxs(address) { @@ -9316,7 +9332,7 @@ class BrkClient extends BrkClientBase { * * Endpoint: `GET /api/address/{address}/utxo` * - * @param {Address} address + * @param {Addr} address * @returns {Promise} */ async getAddressUtxos(address) { @@ -10142,7 +10158,7 @@ class BrkClient extends BrkClientBase { * Endpoint: `GET /api/v1/validate-address/{address}` * * @param {string} address - Bitcoin address to validate (can be any string) - * @returns {Promise} + * @returns {Promise} */ async validateAddress(address) { return this.getJson(`/api/v1/validate-address/${address}`); diff --git a/modules/brk-client/tests/basic.js b/modules/brk-client/tests/basic.js index 9112ac42d..ea49e9eec 100644 --- a/modules/brk-client/tests/basic.js +++ b/modules/brk-client/tests/basic.js @@ -6,57 +6,54 @@ console.log("Testing idiomatic API...\n"); // Test getter access (property) console.log("1. Getter access (.by.dateindex):"); -const all = await client.metrics.prices.split.close.usd.by.day1; +const all = await client.series.prices.split.close.usd.by.day1; console.log(` Total: ${all.total}, Got: ${all.data.length} items\n`); // Test dynamic access (bracket notation) console.log("2. Dynamic access (.by['dateindex']):"); -const allDynamic = await client.metrics.prices.split.close.usd.by.day1; +const allDynamic = await client.series.prices.split.close.usd.by.day1; console.log( ` Total: ${allDynamic.total}, Got: ${allDynamic.data.length} items\n`, ); // Test fetch all (explicit .fetch()) console.log("3. Explicit .fetch():"); -const allExplicit = await client.metrics.prices.split.close.usd.by.day1.fetch(); +const allExplicit = await client.series.prices.split.close.usd.by.day1.fetch(); console.log( ` Total: ${allExplicit.total}, Got: ${allExplicit.data.length} items\n`, ); // Test first(n) console.log("4. First 5 items (.first(5)):"); -const first5 = await client.metrics.prices.split.close.usd.by.day1.first(5); +const first5 = await client.series.prices.split.close.usd.by.day1.first(5); console.log( ` Total: ${first5.total}, Start: ${first5.start}, End: ${first5.end}, Got: ${first5.data.length} items\n`, ); // Test last(n) console.log("5. Last 5 items (.last(5)):"); -const last5 = await client.metrics.prices.split.close.usd.by.day1.last(5); +const last5 = await client.series.prices.split.close.usd.by.day1.last(5); console.log( ` Total: ${last5.total}, Start: ${last5.start}, End: ${last5.end}, Got: ${last5.data.length} items\n`, ); // Test slice(start, end) console.log("6. Slice 10-20 (.slice(10, 20)):"); -const sliced = await client.metrics.prices.split.close.usd.by.day1.slice( - 10, - 20, -); +const sliced = await client.series.prices.split.close.usd.by.day1.slice(10, 20); console.log( ` Total: ${sliced.total}, Start: ${sliced.start}, End: ${sliced.end}, Got: ${sliced.data.length} items\n`, ); // Test get(index) - single item console.log("7. Single item (.get(100)):"); -const single = await client.metrics.prices.split.close.usd.by.day1.get(100); +const single = await client.series.prices.split.close.usd.by.day1.get(100); console.log( ` Total: ${single.total}, Start: ${single.start}, End: ${single.end}, Got: ${single.data.length} item(s)\n`, ); // Test skip(n).take(m) chaining console.log("8. Skip and take (.skip(100).take(10)):"); -const skipTake = await client.metrics.prices.split.close.usd.by.day1 +const skipTake = await client.series.prices.split.close.usd.by.day1 .skip(100) .take(10); console.log( @@ -65,7 +62,7 @@ console.log( // Test fetchCsv console.log("9. Fetch as CSV (.last(3).fetchCsv()):"); -const csv = await client.metrics.prices.split.close.usd.by.day1 +const csv = await client.series.prices.split.close.usd.by.day1 .last(3) .fetchCsv(); console.log(` CSV preview: ${csv.substring(0, 100)}...\n`); diff --git a/modules/brk-client/tests/metric_data.js b/modules/brk-client/tests/metric_data.js index 8bf935eec..350e44625 100644 --- a/modules/brk-client/tests/metric_data.js +++ b/modules/brk-client/tests/metric_data.js @@ -11,7 +11,7 @@ console.log("Testing MetricData helpers...\n"); // Fetch a date-based metric console.log("1. Fetching price data (day1):"); -const price = await client.metrics.prices.split.close.usd.by.day1.first(5); +const price = await client.series.prices.split.close.usd.by.day1.first(5); console.log( ` Total: ${price.total}, Start: ${price.start}, End: ${price.end}`, ); @@ -97,7 +97,7 @@ if (count !== 5) throw new Error("Expected 5 iterations"); // Test with non-date-based index (height) console.log("\n11. Testing height-based metric:"); -const heightMetric = await client.metrics.prices.spot.usd.by.height.last(3); +const heightMetric = await client.series.prices.spot.usd.by.height.last(3); console.log( ` Total: ${heightMetric.total}, Start: ${heightMetric.start}, End: ${heightMetric.end}`, ); @@ -137,7 +137,7 @@ console.log(` Iterated ${heightCount} items`); // Test different date indexes console.log("\n13. Testing month1:"); const monthMetric = - await client.metrics.prices.split.close.usd.by.month1.first(3); + await client.series.prices.split.close.usd.by.month1.first(3); const monthDates = monthMetric.dates(); console.log(` First month: ${monthDates[0].toISOString()}`); // MonthIndex 0 = Jan 1, 2009 @@ -240,7 +240,7 @@ console.log(` Roundtrip day1 100: ${testDate.toISOString()} -> ${roundtrip}`); // Test slice with Date console.log("\n16. Testing slice with Date:"); -const dateSlice = await client.metrics.prices.split.close.usd.by.day1 +const dateSlice = await client.series.prices.split.close.usd.by.day1 .slice(new Date(Date.UTC(2020, 0, 1)), new Date(Date.UTC(2020, 0, 4))) .fetch(); console.log( diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 1ded9cc86..85c44fa23 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -18,7 +18,7 @@ T = TypeVar('T') # Type definitions # Bitcoin address string -Address = str +Addr = str # Satoshis Sats = int # Index within its type (e.g., 0 for first P2WPKH address) @@ -26,7 +26,7 @@ TypeIndex = int # Transaction ID (hash) Txid = str # Unified index for any address type (funded or empty) -AnyAddressIndex = TypeIndex +AnyAddrIndex = TypeIndex # Unsigned basis points stored as u16. # 1 bp = 0.0001. Range: 0–6.5535. # Use for bounded 0–1 ratios (dominance, adoption, liveliness, etc.). @@ -45,6 +45,8 @@ BasisPointsSigned16 = int BasisPointsSigned32 = int # Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis) Bitcoin = float +# Position within a .blk file, encoding file index and byte offset +BlkPosition = int # Block height Height = int # UNIX timestamp in seconds @@ -90,12 +92,12 @@ Limit = int RangeIndex = Union[int, Date, Timestamp] Day1 = int Day3 = int -EmptyAddressIndex = TypeIndex +EmptyAddrIndex = TypeIndex EmptyOutputIndex = TypeIndex Epoch = int # Fee rate in sats/vB FeeRate = float -FundedAddressIndex = TypeIndex +FundedAddrIndex = TypeIndex Halving = int # Hex-encoded string Hex = str @@ -121,27 +123,27 @@ OpReturnIndex = TypeIndex OutPoint = int # Type (P2PKH, P2WPKH, P2SH, P2TR, etc.) OutputType = Literal["p2pk65", "p2pk33", "p2pkh", "p2ms", "p2sh", "opreturn", "p2wpkh", "p2wsh", "p2tr", "p2a", "empty", "unknown"] -P2AAddressIndex = TypeIndex +P2AAddrIndex = TypeIndex U8x2 = List[int] P2ABytes = U8x2 P2MSOutputIndex = TypeIndex -P2PK33AddressIndex = TypeIndex +P2PK33AddrIndex = TypeIndex U8x33 = List[int] P2PK33Bytes = U8x33 -P2PK65AddressIndex = TypeIndex +P2PK65AddrIndex = TypeIndex U8x65 = List[int] P2PK65Bytes = U8x65 -P2PKHAddressIndex = TypeIndex +P2PKHAddrIndex = TypeIndex U8x20 = List[int] P2PKHBytes = U8x20 -P2SHAddressIndex = TypeIndex +P2SHAddrIndex = TypeIndex P2SHBytes = U8x20 -P2TRAddressIndex = TypeIndex +P2TRAddrIndex = TypeIndex U8x32 = List[int] P2TRBytes = U8x32 -P2WPKHAddressIndex = TypeIndex +P2WPKHAddrIndex = TypeIndex P2WPKHBytes = U8x20 -P2WSHAddressIndex = TypeIndex +P2WSHAddrIndex = TypeIndex P2WSHBytes = U8x32 PoolSlug = Literal["unknown", "blockfills", "ultimuspool", "terrapool", "luxor", "onethash", "btccom", "bitfarms", "huobipool", "wayicn", "canoepool", "btctop", "bitcoincom", "pool175btc", "gbminers", "axbt", "asicminer", "bitminter", "bitcoinrussia", "btcserv", "simplecoinus", "btcguild", "eligius", "ozcoin", "eclipsemc", "maxbtc", "triplemining", "coinlab", "pool50btc", "ghashio", "stminingcorp", "bitparking", "mmpool", "polmine", "kncminer", "bitalo", "f2pool", "hhtt", "megabigpower", "mtred", "nmcbit", "yourbtcnet", "givemecoins", "braiinspool", "antpool", "multicoinco", "bcpoolio", "cointerra", "kanopool", "solock", "ckpool", "nicehash", "bitclub", "bitcoinaffiliatenetwork", "btcc", "bwpool", "exxbw", "bitsolo", "bitfury", "twentyoneinc", "digitalbtc", "eightbaochi", "mybtccoinpool", "tbdice", "hashpool", "nexious", "bravomining", "hotpool", "okexpool", "bcmonster", "onehash", "bixin", "tatmaspool", "viabtc", "connectbtc", "batpool", "waterhole", "dcexploration", "dcex", "btpool", "fiftyeightcoin", "bitcoinindia", "shawnp0wers", "phashio", "rigpool", "haozhuzhu", "sevenpool", "miningkings", "hashbx", "dpool", "rawpool", "haominer", "helix", "bitcoinukraine", "poolin", "secretsuperstar", "tigerpoolnet", "sigmapoolcom", "okpooltop", "hummerpool", "tangpool", "bytepool", "spiderpool", "novablock", "miningcity", "binancepool", "minerium", "lubiancom", "okkong", "aaopool", "emcdpool", "foundryusa", "sbicrypto", "arkpool", "purebtccom", "marapool", "kucoinpool", "entrustcharitypool", "okminer", "titan", "pegapool", "btcnuggets", "cloudhashing", "digitalxmintsy", "telco214", "btcpoolparty", "multipool", "transactioncoinmining", "btcdig", "trickysbtcpool", "btcmp", "eobot", "unomp", "patels", "gogreenlight", "bitcoinindiapool", "ekanembtc", "canoe", "tiger", "onem1x", "zulupool", "secpool", "ocean", "whitepool", "wiz", "wk057", "futurebitapollosolo", "carbonnegative", "portlandhodl", "phoenix", "neopool", "maxipool", "bitfufupool", "gdpool", "miningdutch", "publicpool", "miningsquared", "innopolistech", "btclab", "parasite", "redrockpool", "est3lar"] # Transaction locktime @@ -198,10 +200,10 @@ Year1 = int Year10 = int # Aggregation dimension for querying series. Includes time-based (date, week, month, year), # block-based (height, tx_index), and address/output type indexes. -Index = Literal["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halving", "epoch", "height", "tx_index", "txin_index", "txout_index", "empty_output_index", "op_return_index", "p2a_address_index", "p2ms_output_index", "p2pk33_address_index", "p2pk65_address_index", "p2pkh_address_index", "p2sh_address_index", "p2tr_address_index", "p2wpkh_address_index", "p2wsh_address_index", "unknown_output_index", "funded_address_index", "empty_address_index"] +Index = Literal["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halving", "epoch", "height", "tx_index", "txin_index", "txout_index", "empty_output_index", "op_return_index", "p2a_addr_index", "p2ms_output_index", "p2pk33_addr_index", "p2pk65_addr_index", "p2pkh_addr_index", "p2sh_addr_index", "p2tr_addr_index", "p2wpkh_addr_index", "p2wsh_addr_index", "unknown_output_index", "funded_addr_index", "empty_addr_index"] # Hierarchical tree node for organizing series into categories TreeNode = Union[dict[str, "TreeNode"], "SeriesLeafWithSchema"] -class AddressChainStats(TypedDict): +class AddrChainStats(TypedDict): """ Address statistics on the blockchain (confirmed transactions only) @@ -222,7 +224,7 @@ class AddressChainStats(TypedDict): tx_count: int type_index: TypeIndex -class AddressMempoolStats(TypedDict): +class AddrMempoolStats(TypedDict): """ Address statistics in the mempool (unconfirmed transactions only) @@ -241,10 +243,10 @@ class AddressMempoolStats(TypedDict): spent_txo_sum: Sats tx_count: int -class AddressParam(TypedDict): - address: Address +class AddrParam(TypedDict): + address: Addr -class AddressStats(TypedDict): +class AddrStats(TypedDict): """ Address information compatible with mempool.space API format @@ -253,18 +255,18 @@ class AddressStats(TypedDict): chain_stats: Statistics for confirmed transactions on the blockchain mempool_stats: Statistics for unconfirmed transactions in the mempool """ - address: Address - chain_stats: AddressChainStats - mempool_stats: Union[AddressMempoolStats, None] + address: Addr + chain_stats: AddrChainStats + mempool_stats: Union[AddrMempoolStats, None] -class AddressTxidsParam(TypedDict): +class AddrTxidsParam(TypedDict): """ Attributes: after_txid: Txid to paginate from (return transactions before this one) """ after_txid: Union[Txid, None] -class AddressValidation(TypedDict): +class AddrValidation(TypedDict): """ Address validation result @@ -537,7 +539,7 @@ class DiskUsage(TypedDict): bitcoin_bytes: int ratio: float -class EmptyAddressData(TypedDict): +class EmptyAddrData(TypedDict): """ Data of an empty address @@ -554,7 +556,7 @@ class ErrorDetail(TypedDict): """ Attributes: type: Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" - code: Machine-readable error code (e.g. "invalid_address", "series_not_found") + code: Machine-readable error code (e.g. "invalid_addr", "series_not_found") message: Human-readable description doc_url: Link to API documentation """ @@ -566,7 +568,7 @@ class ErrorDetail(TypedDict): class ErrorBody(TypedDict): error: ErrorDetail -class FundedAddressData(TypedDict): +class FundedAddrData(TypedDict): """ Data for a funded (non-empty) address with current balance @@ -790,14 +792,14 @@ class PoolDetailInfo(TypedDict): id: Unique pool identifier name: Pool name link: Pool website URL - addresses: Known payout addresses + addrs: Known payout addresses regexes: Coinbase tag patterns (regexes) slug: URL-friendly pool identifier """ id: int name: str link: str - addresses: List[str] + addrs: List[str] regexes: List[str] slug: PoolSlug @@ -1115,7 +1117,7 @@ class Utxo(TypedDict): status: TxStatus value: Sats -class ValidateAddressParam(TypedDict): +class ValidateAddrParam(TypedDict): """ Attributes: address: Bitcoin address to validate (can be any string) @@ -1678,18 +1680,18 @@ _i20 = ('txin_index',) _i21 = ('txout_index',) _i22 = ('empty_output_index',) _i23 = ('op_return_index',) -_i24 = ('p2a_address_index',) +_i24 = ('p2a_addr_index',) _i25 = ('p2ms_output_index',) -_i26 = ('p2pk33_address_index',) -_i27 = ('p2pk65_address_index',) -_i28 = ('p2pkh_address_index',) -_i29 = ('p2sh_address_index',) -_i30 = ('p2tr_address_index',) -_i31 = ('p2wpkh_address_index',) -_i32 = ('p2wsh_address_index',) +_i26 = ('p2pk33_addr_index',) +_i27 = ('p2pk65_addr_index',) +_i28 = ('p2pkh_addr_index',) +_i29 = ('p2sh_addr_index',) +_i30 = ('p2tr_addr_index',) +_i31 = ('p2wpkh_addr_index',) +_i32 = ('p2wsh_addr_index',) _i33 = ('unknown_output_index',) -_i34 = ('funded_address_index',) -_i35 = ('empty_address_index',) +_i34 = ('funded_addr_index',) +_i35 = ('empty_addr_index',) def _ep(c: BrkClientBase, n: str, i: Index) -> SeriesEndpoint[Any]: return SeriesEndpoint(c, n, i) @@ -2006,7 +2008,7 @@ class SeriesPattern23(Generic[T]): class _SeriesPattern24By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2a_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2a_address_index') + def p2a_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2a_addr_index') class SeriesPattern24(Generic[T]): by: _SeriesPattern24By[T] @@ -2030,7 +2032,7 @@ class SeriesPattern25(Generic[T]): class _SeriesPattern26By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2pk33_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pk33_address_index') + def p2pk33_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pk33_addr_index') class SeriesPattern26(Generic[T]): by: _SeriesPattern26By[T] @@ -2042,7 +2044,7 @@ class SeriesPattern26(Generic[T]): class _SeriesPattern27By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2pk65_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pk65_address_index') + def p2pk65_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pk65_addr_index') class SeriesPattern27(Generic[T]): by: _SeriesPattern27By[T] @@ -2054,7 +2056,7 @@ class SeriesPattern27(Generic[T]): class _SeriesPattern28By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2pkh_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pkh_address_index') + def p2pkh_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2pkh_addr_index') class SeriesPattern28(Generic[T]): by: _SeriesPattern28By[T] @@ -2066,7 +2068,7 @@ class SeriesPattern28(Generic[T]): class _SeriesPattern29By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2sh_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2sh_address_index') + def p2sh_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2sh_addr_index') class SeriesPattern29(Generic[T]): by: _SeriesPattern29By[T] @@ -2078,7 +2080,7 @@ class SeriesPattern29(Generic[T]): class _SeriesPattern30By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2tr_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2tr_address_index') + def p2tr_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2tr_addr_index') class SeriesPattern30(Generic[T]): by: _SeriesPattern30By[T] @@ -2090,7 +2092,7 @@ class SeriesPattern30(Generic[T]): class _SeriesPattern31By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2wpkh_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2wpkh_address_index') + def p2wpkh_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2wpkh_addr_index') class SeriesPattern31(Generic[T]): by: _SeriesPattern31By[T] @@ -2102,7 +2104,7 @@ class SeriesPattern31(Generic[T]): class _SeriesPattern32By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def p2wsh_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2wsh_address_index') + def p2wsh_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'p2wsh_addr_index') class SeriesPattern32(Generic[T]): by: _SeriesPattern32By[T] @@ -2126,7 +2128,7 @@ class SeriesPattern33(Generic[T]): class _SeriesPattern34By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def funded_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'funded_address_index') + def funded_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'funded_addr_index') class SeriesPattern34(Generic[T]): by: _SeriesPattern34By[T] @@ -2138,7 +2140,7 @@ class SeriesPattern34(Generic[T]): class _SeriesPattern35By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def empty_address_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'empty_address_index') + def empty_addr_index(self) -> SeriesEndpoint[T]: return _ep(self._c, self._n, 'empty_addr_index') class SeriesPattern35(Generic[T]): by: _SeriesPattern35By[T] @@ -2504,12 +2506,12 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern: self.supply: DeltaHalfInToTotalPattern = DeltaHalfInToTotalPattern(client, _m(acc, 'supply')) self.unrealized: LossNetNuplProfitPattern = LossNetNuplProfitPattern(client, acc) -class AddressOutputsRealizedSupplyUnrealizedPattern: +class AddrOutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated series name.""" - self.address_count: BaseDeltaPattern = BaseDeltaPattern(client, _m(acc, 'address_count')) + self.addr_count: BaseDeltaPattern = BaseDeltaPattern(client, _m(acc, 'addr_count')) self.outputs: UnspentPattern = UnspentPattern(client, _m(acc, 'utxo_count')) self.realized: CapLossMvrvPriceProfitSoprPattern = CapLossMvrvPriceProfitSoprPattern(client, acc) self.supply: DeltaHalfTotalPattern = DeltaHalfTotalPattern(client, _m(acc, 'supply')) @@ -2520,11 +2522,11 @@ class BaseCumulativeInSumPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated series name.""" - self.base: SeriesPattern1[Sats] = SeriesPattern1(client, acc) - self.cumulative: SeriesPattern1[Sats] = SeriesPattern1(client, _m(acc, 'cumulative')) + self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')) self.in_loss: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, _m(acc, 'in_loss')) self.in_profit: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, _m(acc, 'in_profit')) - self.sum: _1m1w1y24hPattern[Sats] = _1m1w1y24hPattern(client, _m(acc, 'sum')) + self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'sum')) class BpsCentsRatioSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -3306,7 +3308,7 @@ class SeriesTree_Transactions_Volume: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.transfer_volume: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'exact_transfer_volume') + self.transfer_volume: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'transfer_volume_bis') self.output_volume: BaseCumulativeSumPattern4 = BaseCumulativeSumPattern4(client, 'output_volume') self.tx_per_sec: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'tx_per_sec') self.outputs_per_sec: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'outputs_per_sec') @@ -3369,7 +3371,7 @@ class SeriesTree_Outputs_Count: def __init__(self, client: BrkClientBase, base_path: str = ''): self.total: AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern = AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern(client, 'output_count') - self.unspent: SeriesPattern1[StoredU64] = SeriesPattern1(client, 'exact_utxo_count') + self.unspent: SeriesPattern1[StoredU64] = SeriesPattern1(client, 'utxo_count_bis') class SeriesTree_Outputs: """Series tree node.""" @@ -3379,152 +3381,152 @@ class SeriesTree_Outputs: self.spent: SeriesTree_Outputs_Spent = SeriesTree_Outputs_Spent(client) self.count: SeriesTree_Outputs_Count = SeriesTree_Outputs_Count(client) -class SeriesTree_Addresses_Raw_P2pk65: +class SeriesTree_Addrs_Raw_P2pk65: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2PK65AddressIndex] = SeriesPattern18(client, 'first_p2pk65_address_index') + self.first_index: SeriesPattern18[P2PK65AddrIndex] = SeriesPattern18(client, 'first_p2pk65_addr_index') self.bytes: SeriesPattern27[P2PK65Bytes] = SeriesPattern27(client, 'p2pk65_bytes') -class SeriesTree_Addresses_Raw_P2pk33: +class SeriesTree_Addrs_Raw_P2pk33: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2PK33AddressIndex] = SeriesPattern18(client, 'first_p2pk33_address_index') + self.first_index: SeriesPattern18[P2PK33AddrIndex] = SeriesPattern18(client, 'first_p2pk33_addr_index') self.bytes: SeriesPattern26[P2PK33Bytes] = SeriesPattern26(client, 'p2pk33_bytes') -class SeriesTree_Addresses_Raw_P2pkh: +class SeriesTree_Addrs_Raw_P2pkh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2PKHAddressIndex] = SeriesPattern18(client, 'first_p2pkh_address_index') + self.first_index: SeriesPattern18[P2PKHAddrIndex] = SeriesPattern18(client, 'first_p2pkh_addr_index') self.bytes: SeriesPattern28[P2PKHBytes] = SeriesPattern28(client, 'p2pkh_bytes') -class SeriesTree_Addresses_Raw_P2sh: +class SeriesTree_Addrs_Raw_P2sh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2SHAddressIndex] = SeriesPattern18(client, 'first_p2sh_address_index') + self.first_index: SeriesPattern18[P2SHAddrIndex] = SeriesPattern18(client, 'first_p2sh_addr_index') self.bytes: SeriesPattern29[P2SHBytes] = SeriesPattern29(client, 'p2sh_bytes') -class SeriesTree_Addresses_Raw_P2wpkh: +class SeriesTree_Addrs_Raw_P2wpkh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2WPKHAddressIndex] = SeriesPattern18(client, 'first_p2wpkh_address_index') + self.first_index: SeriesPattern18[P2WPKHAddrIndex] = SeriesPattern18(client, 'first_p2wpkh_addr_index') self.bytes: SeriesPattern31[P2WPKHBytes] = SeriesPattern31(client, 'p2wpkh_bytes') -class SeriesTree_Addresses_Raw_P2wsh: +class SeriesTree_Addrs_Raw_P2wsh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2WSHAddressIndex] = SeriesPattern18(client, 'first_p2wsh_address_index') + self.first_index: SeriesPattern18[P2WSHAddrIndex] = SeriesPattern18(client, 'first_p2wsh_addr_index') self.bytes: SeriesPattern32[P2WSHBytes] = SeriesPattern32(client, 'p2wsh_bytes') -class SeriesTree_Addresses_Raw_P2tr: +class SeriesTree_Addrs_Raw_P2tr: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2TRAddressIndex] = SeriesPattern18(client, 'first_p2tr_address_index') + self.first_index: SeriesPattern18[P2TRAddrIndex] = SeriesPattern18(client, 'first_p2tr_addr_index') self.bytes: SeriesPattern30[P2TRBytes] = SeriesPattern30(client, 'p2tr_bytes') -class SeriesTree_Addresses_Raw_P2a: +class SeriesTree_Addrs_Raw_P2a: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.first_index: SeriesPattern18[P2AAddressIndex] = SeriesPattern18(client, 'first_p2a_address_index') + self.first_index: SeriesPattern18[P2AAddrIndex] = SeriesPattern18(client, 'first_p2a_addr_index') self.bytes: SeriesPattern24[P2ABytes] = SeriesPattern24(client, 'p2a_bytes') -class SeriesTree_Addresses_Raw: +class SeriesTree_Addrs_Raw: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2pk65: SeriesTree_Addresses_Raw_P2pk65 = SeriesTree_Addresses_Raw_P2pk65(client) - self.p2pk33: SeriesTree_Addresses_Raw_P2pk33 = SeriesTree_Addresses_Raw_P2pk33(client) - self.p2pkh: SeriesTree_Addresses_Raw_P2pkh = SeriesTree_Addresses_Raw_P2pkh(client) - self.p2sh: SeriesTree_Addresses_Raw_P2sh = SeriesTree_Addresses_Raw_P2sh(client) - self.p2wpkh: SeriesTree_Addresses_Raw_P2wpkh = SeriesTree_Addresses_Raw_P2wpkh(client) - self.p2wsh: SeriesTree_Addresses_Raw_P2wsh = SeriesTree_Addresses_Raw_P2wsh(client) - self.p2tr: SeriesTree_Addresses_Raw_P2tr = SeriesTree_Addresses_Raw_P2tr(client) - self.p2a: SeriesTree_Addresses_Raw_P2a = SeriesTree_Addresses_Raw_P2a(client) + self.p2pk65: SeriesTree_Addrs_Raw_P2pk65 = SeriesTree_Addrs_Raw_P2pk65(client) + self.p2pk33: SeriesTree_Addrs_Raw_P2pk33 = SeriesTree_Addrs_Raw_P2pk33(client) + self.p2pkh: SeriesTree_Addrs_Raw_P2pkh = SeriesTree_Addrs_Raw_P2pkh(client) + self.p2sh: SeriesTree_Addrs_Raw_P2sh = SeriesTree_Addrs_Raw_P2sh(client) + self.p2wpkh: SeriesTree_Addrs_Raw_P2wpkh = SeriesTree_Addrs_Raw_P2wpkh(client) + self.p2wsh: SeriesTree_Addrs_Raw_P2wsh = SeriesTree_Addrs_Raw_P2wsh(client) + self.p2tr: SeriesTree_Addrs_Raw_P2tr = SeriesTree_Addrs_Raw_P2tr(client) + self.p2a: SeriesTree_Addrs_Raw_P2a = SeriesTree_Addrs_Raw_P2a(client) -class SeriesTree_Addresses_Indexes: +class SeriesTree_Addrs_Indexes: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2a: SeriesPattern24[AnyAddressIndex] = SeriesPattern24(client, 'any_address_index') - self.p2pk33: SeriesPattern26[AnyAddressIndex] = SeriesPattern26(client, 'any_address_index') - self.p2pk65: SeriesPattern27[AnyAddressIndex] = SeriesPattern27(client, 'any_address_index') - self.p2pkh: SeriesPattern28[AnyAddressIndex] = SeriesPattern28(client, 'any_address_index') - self.p2sh: SeriesPattern29[AnyAddressIndex] = SeriesPattern29(client, 'any_address_index') - self.p2tr: SeriesPattern30[AnyAddressIndex] = SeriesPattern30(client, 'any_address_index') - self.p2wpkh: SeriesPattern31[AnyAddressIndex] = SeriesPattern31(client, 'any_address_index') - self.p2wsh: SeriesPattern32[AnyAddressIndex] = SeriesPattern32(client, 'any_address_index') - self.funded: SeriesPattern34[FundedAddressIndex] = SeriesPattern34(client, 'funded_address_index') - self.empty: SeriesPattern35[EmptyAddressIndex] = SeriesPattern35(client, 'empty_address_index') + self.p2a: SeriesPattern24[AnyAddrIndex] = SeriesPattern24(client, 'any_addr_index') + self.p2pk33: SeriesPattern26[AnyAddrIndex] = SeriesPattern26(client, 'any_addr_index') + self.p2pk65: SeriesPattern27[AnyAddrIndex] = SeriesPattern27(client, 'any_addr_index') + self.p2pkh: SeriesPattern28[AnyAddrIndex] = SeriesPattern28(client, 'any_addr_index') + self.p2sh: SeriesPattern29[AnyAddrIndex] = SeriesPattern29(client, 'any_addr_index') + self.p2tr: SeriesPattern30[AnyAddrIndex] = SeriesPattern30(client, 'any_addr_index') + self.p2wpkh: SeriesPattern31[AnyAddrIndex] = SeriesPattern31(client, 'any_addr_index') + self.p2wsh: SeriesPattern32[AnyAddrIndex] = SeriesPattern32(client, 'any_addr_index') + self.funded: SeriesPattern34[FundedAddrIndex] = SeriesPattern34(client, 'funded_addr_index') + self.empty: SeriesPattern35[EmptyAddrIndex] = SeriesPattern35(client, 'empty_addr_index') -class SeriesTree_Addresses_Data: +class SeriesTree_Addrs_Data: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.funded: SeriesPattern34[FundedAddressData] = SeriesPattern34(client, 'funded_address_data') - self.empty: SeriesPattern35[EmptyAddressData] = SeriesPattern35(client, 'empty_address_data') + self.funded: SeriesPattern34[FundedAddrData] = SeriesPattern34(client, 'funded_addr_data') + self.empty: SeriesPattern35[EmptyAddrData] = SeriesPattern35(client, 'empty_addr_data') -class SeriesTree_Addresses_Activity: +class SeriesTree_Addrs_Activity: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'address_activity') - self.p2pk65: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk65_address_activity') - self.p2pk33: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk33_address_activity') - self.p2pkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pkh_address_activity') - self.p2sh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2sh_address_activity') - self.p2wpkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wpkh_address_activity') - self.p2wsh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wsh_address_activity') - self.p2tr: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2tr_address_activity') - self.p2a: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2a_address_activity') + self.all: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'addr_activity') + self.p2pk65: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk65_addr_activity') + self.p2pk33: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pk33_addr_activity') + self.p2pkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2pkh_addr_activity') + self.p2sh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2sh_addr_activity') + self.p2wpkh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wpkh_addr_activity') + self.p2wsh: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2wsh_addr_activity') + self.p2tr: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2tr_addr_activity') + self.p2a: BothReactivatedReceivingSendingPattern = BothReactivatedReceivingSendingPattern(client, 'p2a_addr_activity') -class SeriesTree_Addresses_New: +class SeriesTree_Addrs_New: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'new_address_count') - self.p2pk65: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pk65_new_address_count') - self.p2pk33: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pk33_new_address_count') - self.p2pkh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pkh_new_address_count') - self.p2sh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2sh_new_address_count') - self.p2wpkh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wpkh_new_address_count') - self.p2wsh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wsh_new_address_count') - self.p2tr: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2tr_new_address_count') - self.p2a: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2a_new_address_count') + self.all: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'new_addr_count') + self.p2pk65: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pk65_new_addr_count') + self.p2pk33: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pk33_new_addr_count') + self.p2pkh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2pkh_new_addr_count') + self.p2sh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2sh_new_addr_count') + self.p2wpkh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wpkh_new_addr_count') + self.p2wsh: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2wsh_new_addr_count') + self.p2tr: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2tr_new_addr_count') + self.p2a: BaseCumulativeSumPattern[StoredU64] = BaseCumulativeSumPattern(client, 'p2a_new_addr_count') -class SeriesTree_Addresses_Delta: +class SeriesTree_Addrs_Delta: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.all: AbsoluteRatePattern = AbsoluteRatePattern(client, 'address_count') - self.p2pk65: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pk65_address_count') - self.p2pk33: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pk33_address_count') - self.p2pkh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pkh_address_count') - self.p2sh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2sh_address_count') - self.p2wpkh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2wpkh_address_count') - self.p2wsh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2wsh_address_count') - self.p2tr: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2tr_address_count') - self.p2a: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2a_address_count') + self.all: AbsoluteRatePattern = AbsoluteRatePattern(client, 'addr_count') + self.p2pk65: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pk65_addr_count') + self.p2pk33: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pk33_addr_count') + self.p2pkh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2pkh_addr_count') + self.p2sh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2sh_addr_count') + self.p2wpkh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2wpkh_addr_count') + self.p2wsh: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2wsh_addr_count') + self.p2tr: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2tr_addr_count') + self.p2a: AbsoluteRatePattern = AbsoluteRatePattern(client, 'p2a_addr_count') -class SeriesTree_Addresses: +class SeriesTree_Addrs: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.raw: SeriesTree_Addresses_Raw = SeriesTree_Addresses_Raw(client) - self.indexes: SeriesTree_Addresses_Indexes = SeriesTree_Addresses_Indexes(client) - self.data: SeriesTree_Addresses_Data = SeriesTree_Addresses_Data(client) - self.funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'address_count') - self.empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'empty_address_count') - self.activity: SeriesTree_Addresses_Activity = SeriesTree_Addresses_Activity(client) - self.total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'total_address_count') - self.new: SeriesTree_Addresses_New = SeriesTree_Addresses_New(client) - self.delta: SeriesTree_Addresses_Delta = SeriesTree_Addresses_Delta(client) + self.raw: SeriesTree_Addrs_Raw = SeriesTree_Addrs_Raw(client) + self.indexes: SeriesTree_Addrs_Indexes = SeriesTree_Addrs_Indexes(client) + self.data: SeriesTree_Addrs_Data = SeriesTree_Addrs_Data(client) + self.funded: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'addr_count') + self.empty: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'empty_addr_count') + self.activity: SeriesTree_Addrs_Activity = SeriesTree_Addrs_Activity(client) + self.total: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern3(client, 'total_addr_count') + self.new: SeriesTree_Addrs_New = SeriesTree_Addrs_New(client) + self.delta: SeriesTree_Addrs_Delta = SeriesTree_Addrs_Delta(client) class SeriesTree_Scripts_Raw_Empty: """Series tree node.""" @@ -3681,6 +3683,13 @@ class SeriesTree_Mining: self.rewards: SeriesTree_Mining_Rewards = SeriesTree_Mining_Rewards(client) self.hashrate: SeriesTree_Mining_Hashrate = SeriesTree_Mining_Hashrate(client) +class SeriesTree_Positions: + """Series tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.block: SeriesPattern18[BlkPosition] = SeriesPattern18(client, 'position') + self.tx: SeriesPattern19[BlkPosition] = SeriesPattern19(client, 'position') + class SeriesTree_Cointime_Activity: """Series tree node.""" @@ -3783,102 +3792,102 @@ class SeriesTree_Constants: self.minus_3: SeriesPattern1[StoredI8] = SeriesPattern1(client, 'constant_minus_3') self.minus_4: SeriesPattern1[StoredI8] = SeriesPattern1(client, 'constant_minus_4') -class SeriesTree_Indexes_Address_P2pk33: +class SeriesTree_Indexes_Addr_P2pk33: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern26[P2PK33AddressIndex] = SeriesPattern26(client, 'p2pk33_address_index') - self.address: SeriesPattern26[Address] = SeriesPattern26(client, 'p2pk33_address') + self.identity: SeriesPattern26[P2PK33AddrIndex] = SeriesPattern26(client, 'p2pk33_addr_index') + self.addr: SeriesPattern26[Addr] = SeriesPattern26(client, 'p2pk33_addr') -class SeriesTree_Indexes_Address_P2pk65: +class SeriesTree_Indexes_Addr_P2pk65: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern27[P2PK65AddressIndex] = SeriesPattern27(client, 'p2pk65_address_index') - self.address: SeriesPattern27[Address] = SeriesPattern27(client, 'p2pk65_address') + self.identity: SeriesPattern27[P2PK65AddrIndex] = SeriesPattern27(client, 'p2pk65_addr_index') + self.addr: SeriesPattern27[Addr] = SeriesPattern27(client, 'p2pk65_addr') -class SeriesTree_Indexes_Address_P2pkh: +class SeriesTree_Indexes_Addr_P2pkh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern28[P2PKHAddressIndex] = SeriesPattern28(client, 'p2pkh_address_index') - self.address: SeriesPattern28[Address] = SeriesPattern28(client, 'p2pkh_address') + self.identity: SeriesPattern28[P2PKHAddrIndex] = SeriesPattern28(client, 'p2pkh_addr_index') + self.addr: SeriesPattern28[Addr] = SeriesPattern28(client, 'p2pkh_addr') -class SeriesTree_Indexes_Address_P2sh: +class SeriesTree_Indexes_Addr_P2sh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern29[P2SHAddressIndex] = SeriesPattern29(client, 'p2sh_address_index') - self.address: SeriesPattern29[Address] = SeriesPattern29(client, 'p2sh_address') + self.identity: SeriesPattern29[P2SHAddrIndex] = SeriesPattern29(client, 'p2sh_addr_index') + self.addr: SeriesPattern29[Addr] = SeriesPattern29(client, 'p2sh_addr') -class SeriesTree_Indexes_Address_P2tr: +class SeriesTree_Indexes_Addr_P2tr: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern30[P2TRAddressIndex] = SeriesPattern30(client, 'p2tr_address_index') - self.address: SeriesPattern30[Address] = SeriesPattern30(client, 'p2tr_address') + self.identity: SeriesPattern30[P2TRAddrIndex] = SeriesPattern30(client, 'p2tr_addr_index') + self.addr: SeriesPattern30[Addr] = SeriesPattern30(client, 'p2tr_addr') -class SeriesTree_Indexes_Address_P2wpkh: +class SeriesTree_Indexes_Addr_P2wpkh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern31[P2WPKHAddressIndex] = SeriesPattern31(client, 'p2wpkh_address_index') - self.address: SeriesPattern31[Address] = SeriesPattern31(client, 'p2wpkh_address') + self.identity: SeriesPattern31[P2WPKHAddrIndex] = SeriesPattern31(client, 'p2wpkh_addr_index') + self.addr: SeriesPattern31[Addr] = SeriesPattern31(client, 'p2wpkh_addr') -class SeriesTree_Indexes_Address_P2wsh: +class SeriesTree_Indexes_Addr_P2wsh: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern32[P2WSHAddressIndex] = SeriesPattern32(client, 'p2wsh_address_index') - self.address: SeriesPattern32[Address] = SeriesPattern32(client, 'p2wsh_address') + self.identity: SeriesPattern32[P2WSHAddrIndex] = SeriesPattern32(client, 'p2wsh_addr_index') + self.addr: SeriesPattern32[Addr] = SeriesPattern32(client, 'p2wsh_addr') -class SeriesTree_Indexes_Address_P2a: +class SeriesTree_Indexes_Addr_P2a: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: SeriesPattern24[P2AAddressIndex] = SeriesPattern24(client, 'p2a_address_index') - self.address: SeriesPattern24[Address] = SeriesPattern24(client, 'p2a_address') + self.identity: SeriesPattern24[P2AAddrIndex] = SeriesPattern24(client, 'p2a_addr_index') + self.addr: SeriesPattern24[Addr] = SeriesPattern24(client, 'p2a_addr') -class SeriesTree_Indexes_Address_P2ms: +class SeriesTree_Indexes_Addr_P2ms: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.identity: SeriesPattern25[P2MSOutputIndex] = SeriesPattern25(client, 'p2ms_output_index') -class SeriesTree_Indexes_Address_Empty: +class SeriesTree_Indexes_Addr_Empty: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.identity: SeriesPattern22[EmptyOutputIndex] = SeriesPattern22(client, 'empty_output_index') -class SeriesTree_Indexes_Address_Unknown: +class SeriesTree_Indexes_Addr_Unknown: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.identity: SeriesPattern33[UnknownOutputIndex] = SeriesPattern33(client, 'unknown_output_index') -class SeriesTree_Indexes_Address_OpReturn: +class SeriesTree_Indexes_Addr_OpReturn: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.identity: SeriesPattern23[OpReturnIndex] = SeriesPattern23(client, 'op_return_index') -class SeriesTree_Indexes_Address: +class SeriesTree_Indexes_Addr: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2pk33: SeriesTree_Indexes_Address_P2pk33 = SeriesTree_Indexes_Address_P2pk33(client) - self.p2pk65: SeriesTree_Indexes_Address_P2pk65 = SeriesTree_Indexes_Address_P2pk65(client) - self.p2pkh: SeriesTree_Indexes_Address_P2pkh = SeriesTree_Indexes_Address_P2pkh(client) - self.p2sh: SeriesTree_Indexes_Address_P2sh = SeriesTree_Indexes_Address_P2sh(client) - self.p2tr: SeriesTree_Indexes_Address_P2tr = SeriesTree_Indexes_Address_P2tr(client) - self.p2wpkh: SeriesTree_Indexes_Address_P2wpkh = SeriesTree_Indexes_Address_P2wpkh(client) - self.p2wsh: SeriesTree_Indexes_Address_P2wsh = SeriesTree_Indexes_Address_P2wsh(client) - self.p2a: SeriesTree_Indexes_Address_P2a = SeriesTree_Indexes_Address_P2a(client) - self.p2ms: SeriesTree_Indexes_Address_P2ms = SeriesTree_Indexes_Address_P2ms(client) - self.empty: SeriesTree_Indexes_Address_Empty = SeriesTree_Indexes_Address_Empty(client) - self.unknown: SeriesTree_Indexes_Address_Unknown = SeriesTree_Indexes_Address_Unknown(client) - self.op_return: SeriesTree_Indexes_Address_OpReturn = SeriesTree_Indexes_Address_OpReturn(client) + self.p2pk33: SeriesTree_Indexes_Addr_P2pk33 = SeriesTree_Indexes_Addr_P2pk33(client) + self.p2pk65: SeriesTree_Indexes_Addr_P2pk65 = SeriesTree_Indexes_Addr_P2pk65(client) + self.p2pkh: SeriesTree_Indexes_Addr_P2pkh = SeriesTree_Indexes_Addr_P2pkh(client) + self.p2sh: SeriesTree_Indexes_Addr_P2sh = SeriesTree_Indexes_Addr_P2sh(client) + self.p2tr: SeriesTree_Indexes_Addr_P2tr = SeriesTree_Indexes_Addr_P2tr(client) + self.p2wpkh: SeriesTree_Indexes_Addr_P2wpkh = SeriesTree_Indexes_Addr_P2wpkh(client) + self.p2wsh: SeriesTree_Indexes_Addr_P2wsh = SeriesTree_Indexes_Addr_P2wsh(client) + self.p2a: SeriesTree_Indexes_Addr_P2a = SeriesTree_Indexes_Addr_P2a(client) + self.p2ms: SeriesTree_Indexes_Addr_P2ms = SeriesTree_Indexes_Addr_P2ms(client) + self.empty: SeriesTree_Indexes_Addr_Empty = SeriesTree_Indexes_Addr_Empty(client) + self.unknown: SeriesTree_Indexes_Addr_Unknown = SeriesTree_Indexes_Addr_Unknown(client) + self.op_return: SeriesTree_Indexes_Addr_OpReturn = SeriesTree_Indexes_Addr_OpReturn(client) class SeriesTree_Indexes_Height: """Series tree node.""" @@ -4040,7 +4049,7 @@ class SeriesTree_Indexes: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.address: SeriesTree_Indexes_Address = SeriesTree_Indexes_Address(client) + self.addr: SeriesTree_Indexes_Addr = SeriesTree_Indexes_Addr(client) self.height: SeriesTree_Indexes_Height = SeriesTree_Indexes_Height(client) self.epoch: SeriesTree_Indexes_Epoch = SeriesTree_Indexes_Epoch(client) self.halving: SeriesTree_Indexes_Halving = SeriesTree_Indexes_Halving(client) @@ -5622,76 +5631,76 @@ class SeriesTree_Cohorts_Utxo: self.profitability: SeriesTree_Cohorts_Utxo_Profitability = SeriesTree_Cohorts_Utxo_Profitability(client) self.matured: SeriesTree_Cohorts_Utxo_Matured = SeriesTree_Cohorts_Utxo_Matured(client) -class SeriesTree_Cohorts_Address_OverAmount: +class SeriesTree_Cohorts_Addr_OverAmount: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1sat: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1sat') - self._10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10sats') - self._100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100sats') - self._1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_sats') - self._10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_sats') - self._100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_sats') - self._1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1m_sats') - self._10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10m_sats') - self._1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1btc') - self._10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10btc') - self._100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100btc') - self._1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_btc') - self._10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_btc') + self._1sat: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1sat') + self._10sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10sats') + self._100sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100sats') + self._1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_sats') + self._10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_sats') + self._100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_sats') + self._1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1m_sats') + self._10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10m_sats') + self._1btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1btc') + self._10btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10btc') + self._100btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100btc') + self._1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_btc') + self._10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_btc') -class SeriesTree_Cohorts_Address_AmountRange: +class SeriesTree_Cohorts_Addr_AmountRange: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_0sats') - self._1sat_to_10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1sat_to_10sats') - self._10sats_to_100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10sats_to_100sats') - self._100sats_to_1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100sats_to_1k_sats') - self._1k_sats_to_10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_sats_to_10k_sats') - self._10k_sats_to_100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_sats_to_100k_sats') - self._100k_sats_to_1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100k_sats_to_1m_sats') - self._1m_sats_to_10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1m_sats_to_10m_sats') - self._10m_sats_to_1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10m_sats_to_1btc') - self._1btc_to_10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1btc_to_10btc') - self._10btc_to_100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10btc_to_100btc') - self._100btc_to_1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100btc_to_1k_btc') - self._1k_btc_to_10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_btc_to_10k_btc') - self._10k_btc_to_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_btc_to_100k_btc') - self.over_100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_btc') + self._0sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_0sats') + self._1sat_to_10sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1sat_to_10sats') + self._10sats_to_100sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10sats_to_100sats') + self._100sats_to_1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100sats_to_1k_sats') + self._1k_sats_to_10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_sats_to_10k_sats') + self._10k_sats_to_100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_sats_to_100k_sats') + self._100k_sats_to_1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100k_sats_to_1m_sats') + self._1m_sats_to_10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1m_sats_to_10m_sats') + self._10m_sats_to_1btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10m_sats_to_1btc') + self._1btc_to_10btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1btc_to_10btc') + self._10btc_to_100btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10btc_to_100btc') + self._100btc_to_1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_100btc_to_1k_btc') + self._1k_btc_to_10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_1k_btc_to_10k_btc') + self._10k_btc_to_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_10k_btc_to_100k_btc') + self.over_100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_btc') -class SeriesTree_Cohorts_Address_UnderAmount: +class SeriesTree_Cohorts_Addr_UnderAmount: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._10sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10sats') - self._100sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100sats') - self._1k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_sats') - self._10k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_sats') - self._100k_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_sats') - self._1m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1m_sats') - self._10m_sats: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10m_sats') - self._1btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1btc') - self._10btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10btc') - self._100btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100btc') - self._1k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_btc') - self._10k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_btc') - self._100k_btc: AddressOutputsRealizedSupplyUnrealizedPattern = AddressOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_btc') + self._10sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10sats') + self._100sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100sats') + self._1k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_sats') + self._10k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_sats') + self._100k_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_sats') + self._1m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1m_sats') + self._10m_sats: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10m_sats') + self._1btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1btc') + self._10btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10btc') + self._100btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100btc') + self._1k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_btc') + self._10k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_btc') + self._100k_btc: AddrOutputsRealizedSupplyUnrealizedPattern = AddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_btc') -class SeriesTree_Cohorts_Address: +class SeriesTree_Cohorts_Addr: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.over_amount: SeriesTree_Cohorts_Address_OverAmount = SeriesTree_Cohorts_Address_OverAmount(client) - self.amount_range: SeriesTree_Cohorts_Address_AmountRange = SeriesTree_Cohorts_Address_AmountRange(client) - self.under_amount: SeriesTree_Cohorts_Address_UnderAmount = SeriesTree_Cohorts_Address_UnderAmount(client) + self.over_amount: SeriesTree_Cohorts_Addr_OverAmount = SeriesTree_Cohorts_Addr_OverAmount(client) + self.amount_range: SeriesTree_Cohorts_Addr_AmountRange = SeriesTree_Cohorts_Addr_AmountRange(client) + self.under_amount: SeriesTree_Cohorts_Addr_UnderAmount = SeriesTree_Cohorts_Addr_UnderAmount(client) class SeriesTree_Cohorts: """Series tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.utxo: SeriesTree_Cohorts_Utxo = SeriesTree_Cohorts_Utxo(client) - self.address: SeriesTree_Cohorts_Address = SeriesTree_Cohorts_Address(client) + self.addr: SeriesTree_Cohorts_Addr = SeriesTree_Cohorts_Addr(client) class SeriesTree: """Series tree node.""" @@ -5701,9 +5710,10 @@ class SeriesTree: self.transactions: SeriesTree_Transactions = SeriesTree_Transactions(client) self.inputs: SeriesTree_Inputs = SeriesTree_Inputs(client) self.outputs: SeriesTree_Outputs = SeriesTree_Outputs(client) - self.addresses: SeriesTree_Addresses = SeriesTree_Addresses(client) + self.addrs: SeriesTree_Addrs = SeriesTree_Addrs(client) self.scripts: SeriesTree_Scripts = SeriesTree_Scripts(client) self.mining: SeriesTree_Mining = SeriesTree_Mining(client) + self.positions: SeriesTree_Positions = SeriesTree_Positions(client) self.cointime: SeriesTree_Cointime = SeriesTree_Cointime(client) self.constants: SeriesTree_Constants = SeriesTree_Constants(client) self.indexes: SeriesTree_Indexes = SeriesTree_Indexes(client) @@ -5741,18 +5751,18 @@ class BrkClient(BrkClientBase): "txout_index", "empty_output_index", "op_return_index", - "p2a_address_index", + "p2a_addr_index", "p2ms_output_index", - "p2pk33_address_index", - "p2pk65_address_index", - "p2pkh_address_index", - "p2sh_address_index", - "p2tr_address_index", - "p2wpkh_address_index", - "p2wsh_address_index", + "p2pk33_addr_index", + "p2pk65_addr_index", + "p2pkh_addr_index", + "p2sh_addr_index", + "p2tr_addr_index", + "p2wpkh_addr_index", + "p2wsh_addr_index", "unknown_output_index", - "funded_address_index", - "empty_address_index" + "funded_addr_index", + "empty_addr_index" ] POOL_ID_TO_POOL_NAME = { @@ -6897,7 +6907,7 @@ class BrkClient(BrkClientBase): Endpoint: `GET /api.json`""" return self.get_json('/api.json') - def get_address(self, address: Address) -> AddressStats: + def get_address(self, address: Addr) -> AddrStats: """Address information. Retrieve address information including balance and transaction counts. Supports all standard Bitcoin address types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR). @@ -6907,7 +6917,7 @@ class BrkClient(BrkClientBase): Endpoint: `GET /api/address/{address}`""" return self.get_json(f'/api/address/{address}') - def get_address_txs(self, address: Address, after_txid: Optional[Txid] = None) -> List[Transaction]: + def get_address_txs(self, address: Addr, after_txid: Optional[Txid] = None) -> List[Transaction]: """Address transactions. Get transaction history for an address, sorted with newest first. Returns up to 50 mempool transactions plus the first 25 confirmed transactions. Use ?after_txid= for pagination. @@ -6921,7 +6931,7 @@ class BrkClient(BrkClientBase): path = f'/api/address/{address}/txs{"?" + query if query else ""}' return self.get_json(path) - def get_address_confirmed_txs(self, address: Address, after_txid: Optional[Txid] = None) -> List[Transaction]: + def get_address_confirmed_txs(self, address: Addr, after_txid: Optional[Txid] = None) -> List[Transaction]: """Address confirmed transactions. Get confirmed transactions for an address, 25 per page. Use ?after_txid= for pagination. @@ -6935,7 +6945,7 @@ class BrkClient(BrkClientBase): path = f'/api/address/{address}/txs/chain{"?" + query if query else ""}' return self.get_json(path) - def get_address_mempool_txs(self, address: Address) -> List[Txid]: + def get_address_mempool_txs(self, address: Addr) -> List[Txid]: """Address mempool transactions. Get unconfirmed transaction IDs for an address from the mempool (up to 50). @@ -6945,7 +6955,7 @@ class BrkClient(BrkClientBase): Endpoint: `GET /api/address/{address}/txs/mempool`""" return self.get_json(f'/api/address/{address}/txs/mempool') - def get_address_utxos(self, address: Address) -> List[Utxo]: + def get_address_utxos(self, address: Addr) -> List[Utxo]: """Address UTXOs. Get unspent transaction outputs (UTXOs) for an address. Returns txid, vout, value, and confirmation status for each UTXO. @@ -7467,7 +7477,7 @@ class BrkClient(BrkClientBase): Endpoint: `GET /api/v1/mining/reward-stats/{block_count}`""" return self.get_json(f'/api/v1/mining/reward-stats/{block_count}') - def validate_address(self, address: str) -> AddressValidation: + def validate_address(self, address: str) -> AddrValidation: """Validate address. Validate a Bitcoin address and get information about its type and scriptPubKey. diff --git a/website/scripts/options/cointime.js b/website/scripts/options/cointime.js index b79e2bde7..fcb509a86 100644 --- a/website/scripts/options/cointime.js +++ b/website/scripts/options/cointime.js @@ -18,7 +18,6 @@ export function createCointimeSection() { adjusted, reserveRisk, value, - coinblocksDestroyed, } = cointime; const { all } = cohorts.utxo; @@ -99,7 +98,7 @@ export function createCointimeSection() { const coinblocks = /** @type {const} */ ([ { - pattern: coinblocksDestroyed, + pattern: activity.coinblocksDestroyed, name: "Destroyed", title: "Coinblocks Destroyed", color: colors.destroyed, diff --git a/website/scripts/options/distribution/activity.js b/website/scripts/options/distribution/activity.js index 57f85967f..8701014a7 100644 --- a/website/scripts/options/distribution/activity.js +++ b/website/scripts/options/distribution/activity.js @@ -21,7 +21,7 @@ import { colors } from "../../utils/colors.js"; // ============================================================================ /** - * @param {{ sent: Brk.BaseCumulativeInSumPattern, coindaysDestroyed: Brk.BaseCumulativeSumPattern }} activity + * @param {{ transferVolume: TransferVolumePattern, coindaysDestroyed: CountPattern }} activity * @param {Color} color * @param {(name: string) => string} title * @returns {PartialOptionsTree} @@ -35,18 +35,18 @@ function volumeAndCoinsTree(activity, color, title) { name: "Sum", title: title("Sent Volume"), bottom: [ - line({ series: activity.sent.base, name: "Sum", color, unit: Unit.sats }), - line({ series: activity.sent.sum._24h, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }), - line({ series: activity.sent.sum._1w, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }), - line({ series: activity.sent.sum._1m, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }), - line({ series: activity.sent.sum._1y, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }), + line({ series: activity.transferVolume.base.sats, name: "Sum", color, unit: Unit.sats }), + line({ series: activity.transferVolume.sum._24h.sats, name: "24h", color: colors.time._24h, unit: Unit.sats, defaultActive: false }), + line({ series: activity.transferVolume.sum._1w.sats, name: "1w", color: colors.time._1w, unit: Unit.sats, defaultActive: false }), + line({ series: activity.transferVolume.sum._1m.sats, name: "1m", color: colors.time._1m, unit: Unit.sats, defaultActive: false }), + line({ series: activity.transferVolume.sum._1y.sats, name: "1y", color: colors.time._1y, unit: Unit.sats, defaultActive: false }), ], }, { name: "Cumulative", title: title("Sent Volume (Total)"), bottom: [ - line({ series: activity.sent.cumulative, name: "All-time", color, unit: Unit.sats }), + line({ series: activity.transferVolume.cumulative.sats, name: "All-time", color, unit: Unit.sats }), ], }, ], @@ -79,7 +79,7 @@ function volumeAndCoinsTree(activity, color, title) { /** * Sent in profit/loss breakdown tree (shared by full and mid-level activity) - * @param {Brk.BaseCumulativeInSumPattern} sent + * @param {TransferVolumePattern} sent * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -176,7 +176,7 @@ function sentProfitLossTree(sent, title) { /** * Volume and coins tree with coinyears, dormancy, and sent in profit/loss (All/STH/LTH) - * @param {Brk.CoindaysCoinyearsDormancySentPattern} activity + * @param {FullActivityPattern} activity * @param {Color} color * @param {(name: string) => string} title * @returns {PartialOptionsTree} @@ -184,7 +184,7 @@ function sentProfitLossTree(sent, title) { function fullVolumeTree(activity, color, title) { return [ ...volumeAndCoinsTree(activity, color, title), - ...sentProfitLossTree(activity.sent, title), + ...sentProfitLossTree(activity.transferVolume, title), { name: "Coinyears Destroyed", title: title("Coinyears Destroyed"), @@ -203,7 +203,7 @@ function fullVolumeTree(activity, color, title) { // ============================================================================ /** - * @param {Brk._1m1w1y24hPattern} ratio + * @param {RollingWindowPattern} ratio * @param {(name: string) => string} title * @param {string} [prefix] * @returns {PartialOptionsTree} @@ -248,7 +248,7 @@ function singleRollingSoprTree(ratio, title, prefix = "") { // ============================================================================ /** - * @param {Brk._1m1w1y24hPattern6} sellSideRisk + * @param {SellSideRiskPattern} sellSideRisk * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -292,8 +292,8 @@ function singleSellSideRiskTree(sellSideRisk, title) { // ============================================================================ /** - * @param {Brk.BaseCumulativeSumPattern} valueCreated - * @param {Brk.BaseCumulativeSumPattern} valueDestroyed + * @param {CountPattern} valueCreated + * @param {CountPattern} valueDestroyed * @param {(name: string) => string} title * @param {string} [prefix] * @returns {PartialOptionsTree} @@ -370,10 +370,10 @@ function singleRollingValueTree(valueCreated, valueDestroyed, title, prefix = "" /** * Value section for cohorts with full realized (flows + breakdown) - * @param {Brk.BaseCumulativeDistributionRelSumValuePattern} profit - * @param {Brk.BaseCapitulationCumulativeNegativeRelSumValuePattern} loss - * @param {Brk.BaseCumulativeSumPattern} valueCreated - * @param {Brk.BaseCumulativeSumPattern} valueDestroyed + * @param {ProfitDetailPattern} profit + * @param {LossDetailPattern} loss + * @param {CountPattern} valueCreated + * @param {CountPattern} valueDestroyed * @param {AnyFetchedSeriesBlueprint[]} extraValueSeries * @param {PartialOptionsTree} rollingTree * @param {(name: string) => string} title @@ -428,8 +428,8 @@ function fullValueSection(profit, loss, valueCreated, valueDestroyed, extraValue /** * Simple value section (created & destroyed + rolling) - * @param {Brk.BaseCumulativeSumPattern} valueCreated - * @param {Brk.BaseCumulativeSumPattern} valueDestroyed + * @param {CountPattern} valueCreated + * @param {CountPattern} valueDestroyed * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -551,7 +551,7 @@ export function createActivitySectionWithActivity({ cohort, title }) { name: "Activity", tree: [ ...volumeAndCoinsTree(tree.activity, color, title), - ...sentProfitLossTree(tree.activity.sent, title), + ...sentProfitLossTree(tree.activity.transferVolume, title), { name: "SOPR", title: title("SOPR (24h)"), @@ -564,7 +564,7 @@ export function createActivitySectionWithActivity({ cohort, title }) { /** * Minimal activity section for cohorts without activity field (value only) - * @param {{ cohort: CohortBasicWithMarketCap | CohortBasicWithoutMarketCap | CohortWithoutRelative | CohortAddress | AddressCohortObject, title: (name: string) => string }} args + * @param {{ cohort: CohortBasicWithMarketCap | CohortBasicWithoutMarketCap | CohortWithoutRelative | CohortAddr | AddrCohortObject, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createActivitySectionMinimal({ cohort, title }) { @@ -734,7 +734,7 @@ export function createGroupedActivitySectionWithAdjusted({ list, all, title }) { name: "Volume", title: title("Sent Volume"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [ - line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }), + line({ series: tree.activity.transferVolume.sum._24h.sats, name, color, unit: Unit.sats }), ]), }, { @@ -860,7 +860,7 @@ export function createGroupedActivitySection({ list, all, title }) { name: "Volume", title: title("Sent Volume"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [ - line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }), + line({ series: tree.activity.transferVolume.sum._24h.sats, name, color, unit: Unit.sats }), ]), }, { @@ -937,7 +937,7 @@ export function createGroupedActivitySectionWithActivity({ list, all, title }) { name: "Volume", title: title("Sent Volume"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => [ - line({ series: tree.activity.sent.sum._24h, name, color, unit: Unit.sats }), + line({ series: tree.activity.transferVolume.sum._24h.sats, name, color, unit: Unit.sats }), ]), }, { @@ -967,7 +967,7 @@ export function createGroupedActivitySectionWithActivity({ list, all, title }) { /** * Grouped minimal activity (value only, no activity field) - * @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative | CohortAddress | AddressCohortObject)[], all: CohortAll, title: (name: string) => string }} args + * @param {{ list: readonly (UtxoCohortObject | CohortWithoutRelative | CohortAddr | AddrCohortObject)[], all: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createGroupedActivitySectionMinimal({ list, all, title }) { diff --git a/website/scripts/options/distribution/data.js b/website/scripts/options/distribution/data.js index 2cc7af3c2..0bb21f714 100644 --- a/website/scripts/options/distribution/data.js +++ b/website/scripts/options/distribution/data.js @@ -20,8 +20,8 @@ const isAddressable = (key) => export function buildCohortData() { const utxoCohorts = brk.series.cohorts.utxo; - const addressCohorts = brk.series.cohorts.address; - const { addresses } = brk.series; + const addressCohorts = brk.series.cohorts.addr; + const { addrs } = brk.series; const { TERM_NAMES, EPOCH_NAMES, @@ -44,8 +44,8 @@ export function buildCohortData() { color: colors.bitcoin, tree: utxoCohorts.all, addressCount: { - inner: addresses.funded.all, - delta: addresses.delta.all, + inner: addrs.funded.all, + delta: addrs.delta.all, }, }; @@ -113,7 +113,7 @@ export function buildCohortData() { title: `Addresses ${names.long}`, color: colors.at(i, arr.length), tree: cohort, - addressCount: cohort.addressCount, + addressCount: cohort.addrCount, }; }, ); @@ -135,7 +135,7 @@ export function buildCohortData() { title: `Addresses ${names.long}`, color: colors.at(i, arr.length), tree: cohort, - addressCount: cohort.addressCount, + addressCount: cohort.addrCount, }; }, ); @@ -157,7 +157,7 @@ export function buildCohortData() { title: `Addresses ${names.long}`, color: colors.at(i, arr.length), tree: cohort, - addressCount: cohort.addressCount, + addressCount: cohort.addrCount, }; }, ); @@ -170,8 +170,8 @@ export function buildCohortData() { color: colors.at(i, arr.length), tree: utxoCohorts.type[key], addressCount: { - inner: addresses.funded[key], - delta: addresses.delta[key], + inner: addrs.funded[key], + delta: addrs.delta[key], }, }; }); @@ -204,11 +204,13 @@ export function buildCohortData() { }), ); - const profitabilityProfit = entries(PROFIT_NAMES).map(([key, names], i, arr) => ({ - name: names.short, - color: colors.at(i, arr.length), - pattern: profit[key], - })); + const profitabilityProfit = entries(PROFIT_NAMES).map( + ([key, names], i, arr) => ({ + name: names.short, + color: colors.at(i, arr.length), + pattern: profit[key], + }), + ); const profitabilityLoss = entries(LOSS_NAMES).map(([key, names], i, arr) => ({ name: names.short, diff --git a/website/scripts/options/distribution/holdings.js b/website/scripts/options/distribution/holdings.js index 412450221..60c4a3857 100644 --- a/website/scripts/options/distribution/holdings.js +++ b/website/scripts/options/distribution/holdings.js @@ -2,9 +2,9 @@ * Holdings section builders * * Supply pattern capabilities by cohort type: - * - DeltaHalfInRelTotalPattern2 (STH/LTH): inProfit + inLoss + relToCirculating + relToOwn - * - SeriesTree_Cohorts_Utxo_All_Supply (All): inProfit + inLoss + relToOwn (no relToCirculating) - * - DeltaHalfInRelTotalPattern (AgeRange/MaxAge/Epoch): inProfit + inLoss + relToCirculating (no relToOwn) + * - DeltaHalfInRelTotalPattern2 (STH/LTH): inProfit + inLoss + toCirculating + toOwn + * - SeriesTree_Cohorts_Utxo_All_Supply (All): inProfit + inLoss + toOwn (no toCirculating) + * - DeltaHalfInRelTotalPattern (AgeRange/MaxAge/Epoch): inProfit + inLoss + toCirculating (no toOwn) * - DeltaHalfInTotalPattern2 (Type.*): inProfit + inLoss (no rel) * - DeltaHalfTotalPattern (Empty/UtxoAmount/AddrAmount): total + half only */ @@ -74,40 +74,40 @@ function fullSupplySeries(supply) { /** * % of Own Supply series (profit/loss relative to own supply) - * @param {{ inProfit: { relToOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } }, inLoss: { relToOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } } }} supply + * @param {{ inProfit: { toOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } }, inLoss: { toOwn: { percent: AnySeriesPattern, ratio: AnySeriesPattern } } }} supply * @returns {AnyFetchedSeriesBlueprint[]} */ function ownSupplyPctSeries(supply) { return [ - line({ series: supply.inProfit.relToOwn.percent, name: "In Profit", color: colors.profit, unit: Unit.pctOwn }), - line({ series: supply.inLoss.relToOwn.percent, name: "In Loss", color: colors.loss, unit: Unit.pctOwn }), - line({ series: supply.inProfit.relToOwn.ratio, name: "In Profit", color: colors.profit, unit: Unit.ratio }), - line({ series: supply.inLoss.relToOwn.ratio, name: "In Loss", color: colors.loss, unit: Unit.ratio }), + line({ series: supply.inProfit.toOwn.percent, name: "In Profit", color: colors.profit, unit: Unit.pctOwn }), + line({ series: supply.inLoss.toOwn.percent, name: "In Loss", color: colors.loss, unit: Unit.pctOwn }), + line({ series: supply.inProfit.toOwn.ratio, name: "In Profit", color: colors.profit, unit: Unit.ratio }), + line({ series: supply.inLoss.toOwn.ratio, name: "In Loss", color: colors.loss, unit: Unit.ratio }), ...priceLines({ numbers: [100, 50, 0], unit: Unit.pctOwn }), ]; } /** * % of Circulating Supply series (total, profit, loss) - * @param {{ relToCirculating: { percent: AnySeriesPattern }, inProfit: { relToCirculating: { percent: AnySeriesPattern } }, inLoss: { relToCirculating: { percent: AnySeriesPattern } } }} supply + * @param {{ toCirculating: { percent: AnySeriesPattern }, inProfit: { toCirculating: { percent: AnySeriesPattern } }, inLoss: { toCirculating: { percent: AnySeriesPattern } } }} supply * @returns {AnyFetchedSeriesBlueprint[]} */ function circulatingSupplyPctSeries(supply) { return [ line({ - series: supply.relToCirculating.percent, + series: supply.toCirculating.percent, name: "Total", color: colors.default, unit: Unit.pctSupply, }), line({ - series: supply.inProfit.relToCirculating.percent, + series: supply.inProfit.toCirculating.percent, name: "In Profit", color: colors.profit, unit: Unit.pctSupply, }), line({ - series: supply.inLoss.relToCirculating.percent, + series: supply.inLoss.toCirculating.percent, name: "In Loss", color: colors.loss, unit: Unit.pctSupply, @@ -117,25 +117,25 @@ function circulatingSupplyPctSeries(supply) { /** * Ratio of Circulating Supply series (total, profit, loss) - * @param {{ relToCirculating: { ratio: AnySeriesPattern }, inProfit: { relToCirculating: { ratio: AnySeriesPattern } }, inLoss: { relToCirculating: { ratio: AnySeriesPattern } } }} supply + * @param {{ toCirculating: { ratio: AnySeriesPattern }, inProfit: { toCirculating: { ratio: AnySeriesPattern } }, inLoss: { toCirculating: { ratio: AnySeriesPattern } } }} supply * @returns {AnyFetchedSeriesBlueprint[]} */ function circulatingSupplyRatioSeries(supply) { return [ line({ - series: supply.relToCirculating.ratio, + series: supply.toCirculating.ratio, name: "Total", color: colors.default, unit: Unit.ratio, }), line({ - series: supply.inProfit.relToCirculating.ratio, + series: supply.inProfit.toCirculating.ratio, name: "In Profit", color: colors.profit, unit: Unit.ratio, }), line({ - series: supply.inLoss.relToCirculating.ratio, + series: supply.inLoss.toCirculating.ratio, name: "In Loss", color: colors.loss, unit: Unit.ratio, @@ -154,7 +154,7 @@ function groupedUtxoCountChart(list, all, title) { title: title("UTXO Count"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ - series: tree.outputs.unspentCount.inner, + series: tree.outputs.unspentCount.base, name, color, unit: Unit.count, @@ -230,7 +230,7 @@ function singleUtxoCountChart(cohort, title) { title: title("UTXO Count"), bottom: [ line({ - series: cohort.tree.outputs.unspentCount.inner, + series: cohort.tree.outputs.unspentCount.base, name: "UTXO Count", color: cohort.color, unit: Unit.count, @@ -241,7 +241,7 @@ function singleUtxoCountChart(cohort, title) { /** - * @param {CohortAll | CohortAddress | AddressCohortObject} cohort + * @param {CohortAll | CohortAddr | AddrCohortObject} cohort * @param {(name: string) => string} title * @returns {PartialChartOption} */ @@ -251,7 +251,7 @@ function singleAddressCountChart(cohort, title) { title: title("Address Count"), bottom: [ line({ - series: cohort.addressCount.inner, + series: cohort.addressCount.base, name: "Address Count", color: cohort.color, unit: Unit.count, @@ -293,7 +293,7 @@ export function createHoldingsSection({ cohort, title }) { } /** - * Holdings for CohortAll (has inProfit/inLoss with relToOwn but no relToCirculating) + * Holdings for CohortAll (has inProfit/inLoss with toOwn but no toCirculating) * @param {{ cohort: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ @@ -325,7 +325,7 @@ export function createHoldingsSectionAll({ cohort, title }) { } /** - * Holdings with full relative series (relToCirculating + relToOwn) + * Holdings with full relative series (toCirculating + toOwn) * For: CohortFull, CohortLongTerm (have DeltaHalfInRelTotalPattern2) * @param {{ cohort: CohortFull | CohortLongTerm, title: (name: string) => string }} args * @returns {PartialOptionsGroup} @@ -367,7 +367,7 @@ export function createHoldingsSectionWithRelative({ cohort, title }) { } /** - * Holdings with inProfit/inLoss + relToCirculating (no relToOwn) + * Holdings with inProfit/inLoss + toCirculating (no toOwn) * For: CohortWithAdjusted, CohortAgeRange (have DeltaHalfInRelTotalPattern) * @param {{ cohort: CohortWithAdjusted | CohortAgeRange, title: (name: string) => string }} args * @returns {PartialOptionsGroup} @@ -435,8 +435,8 @@ export function createHoldingsSectionWithProfitLoss({ cohort, title }) { } /** - * Holdings for CohortAddress (has inProfit/inLoss but no rel, plus address count) - * @param {{ cohort: CohortAddress, title: (name: string) => string }} args + * Holdings for CohortAddr (has inProfit/inLoss but no rel, plus address count) + * @param {{ cohort: CohortAddr, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createHoldingsSectionAddress({ cohort, title }) { @@ -464,7 +464,7 @@ export function createHoldingsSectionAddress({ cohort, title }) { /** * Holdings for address amount cohorts (no inProfit/inLoss, has address count) - * @param {{ cohort: AddressCohortObject, title: (name: string) => string }} args + * @param {{ cohort: AddrCohortObject, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createHoldingsSectionAddressAmount({ cohort, title }) { @@ -495,7 +495,7 @@ export function createHoldingsSectionAddressAmount({ cohort, title }) { // ============================================================================ /** - * @param {{ list: readonly CohortAddress[], all: CohortAll, title: (name: string) => string }} args + * @param {{ list: readonly CohortAddr[], all: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createGroupedHoldingsSectionAddress({ list, all, title }) { @@ -541,7 +541,7 @@ export function createGroupedHoldingsSectionAddress({ list, all, title }) { name: "Address Count", title: title("Address Count"), bottom: mapCohortsWithAll(list, all, ({ name, color, addressCount }) => - line({ series: addressCount.inner, name, color, unit: Unit.count }), + line({ series: addressCount.base, name, color, unit: Unit.count }), ), }, { @@ -558,7 +558,7 @@ export function createGroupedHoldingsSectionAddress({ list, all, title }) { /** * Grouped holdings for address amount cohorts (no inProfit/inLoss, has address count) - * @param {{ list: readonly AddressCohortObject[], all: CohortAll, title: (name: string) => string }} args + * @param {{ list: readonly AddrCohortObject[], all: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createGroupedHoldingsSectionAddressAmount({ @@ -586,7 +586,7 @@ export function createGroupedHoldingsSectionAddressAmount({ name: "Address Count", title: title("Address Count"), bottom: mapCohortsWithAll(list, all, ({ name, color, addressCount }) => - line({ series: addressCount.inner, name, color, unit: Unit.count }), + line({ series: addressCount.base, name, color, unit: Unit.count }), ), }, { @@ -695,7 +695,7 @@ export function createGroupedHoldingsSectionWithProfitLoss({ } /** - * Grouped holdings with inProfit/inLoss + relToCirculating (no relToOwn) + * Grouped holdings with inProfit/inLoss + toCirculating (no toOwn) * For: CohortWithAdjusted, CohortAgeRange * @param {{ list: readonly (CohortWithAdjusted | CohortAgeRange)[], all: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} @@ -720,7 +720,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({ ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.relToCirculating.percent, + series: tree.supply.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -741,7 +741,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({ ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.inProfit.relToCirculating.percent, + series: tree.supply.inProfit.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -762,7 +762,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({ ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.inLoss.relToCirculating.percent, + series: tree.supply.inLoss.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -785,7 +785,7 @@ export function createGroupedHoldingsSectionWithOwnSupply({ } /** - * Grouped holdings with full relative series (relToCirculating + relToOwn) + * Grouped holdings with full relative series (toCirculating + toOwn) * For: CohortFull, CohortLongTerm * @param {{ list: readonly (CohortFull | CohortLongTerm)[], all: CohortAll, title: (name: string) => string }} args * @returns {PartialOptionsGroup} @@ -806,7 +806,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) { ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.relToCirculating.percent, + series: tree.supply.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -827,7 +827,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) { ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.inProfit.relToCirculating.percent, + series: tree.supply.inProfit.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -835,7 +835,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) { ), ...mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ - series: tree.supply.inProfit.relToOwn.percent, + series: tree.supply.inProfit.toOwn.percent, name, color, unit: Unit.pctOwn, @@ -857,7 +857,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) { ), ...mapCohorts(list, ({ name, color, tree }) => line({ - series: tree.supply.inLoss.relToCirculating.percent, + series: tree.supply.inLoss.toCirculating.percent, name, color, unit: Unit.pctSupply, @@ -865,7 +865,7 @@ export function createGroupedHoldingsSectionWithRelative({ list, all, title }) { ), ...mapCohortsWithAll(list, all, ({ name, color, tree }) => line({ - series: tree.supply.inLoss.relToOwn.percent, + series: tree.supply.inLoss.toOwn.percent, name, color, unit: Unit.pctOwn, diff --git a/website/scripts/options/distribution/index.js b/website/scripts/options/distribution/index.js index 3d9901e42..20746d7b4 100644 --- a/website/scripts/options/distribution/index.js +++ b/website/scripts/options/distribution/index.js @@ -257,7 +257,7 @@ export function createCohortFolderBasicWithoutMarketCap(cohort) { /** * Address folder: like basic but with address count - * @param {CohortAddress} cohort + * @param {CohortAddr} cohort * @returns {PartialOptionsGroup} */ export function createCohortFolderAddress(cohort) { @@ -295,7 +295,7 @@ export function createCohortFolderWithoutRelative(cohort) { /** * Address amount cohort folder: has NUPL + addrCount - * @param {AddressCohortObject} cohort + * @param {AddrCohortObject} cohort * @returns {PartialOptionsGroup} */ export function createAddressCohortFolder(cohort) { @@ -515,7 +515,7 @@ export function createGroupedCohortFolderBasicWithoutMarketCap({ } /** - * @param {CohortGroupAddress} args + * @param {CohortGroupAddr} args * @returns {PartialOptionsGroup} */ export function createGroupedCohortFolderAddress({ @@ -565,7 +565,7 @@ export function createGroupedCohortFolderWithoutRelative({ } /** - * @param {AddressCohortGroupObject} args + * @param {AddrCohortGroupObject} args * @returns {PartialOptionsGroup} */ export function createGroupedAddressCohortFolder({ diff --git a/website/scripts/options/distribution/prices.js b/website/scripts/options/distribution/prices.js index 8cb17dd97..fb3b9e7c0 100644 --- a/website/scripts/options/distribution/prices.js +++ b/website/scripts/options/distribution/prices.js @@ -35,8 +35,8 @@ export function createPricesSectionFull({ cohort, title }) { top: [ price({ series: tree.realized.price, name: "Realized", color: colors.realized }), price({ series: tree.realized.investor.price, name: "Investor", color: colors.investor }), - price({ series: tree.realized.investor.upperPriceBand, name: "I²/R", color: colors.stat.max, style: 2, defaultActive: false }), - price({ series: tree.realized.investor.lowerPriceBand, name: "R²/I", color: colors.stat.min, style: 2, defaultActive: false }), + price({ series: tree.realized.investor.investorUpperBand, name: "I²/R", color: colors.stat.max, style: 2, defaultActive: false }), + price({ series: tree.realized.investor.investorLowerBand, name: "R²/I", color: colors.stat.min, style: 2, defaultActive: false }), ], }, { @@ -66,8 +66,8 @@ export function createPricesSectionFull({ cohort, title }) { /** * Create prices section for cohorts with basic ratio patterns only - * (CohortWithAdjusted, CohortBasic, CohortAddress, CohortWithoutRelative) - * @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative | CohortAgeRange, title: (name: string) => string }} args + * (CohortWithAdjusted, CohortBasic, CohortAddr, CohortWithoutRelative) + * @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddr | CohortWithoutRelative | CohortAgeRange, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createPricesSectionBasic({ cohort, title }) { diff --git a/website/scripts/options/distribution/profitability.js b/website/scripts/options/distribution/profitability.js index eb5cd0c96..a0185d767 100644 --- a/website/scripts/options/distribution/profitability.js +++ b/website/scripts/options/distribution/profitability.js @@ -96,38 +96,38 @@ function relPnlChart(profit, loss, name, title) { /** * Unrealized P&L tree for All cohort - * @param {Brk.SeriesTree_Cohorts_Utxo_All_Unrealized} u + * @param {AllRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ function unrealizedPnlTreeAll(u, title) { return [ { name: "USD", title: title("Unrealized P&L"), bottom: unrealizedUsdSeries(u) }, - relPnlChart(u.profit.relToMcap, u.loss.relToMcap, "% of Mcap", title), - relPnlChart(u.profit.relToOwnGross, u.loss.relToOwnGross, "% of Own P&L", title), + relPnlChart(u.profit.toMcap, u.loss.toMcap, "% of Mcap", title), + relPnlChart(u.profit.toOwnGrossPnl, u.loss.toOwnGrossPnl, "% of Own P&L", title), ...unrealizedCumulativeRollingTree(u.profit, u.loss, title), ]; } /** * Unrealized P&L tree for Full cohorts (STH) - * @param {Brk.GrossInvestedLossNetNuplProfitSentimentPattern2} u + * @param {FullRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ function unrealizedPnlTreeFull(u, title) { return [ { name: "USD", title: title("Unrealized P&L"), bottom: unrealizedUsdSeries(u) }, - relPnlChart(u.profit.relToMcap, u.loss.relToMcap, "% of Mcap", title), - relPnlChart(u.profit.relToOwnMcap, u.loss.relToOwnMcap, "% of Own Mcap", title), - relPnlChart(u.profit.relToOwnGross, u.loss.relToOwnGross, "% of Own P&L", title), + relPnlChart(u.profit.toMcap, u.loss.toMcap, "% of Mcap", title), + relPnlChart(u.profit.toOwnMcap, u.loss.toOwnMcap, "% of Own Mcap", title), + relPnlChart(u.profit.toOwnGrossPnl, u.loss.toOwnGrossPnl, "% of Own P&L", title), ...unrealizedCumulativeRollingTree(u.profit, u.loss, title), ]; } /** * Unrealized P&L tree for LTH (loss relToMcap only) - * @param {Brk.GrossInvestedLossNetNuplProfitSentimentPattern2} u + * @param {FullRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -137,17 +137,17 @@ function unrealizedPnlTreeLongTerm(u, title) { { name: "% of Mcap", title: title("Unrealized Loss (% of Mcap)"), - bottom: percentRatio({ pattern: u.loss.relToMcap, name: "Loss", color: colors.loss }), + bottom: percentRatio({ pattern: u.loss.toMcap, name: "Loss", color: colors.loss }), }, - relPnlChart(u.profit.relToOwnMcap, u.loss.relToOwnMcap, "% of Own Mcap", title), - relPnlChart(u.profit.relToOwnGross, u.loss.relToOwnGross, "% of Own P&L", title), + relPnlChart(u.profit.toOwnMcap, u.loss.toOwnMcap, "% of Own Mcap", title), + relPnlChart(u.profit.toOwnGrossPnl, u.loss.toOwnGrossPnl, "% of Own P&L", title), ...unrealizedCumulativeRollingTree(u.profit, u.loss, title), ]; } /** * Unrealized P&L tree for mid-tier cohorts (AgeRange/MaxAge) - * @param {Brk.LossNetNuplProfitPattern} u + * @param {BasicRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -232,7 +232,7 @@ function unrealizedCumulativeRollingTree(profit, loss, title) { // ============================================================================ /** - * @param {Brk.SeriesTree_Cohorts_Utxo_All_Unrealized} u + * @param {AllRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -242,13 +242,13 @@ function netUnrealizedTreeAll(u, title) { { name: "% of Own P&L", title: title("Net Unrealized P&L (% of Own P&L)"), - bottom: percentRatioBaseline({ pattern: u.netPnl.relToOwnGross, name: "Net P&L" }), + bottom: percentRatioBaseline({ pattern: u.netPnl.toOwnGrossPnl, name: "Net P&L" }), }, ]; } /** - * @param {Brk.GrossInvestedLossNetNuplProfitSentimentPattern2} u + * @param {FullRelativePattern} u * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -258,19 +258,19 @@ function netUnrealizedTreeFull(u, title) { { name: "% of Own Mcap", title: title("Net Unrealized P&L (% of Own Mcap)"), - bottom: percentRatioBaseline({ pattern: u.netPnl.relToOwnMcap, name: "Net P&L" }), + bottom: percentRatioBaseline({ pattern: u.netPnl.toOwnMcap, name: "Net P&L" }), }, { name: "% of Own P&L", title: title("Net Unrealized P&L (% of Own P&L)"), - bottom: percentRatioBaseline({ pattern: u.netPnl.relToOwnGross, name: "Net P&L" }), + bottom: percentRatioBaseline({ pattern: u.netPnl.toOwnGrossPnl, name: "Net P&L" }), }, ]; } /** * Net P&L for mid-tier cohorts - * @param {Brk.LossNetNuplProfitPattern} u + * @param {BasicRelativePattern} u * @returns {AnyFetchedSeriesBlueprint[]} */ function netUnrealizedMid(u) { @@ -283,7 +283,7 @@ function netUnrealizedMid(u) { /** * Invested capital (Full unrealized only) - * @param {Brk.GrossInvestedLossNetNuplProfitSentimentPattern2 | Brk.SeriesTree_Cohorts_Utxo_All_Unrealized} u + * @param {FullRelativePattern | AllRelativePattern} u * @returns {AnyFetchedSeriesBlueprint[]} */ function investedCapitalSeries(u) { @@ -295,7 +295,7 @@ function investedCapitalSeries(u) { /** * Sentiment (Full unrealized only) - * @param {Brk.GrossInvestedLossNetNuplProfitSentimentPattern2 | Brk.SeriesTree_Cohorts_Utxo_All_Unrealized} u + * @param {FullRelativePattern | AllRelativePattern} u * @returns {AnyFetchedSeriesBlueprint[]} */ function sentimentSeries(u) { @@ -308,7 +308,7 @@ function sentimentSeries(u) { /** * NUPL series - * @param {Brk.BpsRatioPattern} nupl + * @param {NuplPattern} nupl * @returns {AnyFetchedSeriesBlueprint[]} */ function nuplSeries(nupl) { @@ -320,7 +320,7 @@ function nuplSeries(nupl) { // ============================================================================ /** - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -339,15 +339,15 @@ function realizedPnlSumTreeFull(r, title) { name: "% of Rcap", title: title("Realized P&L (% of Realized Cap)"), bottom: [ - ...percentRatioBaseline({ pattern: r.profit.relToRcap, name: "Profit", color: colors.profit }), - ...percentRatioBaseline({ pattern: r.loss.relToRcap, name: "Loss", color: colors.loss }), + ...percentRatioBaseline({ pattern: r.profit.toRcap, name: "Profit", color: colors.profit }), + ...percentRatioBaseline({ pattern: r.loss.toRcap, name: "Loss", color: colors.loss }), ], }, ]; } /** - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -357,13 +357,13 @@ function realizedNetPnlSumTreeFull(r, title) { { name: "% of Rcap", title: title("Net Realized P&L (% of Realized Cap)"), - bottom: percentRatioBaseline({ pattern: r.netPnl.relToRcap, name: "Net" }), + bottom: percentRatioBaseline({ pattern: r.netPnl.toRcap, name: "Net" }), }, ]; } /** - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -382,8 +382,8 @@ function realizedPnlCumulativeTreeFull(r, title) { name: "% of Rcap", title: title("Cumulative Realized P&L (% of Realized Cap)"), bottom: [ - ...percentRatioBaseline({ pattern: r.profit.relToRcap, name: "Profit", color: colors.profit }), - ...percentRatioBaseline({ pattern: r.loss.relToRcap, name: "Loss", color: colors.loss }), + ...percentRatioBaseline({ pattern: r.profit.toRcap, name: "Profit", color: colors.profit }), + ...percentRatioBaseline({ pattern: r.loss.toRcap, name: "Loss", color: colors.loss }), ], }, ]; @@ -391,7 +391,7 @@ function realizedPnlCumulativeTreeFull(r, title) { /** * Net realized P&L delta tree (absolute + rate across all rolling windows) - * @param {Brk.BaseChangeCumulativeDeltaRelSumPattern | Brk.BaseCumulativeDeltaSumPattern} netPnl + * @param {NetPnlFullPattern | NetPnlBasicPattern} netPnl * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -439,7 +439,7 @@ function realizedNetPnlDeltaTree(netPnl, title) { /** * Full realized delta tree (absolute + rate + rel to mcap/rcap) - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -452,12 +452,12 @@ function realizedNetPnlDeltaTreeFull(r, title) { { name: "% of Mcap", title: title("Net Realized P&L Change (% of Mcap)"), - bottom: percentRatioBaseline({ pattern: r.netPnl.change1m.relToMcap, name: "30d Change" }), + bottom: percentRatioBaseline({ pattern: r.netPnl.change1m.toMcap, name: "30d Change" }), }, { name: "% of Rcap", title: title("Net Realized P&L Change (% of Rcap)"), - bottom: percentRatioBaseline({ pattern: r.netPnl.change1m.relToRcap, name: "30d Change" }), + bottom: percentRatioBaseline({ pattern: r.netPnl.change1m.toRcap, name: "30d Change" }), }, ], }; @@ -491,7 +491,7 @@ function rollingNetRealizedTree(netPnl, title) { /** * Rolling realized with P/L and ratio (full realized only) - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -554,8 +554,8 @@ function singleRollingRealizedTreeFull(r, title) { /** * Rolling realized profit/loss sums (basic — no P/L ratio) - * @param {Brk.BaseCumulativeSumPattern3} profit - * @param {Brk.BaseCumulativeSumPattern3} loss + * @param {RealizedProfitLossPattern} profit + * @param {RealizedProfitLossPattern} loss * @param {(name: string) => string} title * @returns {PartialOptionsTree} */ @@ -676,7 +676,7 @@ function investorPricePercentilesTree(percentiles, title) { /** * Full realized subfolder (All/STH/LTH) - * @param {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern | Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} r + * @param {RealizedPattern | LthRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -746,7 +746,7 @@ function realizedSubfolderFull(r, title) { { name: "% of Rcap", title: title("Cumulative Net P&L (% of Realized Cap)"), - bottom: percentRatioBaseline({ pattern: r.netPnl.relToRcap, name: "Net" }), + bottom: percentRatioBaseline({ pattern: r.netPnl.toRcap, name: "Net" }), }, ], }, @@ -757,7 +757,7 @@ function realizedSubfolderFull(r, title) { { name: "% of Rcap", title: title("Cumulative Peak Regret (% of Realized Cap)"), - bottom: percentRatioBaseline({ pattern: r.peakRegret.relToRcap, name: "Peak Regret" }), + bottom: percentRatioBaseline({ pattern: r.peakRegret.toRcap, name: "Peak Regret" }), }, ], }, @@ -769,7 +769,7 @@ function realizedSubfolderFull(r, title) { /** * Mid realized subfolder (AgeRange/MaxAge — has netPnl + delta, no relToRcap/peakRegret) - * @param {Brk.CapLossMvrvNetPriceProfitSoprPattern} r + * @param {MidRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -823,7 +823,7 @@ function realizedSubfolderMid(r, title) { /** * Basic realized subfolder (no netPnl, no relToRcap) - * @param {Brk.CapLossMvrvPriceProfitSoprPattern} r + * @param {BasicRealizedPattern} r * @param {(name: string) => string} title * @returns {PartialOptionsGroup} */ @@ -1070,8 +1070,8 @@ export function createProfitabilitySectionBasicWithInvestedCapitalPct({ cohort, } /** - * Section for CohortAddress (has unrealized profit/loss + NUPL, basic realized) - * @param {{ cohort: CohortAddress, title: (name: string) => string }} args + * Section for CohortAddr (has unrealized profit/loss + NUPL, basic realized) + * @param {{ cohort: CohortAddr, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createProfitabilitySectionAddress({ cohort, title }) { @@ -1110,8 +1110,8 @@ export function createProfitabilitySectionAddress({ cohort, title }) { /** * Grouped realized P&L sum (basic — all cohorts have profit/loss) - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} T - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} A + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} T + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} A * @param {readonly T[]} list * @param {A} all * @param {(name: string) => string} title @@ -1165,8 +1165,8 @@ function groupedRealizedPnlSumFull(list, all, title) { /** * Grouped rolling realized charts (basic — profit/loss sums only) - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} T - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} A + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} T + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} A * @param {readonly T[]} list * @param {A} all * @param {(name: string) => string} title @@ -1218,8 +1218,8 @@ function groupedRollingRealizedChartsFull(list, all, title) { /** * Grouped realized subfolder (basic) - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} T - * @template {{ name: string, color: Color, tree: { realized: { profit: Brk.BaseCumulativeSumPattern3, loss: Brk.BaseCumulativeSumPattern3 } } }} A + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} T + * @template {{ name: string, color: Color, tree: { realized: { profit: RealizedProfitLossPattern, loss: RealizedProfitLossPattern } } }} A * @param {readonly T[]} list * @param {A} all * @param {(name: string) => string} title @@ -1364,8 +1364,8 @@ function groupedRealizedSubfolderFull(list, all, title) { /** * Grouped unrealized P&L (USD only — for all cohorts that at least have nupl) - * @template {{ name: string, color: Color, tree: { unrealized: { nupl: Brk.BpsRatioPattern } } }} T - * @template {{ name: string, color: Color, tree: { unrealized: { nupl: Brk.BpsRatioPattern } } }} A + * @template {{ name: string, color: Color, tree: { unrealized: { nupl: NuplPattern } } }} T + * @template {{ name: string, color: Color, tree: { unrealized: { nupl: NuplPattern } } }} A * @param {readonly T[]} list * @param {A} all * @param {(name: string) => string} title @@ -1406,7 +1406,7 @@ function groupedPnlChartsWithMarketCap(list, all, title) { name: "% of Mcap", title: title("Unrealized Profit (% of Mcap)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.profit.relToMcap, name, color }), + percentRatio({ pattern: tree.unrealized.profit.toMcap, name, color }), ), }, ], @@ -1425,7 +1425,7 @@ function groupedPnlChartsWithMarketCap(list, all, title) { name: "% of Mcap", title: title("Unrealized Loss (% of Mcap)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.loss.relToMcap, name, color }), + percentRatio({ pattern: tree.unrealized.loss.toMcap, name, color }), ), }, ], @@ -1496,14 +1496,14 @@ function groupedPnlChartsLongTerm(list, all, title) { name: "% of Own Mcap", title: title("Unrealized Profit (% of Own Mcap)"), bottom: flatMapCohorts(list, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.profit.relToOwnMcap, name, color }), + percentRatio({ pattern: tree.unrealized.profit.toOwnMcap, name, color }), ), }, { name: "% of Own P&L", title: title("Unrealized Profit (% of Own P&L)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.profit.relToOwnGross, name, color }), + percentRatio({ pattern: tree.unrealized.profit.toOwnGrossPnl, name, color }), ), }, ], @@ -1522,21 +1522,21 @@ function groupedPnlChartsLongTerm(list, all, title) { name: "% of Mcap", title: title("Unrealized Loss (% of Mcap)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.loss.relToMcap, name, color }), + percentRatio({ pattern: tree.unrealized.loss.toMcap, name, color }), ), }, { name: "% of Own Mcap", title: title("Unrealized Loss (% of Own Mcap)"), bottom: flatMapCohorts(list, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.loss.relToOwnMcap, name, color }), + percentRatio({ pattern: tree.unrealized.loss.toOwnMcap, name, color }), ), }, { name: "% of Own P&L", title: title("Unrealized Loss (% of Own P&L)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.unrealized.loss.relToOwnGross, name, color }), + percentRatio({ pattern: tree.unrealized.loss.toOwnGrossPnl, name, color }), ), }, ], @@ -1555,14 +1555,14 @@ function groupedPnlChartsLongTerm(list, all, title) { name: "% of Own Mcap", title: title("Net Unrealized P&L (% of Own Mcap)"), bottom: flatMapCohorts(list, ({ name, color, tree }) => - percentRatioBaseline({ pattern: tree.unrealized.netPnl.relToOwnMcap, name, color }), + percentRatioBaseline({ pattern: tree.unrealized.netPnl.toOwnMcap, name, color }), ), }, { name: "% of Own P&L", title: title("Net Unrealized P&L (% of Own P&L)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatioBaseline({ pattern: tree.unrealized.netPnl.relToOwnGross, name, color }), + percentRatioBaseline({ pattern: tree.unrealized.netPnl.toOwnGrossPnl, name, color }), ), }, ], diff --git a/website/scripts/options/distribution/valuation.js b/website/scripts/options/distribution/valuation.js index d2a68c94e..98c89d990 100644 --- a/website/scripts/options/distribution/valuation.js +++ b/website/scripts/options/distribution/valuation.js @@ -52,7 +52,7 @@ export function createValuationSectionFull({ cohort, title }) { { name: "% of Own Mcap", title: title("Realized Cap (% of Own Mcap)"), - bottom: percentRatioBaseline({ pattern: tree.realized.cap.relToOwnMcap, name: "Rel. to Own M.Cap", color }), + bottom: percentRatioBaseline({ pattern: tree.realized.cap.toOwnMcap, name: "Rel. to Own M.Cap", color }), }, ], }, @@ -76,8 +76,8 @@ export function createValuationSectionFull({ cohort, title }) { /** * Create valuation section for cohorts with basic ratio patterns - * (CohortWithAdjusted, CohortBasic, CohortAddress, CohortWithoutRelative) - * @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddress | CohortWithoutRelative, title: (name: string) => string }} args + * (CohortWithAdjusted, CohortBasic, CohortAddr, CohortWithoutRelative) + * @param {{ cohort: CohortWithAdjusted | CohortBasic | CohortAddr | CohortWithoutRelative, title: (name: string) => string }} args * @returns {PartialOptionsGroup} */ export function createValuationSection({ cohort, title }) { @@ -201,7 +201,7 @@ export function createGroupedValuationSectionWithOwnMarketCap({ name: "% of Own Mcap", title: title("Realized Cap (% of Own Mcap)"), bottom: flatMapCohortsWithAll(list, all, ({ name, color, tree }) => - percentRatio({ pattern: tree.realized.cap.relToOwnMcap, name, color }), + percentRatio({ pattern: tree.realized.cap.toOwnMcap, name, color }), ), }, ], diff --git a/website/scripts/options/market.js b/website/scripts/options/market.js index 1f9b6fcc0..5d3ea02fa 100644 --- a/website/scripts/options/market.js +++ b/website/scripts/options/market.js @@ -34,7 +34,7 @@ import { periodIdToName } from "./utils.js"; * @typedef {Object} MaPeriod * @property {string} id * @property {Color} color - * @property {Brk.BpsCentsRatioSatsUsdPattern} ratio + * @property {MaPriceRatioPattern} ratio */ /** @@ -1028,7 +1028,7 @@ export function createMarketSection() { title: "Thermocap Multiple", bottom: [ line({ - series: indicators.thermocapMultiple.ratio, + series: indicators.thermoCapMultiple.ratio, name: "Thermocap", color: colors.bitcoin, unit: Unit.ratio, @@ -1071,7 +1071,7 @@ export function createMarketSection() { title: "Seller Exhaustion Constant", bottom: [ line({ - series: indicators.sellerExhaustionConstant, + series: indicators.sellerExhaustion, name: "SEC", color: colors.bitcoin, unit: Unit.ratio, diff --git a/website/scripts/options/mining.js b/website/scripts/options/mining.js index df65190a1..eac55f030 100644 --- a/website/scripts/options/mining.js +++ b/website/scripts/options/mining.js @@ -9,6 +9,7 @@ import { dots, dotted, distributionBtcSatsUsd, + statsAtWindow, rollingWindowsTree, ROLLING_WINDOWS, percentRatio, @@ -248,7 +249,7 @@ export function createMiningSection() { defaultActive: false, }), dotted({ - series: blocks.difficulty.asHash, + series: blocks.difficulty.hashrate, name: "Difficulty", color: colors.default, unit: Unit.hashRate, @@ -334,12 +335,12 @@ export function createMiningSection() { title: "Next Difficulty Adjustment", bottom: [ line({ - series: blocks.difficulty.blocksBeforeNext, + series: blocks.difficulty.blocksToRetarget, name: "Remaining", unit: Unit.blocks, }), line({ - series: blocks.difficulty.daysBeforeNext, + series: blocks.difficulty.daysToRetarget, name: "Remaining", unit: Unit.days, }), @@ -583,7 +584,7 @@ export function createMiningSection() { tree: ROLLING_WINDOWS.map((w) => ({ name: w.name, title: `Fee Revenue per Block Distribution (${w.name})`, - bottom: distributionBtcSatsUsd(mining.rewards.fees[w.key]), + bottom: distributionBtcSatsUsd(statsAtWindow(mining.rewards.fees, w.key)), })), }, { @@ -650,13 +651,13 @@ export function createMiningSection() { name: "Compare", title: "Fee-to-Subsidy Ratio", bottom: ROLLING_WINDOWS.map((w) => - line({ series: mining.rewards.fees.ratioMultiple[w.key].ratio, name: w.name, color: w.color, unit: Unit.ratio }), + line({ series: mining.rewards.fees.toSubsidyRatio[w.key].ratio, name: w.name, color: w.color, unit: Unit.ratio }), ), }, ...ROLLING_WINDOWS.map((w) => ({ name: w.name, title: `Fee-to-Subsidy Ratio (${w.name})`, - bottom: [line({ series: mining.rewards.fees.ratioMultiple[w.key].ratio, name: w.name, color: w.color, unit: Unit.ratio })], + bottom: [line({ series: mining.rewards.fees.toSubsidyRatio[w.key].ratio, name: w.name, color: w.color, unit: Unit.ratio })], })), ], }, @@ -787,12 +788,12 @@ export function createMiningSection() { title: "Next Halving", bottom: [ line({ - series: blocks.halving.blocksBeforeNext, + series: blocks.halving.blocksToHalving, name: "Remaining", unit: Unit.blocks, }), line({ - series: blocks.halving.daysBeforeNext, + series: blocks.halving.daysToHalving, name: "Remaining", unit: Unit.days, }), diff --git a/website/scripts/options/network.js b/website/scripts/options/network.js index a51bc055a..35e609247 100644 --- a/website/scripts/options/network.js +++ b/website/scripts/options/network.js @@ -36,7 +36,7 @@ export function createNetworkSection() { outputs, scripts, supply, - addresses, + addrs, cohorts, } = brk.series; @@ -123,19 +123,19 @@ export function createNetworkSection() { name: "Funded", title: "Address Count by Type", /** @param {AddressableType} t */ - getSeries: (t) => addresses.funded[t], + getSeries: (t) => addrs.funded[t], }, { name: "Empty", title: "Empty Address Count by Type", /** @param {AddressableType} t */ - getSeries: (t) => addresses.empty[t], + getSeries: (t) => addrs.empty[t], }, { name: "Total", title: "Total Address Count by Type", /** @param {AddressableType} t */ - getSeries: (t) => addresses.total[t], + getSeries: (t) => addrs.total[t], }, ]); @@ -150,19 +150,19 @@ export function createNetworkSection() { title: `${titlePrefix}Address Count`, bottom: [ line({ - series: addresses.funded[key], + series: addrs.funded[key], name: "Funded", unit: Unit.count, }), line({ - series: addresses.empty[key], + series: addrs.empty[key], name: "Empty", color: colors.gray, unit: Unit.count, defaultActive: false, }), line({ - series: addresses.total[key], + series: addrs.total[key], name: "Total", color: colors.default, unit: Unit.count, @@ -174,7 +174,7 @@ export function createNetworkSection() { name: "Trends", tree: [ rollingWindowsTree({ - windows: addresses.delta[key].absolute, + windows: addrs.delta[key].absolute, title: `${titlePrefix}Address Count Change`, unit: Unit.count, series: baseline, @@ -182,7 +182,7 @@ export function createNetworkSection() { { name: "New", tree: (() => { - const p = addresses.new[key]; + const p = addrs.new[key]; const t = `${titlePrefix}New Address Count`; return [ { @@ -219,12 +219,12 @@ export function createNetworkSection() { title: `${titlePrefix}Reactivated Addresses per Block`, bottom: [ dots({ - series: addresses.activity[key].reactivated.height, + series: addrs.activity[key].reactivated.base, name: "base", unit: Unit.count, }), line({ - series: addresses.activity[key].reactivated._24h, + series: addrs.activity[key].reactivated._24h, name: "24h avg", color: colors.stat.avg, unit: Unit.count, @@ -232,14 +232,14 @@ export function createNetworkSection() { ], }, rollingWindowsTree({ - windows: addresses.activity[key].reactivated, + windows: addrs.activity[key].reactivated, title: `${titlePrefix}Reactivated Addresses`, unit: Unit.count, }), ], }, rollingPercentRatioTree({ - windows: addresses.delta[key].rate, + windows: addrs.delta[key].rate, title: `${titlePrefix}Address Growth Rate`, }), ], @@ -254,12 +254,12 @@ export function createNetworkSection() { title: `${titlePrefix}${t.title}`, bottom: [ dots({ - series: addresses.activity[key][t.key].height, + series: addrs.activity[key][t.key].base, name: "base", unit: Unit.count, }), line({ - series: addresses.activity[key][t.key]._24h, + series: addrs.activity[key][t.key]._24h, name: "24h avg", color: colors.stat.avg, unit: Unit.count, @@ -267,7 +267,7 @@ export function createNetworkSection() { ], }, rollingWindowsTree({ - windows: addresses.activity[key][t.key], + windows: addrs.activity[key][t.key], title: `${titlePrefix}${t.title.replace(" per Block", "")}`, unit: Unit.count, }), @@ -305,13 +305,13 @@ export function createNetworkSection() { title: `${groupName} New Address Count`, bottom: types.flatMap((t) => [ line({ - series: addresses.new[t.key].base, + series: addrs.new[t.key].base, name: t.name, color: t.color, unit: Unit.count, }), line({ - series: addresses.new[t.key].sum._24h, + series: addrs.new[t.key].sum._24h, name: t.name, color: t.color, unit: Unit.count, @@ -326,7 +326,7 @@ export function createNetworkSection() { title: `${groupName} Reactivated Addresses per Block`, bottom: types.map((t) => line({ - series: addresses.activity[t.key].reactivated.height, + series: addrs.activity[t.key].reactivated.base, name: t.name, color: t.color, unit: Unit.count, @@ -338,7 +338,7 @@ export function createNetworkSection() { title: `${groupName} Reactivated Addresses (${w.name})`, bottom: types.map((t) => line({ - series: addresses.activity[t.key].reactivated[w.key], + series: addrs.activity[t.key].reactivated[w.key], name: t.name, color: t.color, unit: Unit.count, @@ -354,7 +354,7 @@ export function createNetworkSection() { title: `${groupName} Address Growth Rate (${w.name})`, bottom: types.flatMap((t) => percentRatio({ - pattern: addresses.delta[t.key].rate[w.key], + pattern: addrs.delta[t.key].rate[w.key], name: t.name, color: t.color, }), @@ -371,7 +371,7 @@ export function createNetworkSection() { title: `${groupName} ${tr.compareTitle}`, bottom: types.map((t) => line({ - series: addresses.activity[t.key][tr.key].height, + series: addrs.activity[t.key][tr.key].base, name: t.name, color: t.color, unit: Unit.count, @@ -383,7 +383,7 @@ export function createNetworkSection() { title: `${groupName} ${tr.compareTitle} (${w.name})`, bottom: types.map((t) => line({ - series: addresses.activity[t.key][tr.key][w.key], + series: addrs.activity[t.key][tr.key][w.key], name: t.name, color: t.color, unit: Unit.count, @@ -519,7 +519,7 @@ export function createNetworkSection() { name: "Base", title: "Unspendable Supply", bottom: satsBtcUsdFrom({ - source: supply.burned.unspendable, + source: supply.burned, key: "base", name: "sum", }), @@ -532,7 +532,7 @@ export function createNetworkSection() { title: "Unspendable Supply Rolling", bottom: ROLLING_WINDOWS.flatMap((w) => satsBtcUsd({ - pattern: supply.burned.unspendable.sum[w.key], + pattern: supply.burned.sum[w.key], name: w.name, color: w.color, }), @@ -542,7 +542,7 @@ export function createNetworkSection() { name: w.name, title: `Unspendable Supply ${w.name}`, bottom: satsBtcUsd({ - pattern: supply.burned.unspendable.sum[w.key], + pattern: supply.burned.sum[w.key], name: w.name, color: w.color, }), @@ -553,7 +553,7 @@ export function createNetworkSection() { name: "Cumulative", title: "Unspendable Supply (Total)", bottom: satsBtcUsdFrom({ - source: supply.burned.unspendable, + source: supply.burned, key: "cumulative", name: "all-time", }), @@ -650,11 +650,11 @@ export function createNetworkSection() { title: "Transaction Volume", bottom: [ ...satsBtcUsd({ - pattern: transactions.volume.sentSum.base, + pattern: transactions.volume.transferVolume.base, name: "Sent", }), ...satsBtcUsd({ - pattern: transactions.volume.receivedSum.base, + pattern: transactions.volume.outputVolume.base, name: "Received", color: colors.entity.output, }), @@ -668,7 +668,7 @@ export function createNetworkSection() { title: "Sent Volume Rolling", bottom: ROLLING_WINDOWS.flatMap((w) => satsBtcUsd({ - pattern: transactions.volume.sentSum.sum[w.key], + pattern: transactions.volume.transferVolume.sum[w.key], name: w.name, color: w.color, }), @@ -678,7 +678,7 @@ export function createNetworkSection() { name: w.name, title: `Sent Volume ${w.name}`, bottom: satsBtcUsd({ - pattern: transactions.volume.sentSum.sum[w.key], + pattern: transactions.volume.transferVolume.sum[w.key], name: w.name, color: w.color, }), @@ -689,7 +689,7 @@ export function createNetworkSection() { name: "Sent Cumulative", title: "Sent Volume (Total)", bottom: satsBtcUsd({ - pattern: transactions.volume.sentSum.cumulative, + pattern: transactions.volume.transferVolume.cumulative, name: "all-time", }), }, @@ -701,7 +701,7 @@ export function createNetworkSection() { title: "Received Volume Rolling", bottom: ROLLING_WINDOWS.flatMap((w) => satsBtcUsd({ - pattern: transactions.volume.receivedSum.sum[w.key], + pattern: transactions.volume.outputVolume.sum[w.key], name: w.name, color: w.color, }), @@ -711,7 +711,7 @@ export function createNetworkSection() { name: w.name, title: `Received Volume ${w.name}`, bottom: satsBtcUsd({ - pattern: transactions.volume.receivedSum.sum[w.key], + pattern: transactions.volume.outputVolume.sum[w.key], name: w.name, color: w.color, }), @@ -722,7 +722,7 @@ export function createNetworkSection() { name: "Received Cumulative", title: "Received Volume (Total)", bottom: satsBtcUsd({ - pattern: transactions.volume.receivedSum.cumulative, + pattern: transactions.volume.outputVolume.cumulative, name: "all-time", }), }, @@ -884,7 +884,7 @@ export function createNetworkSection() { title: "Block Interval", bottom: [ dots({ - series: blocks.interval.height, + series: blocks.interval.base, name: "base", unit: Unit.secs, }), @@ -912,7 +912,7 @@ export function createNetworkSection() { title: "Block Size", bottom: [ line({ - series: blocks.size.total, + series: blocks.size.base, name: "base", unit: Unit.bytes, }), @@ -925,7 +925,7 @@ export function createNetworkSection() { }), distributionWindowsTree({ pattern: blocks.size, - base: blocks.size.total, + base: blocks.size.base, title: "Block Size", unit: Unit.bytes, }), @@ -950,7 +950,7 @@ export function createNetworkSection() { title: "Block Weight", bottom: [ line({ - series: blocks.weight.raw, + series: blocks.weight.base, name: "base", unit: Unit.wu, }), @@ -963,7 +963,7 @@ export function createNetworkSection() { }), distributionWindowsTree({ pattern: blocks.weight, - base: blocks.weight.raw, + base: blocks.weight.base, title: "Block Weight", unit: Unit.wu, }), @@ -1173,14 +1173,14 @@ export function createNetworkSection() { title: "New Address Count by Type", bottom: addressTypes.flatMap((t) => [ line({ - series: addresses.new[t.key].base, + series: addrs.new[t.key].base, name: t.name, color: t.color, unit: Unit.count, defaultActive: t.defaultActive, }), line({ - series: addresses.new[t.key].sum._24h, + series: addrs.new[t.key].sum._24h, name: t.name, color: t.color, unit: Unit.count, @@ -1196,7 +1196,7 @@ export function createNetworkSection() { title: "Reactivated Addresses per Block by Type", bottom: addressTypes.map((t) => line({ - series: addresses.activity[t.key].reactivated.height, + series: addrs.activity[t.key].reactivated.base, name: t.name, color: t.color, unit: Unit.count, @@ -1209,7 +1209,7 @@ export function createNetworkSection() { title: `Reactivated Addresses by Type (${w.name})`, bottom: addressTypes.map((t) => line({ - series: addresses.activity[t.key].reactivated[w.key], + series: addrs.activity[t.key].reactivated[w.key], name: t.name, color: t.color, unit: Unit.count, @@ -1226,7 +1226,7 @@ export function createNetworkSection() { title: `Address Growth Rate by Type (${w.name})`, bottom: addressTypes.flatMap((t) => percentRatio({ - pattern: addresses.delta[t.key].rate[w.key], + pattern: addrs.delta[t.key].rate[w.key], name: t.name, color: t.color, defaultActive: t.defaultActive, @@ -1244,7 +1244,7 @@ export function createNetworkSection() { title: tr.compareTitle, bottom: addressTypes.map((t) => line({ - series: addresses.activity[t.key][tr.key].height, + series: addrs.activity[t.key][tr.key].base, name: t.name, color: t.color, unit: Unit.count, @@ -1257,7 +1257,7 @@ export function createNetworkSection() { title: `${tr.compareTitle} (${w.name})`, bottom: addressTypes.map((t) => line({ - series: addresses.activity[t.key][tr.key][w.key], + series: addrs.activity[t.key][tr.key][w.key], name: t.name, color: t.color, unit: Unit.count, diff --git a/website/scripts/options/series.js b/website/scripts/options/series.js index 6f25cc225..66dd411e7 100644 --- a/website/scripts/options/series.js +++ b/website/scripts/options/series.js @@ -532,7 +532,7 @@ export function distributionWindowsTree({ pattern, base, title, unit }) { /** * Map a rolling window slot's stats to a specific unit, producing a stats-compatible pattern - * @param {RollingWindowSlot} slot - Rolling window slot (e.g., pattern.rolling._24h) + * @param {{ average: Record, median: Record, max: Record, min: Record, pct75: Record, pct25: Record, pct90: Record, pct10: Record }} slot - Rolling window slot with multi-currency stats * @param {BtcSatsUsdKey} unitKey */ function rollingSlotForUnit(slot, unitKey) { @@ -550,7 +550,7 @@ function rollingSlotForUnit(slot, unitKey) { /** * Create distribution series for btc/sats/usd from a rolling window slot - * @param {RollingWindowSlot} slot - Rolling window slot (e.g., pattern.rolling._24h) + * @param {{ average: Record, median: Record, max: Record, min: Record, pct75: Record, pct25: Record, pct90: Record, pct10: Record }} slot - Rolling window slot with multi-currency stats * @returns {AnyFetchedSeriesBlueprint[]} */ export const distributionBtcSatsUsd = (slot) => [ diff --git a/website/scripts/options/types.js b/website/scripts/options/types.js index d02a4a305..addbcc931 100644 --- a/website/scripts/options/types.js +++ b/website/scripts/options/types.js @@ -171,13 +171,13 @@ * @typedef {LongTermPattern | AgeRangePattern} PatternWithPercentiles * * Patterns with RelToMarketCap in relative (geAmount.*, ltAmount.*): - * @typedef {UtxoAmountPattern | AddressAmountPattern} PatternBasicWithMarketCap + * @typedef {UtxoAmountPattern | AddrAmountPattern} PatternBasicWithMarketCap * * Patterns without RelToMarketCap in relative: * - EpochPattern (epoch.*, year.*) * - UtxoAmountPattern (amountRange.*) * - OutputsRealizedSupplyUnrealizedPattern2 (addressable type.*) - * @typedef {EpochPattern | UtxoAmountPattern | Brk.OutputsRealizedSupplyUnrealizedPattern2} PatternBasicWithoutMarketCap + * @typedef {EpochPattern | UtxoAmountPattern | EmptyPattern} PatternBasicWithoutMarketCap * * Patterns without relative section entirely (edge case output types): * - EmptyPattern (type.empty, type.p2ms, type.unknown) @@ -196,7 +196,7 @@ * @property {string} title * @property {Color} color * @property {PatternAll} tree - * @property {Brk.DeltaInnerPattern} addressCount + * @property {AddressCountDeltaPattern} addressCount * * Full cohort: adjustedSopr + percentiles + RelToMarketCap (term.short) * @typedef {Object} CohortFull @@ -265,7 +265,7 @@ * ============================================================================ * * Addressable cohort with address count (for "type" cohorts - uses OutputsRealizedSupplyUnrealizedPattern2) - * @typedef {{ name: string, title: string, color: Color, tree: Brk.OutputsRealizedSupplyUnrealizedPattern2, addressCount: Brk.DeltaInnerPattern }} CohortAddress + * @typedef {{ name: string, title: string, color: Color, tree: EmptyPattern, addressCount: AddressCountDeltaPattern }} CohortAddr * * ============================================================================ * Cohort Group Types (by capability) @@ -328,28 +328,28 @@ * @property {readonly UtxoCohortObject[]} list * @property {CohortAll} all * - * @typedef {Object} AddressCohortObject + * @typedef {Object} AddrCohortObject * @property {string} name * @property {string} title * @property {Color} color - * @property {AddressCohortPattern} tree - * @property {Brk.DeltaInnerPattern} addressCount + * @property {AddrCohortPattern} tree + * @property {AddressCountDeltaPattern} addressCount * - * @typedef {UtxoCohortObject | AddressCohortObject | CohortWithoutRelative} CohortObject + * @typedef {UtxoCohortObject | AddrCohortObject | CohortWithoutRelative} CohortObject * * - * @typedef {Object} AddressCohortGroupObject + * @typedef {Object} AddrCohortGroupObject * @property {string} name * @property {string} title - * @property {readonly AddressCohortObject[]} list + * @property {readonly AddrCohortObject[]} list * @property {CohortAll} all * - * @typedef {UtxoCohortGroupObject | AddressCohortGroupObject} CohortGroupObject + * @typedef {UtxoCohortGroupObject | AddrCohortGroupObject} CohortGroupObject * - * @typedef {Object} CohortGroupAddress + * @typedef {Object} CohortGroupAddr * @property {string} name * @property {string} title - * @property {readonly CohortAddress[]} list + * @property {readonly CohortAddr[]} list * @property {CohortAll} all */ diff --git a/website/scripts/types.js b/website/scripts/types.js index 7e3ffb81f..655ad0b2b 100644 --- a/website/scripts/types.js +++ b/website/scripts/types.js @@ -12,7 +12,7 @@ * * @import { Color } from "./utils/colors.js" * - * @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, AnySeriesBlueprint, SeriesType, AnyFetchedSeriesBlueprint, TableOption, ExplorerOption, UrlOption, PartialOptionsGroup, OptionsGroup, PartialOptionsTree, UtxoCohortObject, AddressCohortObject, CohortObject, CohortGroupObject, FetchedLineSeriesBlueprint, FetchedBaselineSeriesBlueprint, FetchedHistogramSeriesBlueprint, FetchedDotsBaselineSeriesBlueprint, PatternAll, PatternFull, PatternWithAdjusted, PatternWithPercentiles, PatternBasic, PatternBasicWithMarketCap, PatternBasicWithoutMarketCap, PatternWithoutRelative, CohortAll, CohortFull, CohortWithAdjusted, CohortWithPercentiles, CohortBasic, CohortBasicWithMarketCap, CohortBasicWithoutMarketCap, CohortWithoutRelative, CohortAddress, CohortLongTerm, CohortAgeRange, CohortAgeRangeWithMatured, CohortGroupFull, CohortGroupWithAdjusted, CohortGroupWithPercentiles, CohortGroupLongTerm, CohortGroupAgeRange, CohortGroupBasic, CohortGroupBasicWithMarketCap, CohortGroupBasicWithoutMarketCap, CohortGroupWithoutRelative, CohortGroupAddress, UtxoCohortGroupObject, AddressCohortGroupObject, FetchedDotsSeriesBlueprint, FetchedCandlestickSeriesBlueprint, FetchedPriceSeriesBlueprint, AnyPricePattern, AnyValuePattern } from "./options/partial.js" + * @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, AnySeriesBlueprint, SeriesType, AnyFetchedSeriesBlueprint, TableOption, ExplorerOption, UrlOption, PartialOptionsGroup, OptionsGroup, PartialOptionsTree, UtxoCohortObject, AddrCohortObject, CohortObject, CohortGroupObject, FetchedLineSeriesBlueprint, FetchedBaselineSeriesBlueprint, FetchedHistogramSeriesBlueprint, FetchedDotsBaselineSeriesBlueprint, PatternAll, PatternFull, PatternWithAdjusted, PatternWithPercentiles, PatternBasic, PatternBasicWithMarketCap, PatternBasicWithoutMarketCap, PatternWithoutRelative, CohortAll, CohortFull, CohortWithAdjusted, CohortWithPercentiles, CohortBasic, CohortBasicWithMarketCap, CohortBasicWithoutMarketCap, CohortWithoutRelative, CohortAddr, CohortLongTerm, CohortAgeRange, CohortAgeRangeWithMatured, CohortGroupFull, CohortGroupWithAdjusted, CohortGroupWithPercentiles, CohortGroupLongTerm, CohortGroupAgeRange, CohortGroupBasic, CohortGroupBasicWithMarketCap, CohortGroupBasicWithoutMarketCap, CohortGroupWithoutRelative, CohortGroupAddr, UtxoCohortGroupObject, AddrCohortGroupObject, FetchedDotsSeriesBlueprint, FetchedCandlestickSeriesBlueprint, FetchedPriceSeriesBlueprint, AnyPricePattern, AnyValuePattern } from "./options/partial.js" * * * @import { UnitObject as Unit } from "./utils/units.js" @@ -31,22 +31,22 @@ * * Brk tree types (stable across regenerations) * @typedef {Brk.SeriesTree_Cohorts_Utxo} UtxoCohortTree - * @typedef {Brk.SeriesTree_Cohorts_Address} AddressCohortTree + * @typedef {Brk.SeriesTree_Cohorts_Addr} AddrCohortTree * @typedef {Brk.SeriesTree_Cohorts_Utxo_All} AllUtxoPattern * @typedef {Brk.SeriesTree_Cohorts_Utxo_Sth} ShortTermPattern * @typedef {Brk.SeriesTree_Cohorts_Utxo_Lth} LongTermPattern * @typedef {Brk.SeriesTree_Cohorts_Utxo_All_Unrealized} AllRelativePattern * @typedef {keyof Brk.BtcCentsSatsUsdPattern} BtcSatsUsdKey * @typedef {Brk.BtcCentsSatsUsdPattern} SupplyPattern - * @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern} BlockSizePattern + * @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern} BlockSizePattern * @typedef {keyof Brk.SeriesTree_Cohorts_Utxo_Type} SpendableType - * @typedef {keyof Brk.SeriesTree_Addresses_Raw} AddressableType + * @typedef {keyof Brk.SeriesTree_Addrs_Raw} AddressableType * * Brk pattern types (using new pattern names) * @typedef {Brk.ActivityOutputsRealizedSupplyUnrealizedPattern} MaxAgePattern * @typedef {Brk.ActivityOutputsRealizedSupplyUnrealizedPattern} AgeRangePattern * @typedef {Brk.OutputsRealizedSupplyUnrealizedPattern} UtxoAmountPattern - * @typedef {Brk.AddressOutputsRealizedSupplyUnrealizedPattern} AddressAmountPattern + * @typedef {Brk.AddrOutputsRealizedSupplyUnrealizedPattern} AddrAmountPattern * @typedef {Brk.ActivityOutputsRealizedSupplyUnrealizedPattern} BasicUtxoPattern * @typedef {Brk.ActivityOutputsRealizedSupplyUnrealizedPattern} EpochPattern * @typedef {Brk.OutputsRealizedSupplyUnrealizedPattern2} EmptyPattern @@ -65,7 +65,7 @@ * FullValuePattern: base + cumulative + rolling windows (flattened) * @typedef {Brk.BaseCumulativeSumPattern4} FullValuePattern * RollingWindowSlot: a single rolling window with stats (average, pct10, pct25, median, pct75, pct90, max, min) per unit - * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} RollingWindowSlot + * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} RollingWindowSlot * AnyValuePatternType: union of all value pattern types * @typedef {Brk.BaseCumulativeSumPattern4 | Brk.BaseCumulativeSumPattern | Brk.BaseCumulativeRelPattern} AnyValuePatternType * @typedef {Brk.AnySeriesPattern} AnySeriesPattern @@ -92,19 +92,67 @@ * @typedef {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} RealizedPattern2 * @typedef {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} RealizedPattern3 * @typedef {Brk.CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} RealizedPattern4 + * + * Transfer volume pattern (base + cumulative + inProfit/inLoss + sum windows) + * @typedef {Brk.BaseCumulativeInSumPattern} TransferVolumePattern + * + * Realized profit/loss pattern (base + cumulative + sum windows) + * @typedef {Brk.BaseCumulativeSumPattern3} RealizedProfitLossPattern + * + * Full activity pattern (coindays, coinyears, dormancy, transfer volume) + * @typedef {Brk.CoindaysCoinyearsDormancyTransferPattern} FullActivityPattern + * + * Profit distribution detail (base + cumulative + distribution flow + rel + sum + value) + * @typedef {Brk.BaseCumulativeDistributionRelSumValuePattern} ProfitDetailPattern + * + * Loss detail with capitulation (base + capitulation + cumulative + negative + rel + sum + value) + * @typedef {Brk.BaseCapitulationCumulativeNegativeRelSumValuePattern} LossDetailPattern + * + * BPS + ratio pattern (for NUPL and similar) + * @typedef {Brk.BpsRatioPattern} NuplPattern + * + * LTH realized tree + * @typedef {Brk.SeriesTree_Cohorts_Utxo_Lth_Realized} LthRealizedPattern + * + * Net PnL pattern with change (base + change + cumulative + delta + rel + sum) + * @typedef {Brk.BaseChangeCumulativeDeltaRelSumPattern} NetPnlFullPattern + * + * Net PnL basic pattern (base + cumulative + delta + sum) + * @typedef {Brk.BaseCumulativeDeltaSumPattern} NetPnlBasicPattern + * + * Mid realized pattern (cap + loss + MVRV + net + price + profit + SOPR) + * @typedef {Brk.CapLossMvrvNetPriceProfitSoprPattern} MidRealizedPattern + * + * Basic realized pattern (cap + loss + MVRV + price + profit + SOPR, no net) + * @typedef {Brk.CapLossMvrvPriceProfitSoprPattern} BasicRealizedPattern + * + * Moving average price ratio pattern (bps + cents + ratio + sats + usd) + * @typedef {Brk.BpsCentsRatioSatsUsdPattern} MaPriceRatioPattern + * + * Address count delta pattern (inner delta with absolute + rate) + * @typedef {Brk.DeltaInnerPattern} AddressCountDeltaPattern */ /** * @template T * @typedef {Brk.SeriesEndpoint} SeriesEndpoint */ +/** + * Rolling windows pattern (24h, 1w, 1m, 1y) + * @template T + * @typedef {Brk._1m1w1y24hPattern} RollingWindowPattern + */ +/** + * Sell side risk rolling windows pattern + * @typedef {Brk._1m1w1y24hPattern6} SellSideRiskPattern + */ /** * Stats pattern: average, min, max, percentiles (height-only indexes, NO base) - * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} StatsPattern + * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} StatsPattern */ /** * Base stats pattern: average, min, max, percentiles - * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} BaseStatsPattern + * @typedef {Brk.AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern} BaseStatsPattern */ /** * Full stats pattern: cumulative, sum, average, min, max, percentiles + rolling @@ -125,7 +173,7 @@ */ /** * Full per-block pattern: height, cumulative, sum, and distribution stats (all flat) - * @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern} FullPerBlockPattern + * @typedef {Brk.AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern} FullPerBlockPattern */ /** * Any stats pattern union - patterns with sum/cumulative + percentiles @@ -158,8 +206,8 @@ * * Pattern unions by cohort type * @typedef {AllUtxoPattern | AgeRangePattern | UtxoAmountPattern} UtxoCohortPattern - * @typedef {AddressAmountPattern} AddressCohortPattern - * @typedef {UtxoCohortPattern | AddressCohortPattern} CohortPattern + * @typedef {AddrAmountPattern} AddrCohortPattern + * @typedef {UtxoCohortPattern | AddrCohortPattern} CohortPattern * * Relative pattern capability types * @typedef {GlobalRelativePattern | FullRelativePattern | AllRelativePattern} RelativeWithMarketCap @@ -204,10 +252,10 @@ * @typedef {CohortFull | CohortLongTerm | CohortWithAdjusted | CohortBasicWithMarketCap} UtxoCohortWithCirculatingSupplyRelative * * Address cohorts with circulating supply relative series (all address amount cohorts have these) - * @typedef {AddressCohortObject} AddressCohortWithCirculatingSupplyRelative + * @typedef {AddrCohortObject} AddrCohortWithCirculatingSupplyRelative * * All cohorts with circulating supply relative series - * @typedef {UtxoCohortWithCirculatingSupplyRelative | AddressCohortWithCirculatingSupplyRelative} CohortWithCirculatingSupplyRelative + * @typedef {UtxoCohortWithCirculatingSupplyRelative | AddrCohortWithCirculatingSupplyRelative} CohortWithCirculatingSupplyRelative * * Delta patterns with absolute + rate rolling windows * @typedef {Brk.AbsoluteRatePattern} DeltaPattern