mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
249
Cargo.lock
generated
249
Cargo.lock
generated
@@ -32,9 +32,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -494,6 +494,15 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk"
|
||||
version = "0.0.111"
|
||||
@@ -655,6 +664,7 @@ dependencies = [
|
||||
"rayon",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"vecdb",
|
||||
"zerocopy",
|
||||
]
|
||||
@@ -1428,9 +1438,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.42"
|
||||
version = "1.2.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81bbf3b3619004ad9bd139f62a9ab5cfe467f307455a0d307b0cf58bf070feaa"
|
||||
checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"jobserver",
|
||||
@@ -1477,9 +1487,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.50"
|
||||
version = "4.5.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623"
|
||||
checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -1487,9 +1497,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.50"
|
||||
version = "4.5.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0"
|
||||
checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -1746,11 +1756,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ctrlc"
|
||||
version = "3.5.0"
|
||||
version = "3.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3"
|
||||
checksum = "73736a89c4aff73035ba2ed2e565061954da00d4970fc9ac25dcc85a2a20d790"
|
||||
dependencies = [
|
||||
"dispatch",
|
||||
"dispatch2",
|
||||
"nix",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
@@ -1834,9 +1844,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.4"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071"
|
||||
checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
@@ -1895,32 +1905,17 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "6.0.0"
|
||||
name = "dispatch2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"block2",
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.61.2",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dispatch"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@@ -1970,9 +1965,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "endian-type"
|
||||
version = "0.1.2"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
|
||||
checksum = "869b0adbda23651a9c5c0c3d270aac9fcb52e8622a8f2b17e57802d7791962f2"
|
||||
|
||||
[[package]]
|
||||
name = "enum_dispatch"
|
||||
@@ -2120,6 +2115,12 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.2"
|
||||
@@ -2305,9 +2306,7 @@ version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash",
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2317,6 +2316,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2449,9 +2450,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47"
|
||||
checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"potential_utf",
|
||||
@@ -2462,9 +2463,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_locale_core"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a"
|
||||
checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"litemap",
|
||||
@@ -2475,11 +2476,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979"
|
||||
checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_normalizer_data",
|
||||
"icu_properties",
|
||||
@@ -2490,42 +2490,38 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer_data"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3"
|
||||
checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a"
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties"
|
||||
version = "2.0.1"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b"
|
||||
checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_locale_core",
|
||||
"icu_properties_data",
|
||||
"icu_provider",
|
||||
"potential_utf",
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties_data"
|
||||
version = "2.0.1"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632"
|
||||
checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899"
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af"
|
||||
checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locale_core",
|
||||
"stable_deref_trait",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
@@ -2699,9 +2695,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.81"
|
||||
version = "0.3.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||
checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -2797,9 +2793,9 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
|
||||
checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@@ -3085,6 +3081,21 @@ dependencies = [
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05"
|
||||
dependencies = [
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.37.3"
|
||||
@@ -3106,12 +3117,6 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "outref"
|
||||
version = "0.5.2"
|
||||
@@ -3166,9 +3171,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "oxc-miette"
|
||||
version = "2.5.1"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c42cefdcbebec6b0b72229ac0e02261a6770cb7ba39ccc5475a856164066db1"
|
||||
checksum = "f02105a875f3751a0b44b4c822b01177728dd9049ae6fb419e9b04887d730ed1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"owo-colors",
|
||||
@@ -3181,9 +3186,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "oxc-miette-derive"
|
||||
version = "2.5.1"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05bbaa5b6b98826bb62b164406f703bee72c5287af9986f9c863fa8ea992b476"
|
||||
checksum = "003b4612827f6501183873fb0735da92157e3c7daa71c40921c7d2758fec2229"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3813,13 +3818,12 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||
|
||||
[[package]]
|
||||
name = "pnp"
|
||||
version = "0.12.3"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a10a726fb86dab6571b148c0f52cf619a4aabf0ac4fcf578bd4cd2178fb0e6d0"
|
||||
checksum = "7adbc1ab7344e1e77be663e91cb129e989e398c319df7a9b8dbda9dd6758df38"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"concurrent_lru",
|
||||
"dirs",
|
||||
"fancy-regex",
|
||||
"miniz_oxide",
|
||||
"pathdiff",
|
||||
@@ -3847,9 +3851,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a"
|
||||
checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77"
|
||||
dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
@@ -3962,9 +3966,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "radix_trie"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd"
|
||||
checksum = "3b4431027dcd37fc2a73ef740b5f233aa805897935b8bce0195e41bbf9a3289a"
|
||||
dependencies = [
|
||||
"endian-type",
|
||||
"nibble_vec",
|
||||
@@ -4094,17 +4098,6 @@ dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
|
||||
dependencies = [
|
||||
"getrandom 0.2.16",
|
||||
"libredox",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref-cast"
|
||||
version = "1.0.25"
|
||||
@@ -4156,11 +4149,11 @@ checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
|
||||
[[package]]
|
||||
name = "regress"
|
||||
version = "0.10.4"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145bb27393fe455dd64d6cbc8d059adfa392590a45eadf079c01b11857e7b010"
|
||||
checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.5",
|
||||
"hashbrown 0.16.0",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
@@ -4393,7 +4386,6 @@ version = "0.2.17"
|
||||
dependencies = [
|
||||
"allocative",
|
||||
"libc",
|
||||
"log",
|
||||
"memmap2",
|
||||
"parking_lot 0.12.5",
|
||||
"rayon",
|
||||
@@ -4851,9 +4843,9 @@ checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"
|
||||
checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"zerovec",
|
||||
@@ -5160,9 +5152,9 @@ checksum = "81b79ad29b5e19de4260020f8919b443b2ef0277d242ce532ec7b7a2cc8b6007"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.20"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-linebreak"
|
||||
@@ -5350,9 +5342,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.104"
|
||||
version = "0.2.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||
checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -5361,25 +5353,11 @@ dependencies = [
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.104"
|
||||
version = "0.2.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||
checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -5387,22 +5365,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.104"
|
||||
version = "0.2.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.104"
|
||||
version = "0.2.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||
checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -5736,9 +5714,9 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
||||
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
|
||||
|
||||
[[package]]
|
||||
name = "xxhash-rust"
|
||||
@@ -5754,11 +5732,10 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
|
||||
checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
"zerofrom",
|
||||
@@ -5766,9 +5743,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yoke-derive"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
|
||||
checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5819,9 +5796,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerotrie"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595"
|
||||
checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"yoke",
|
||||
@@ -5830,9 +5807,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.11.4"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b"
|
||||
checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002"
|
||||
dependencies = [
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
@@ -5841,9 +5818,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerovec-derive"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
|
||||
checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5872,9 +5849,9 @@ checksum = "2f06ae92f42f5e5c42443fd094f245eb656abf56dd7cce9b8b263236565e00f2"
|
||||
|
||||
[[package]]
|
||||
name = "zopfli"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edfc5ee405f504cd4984ecc6f14d02d55cfda60fa4b689434ef4102aae150cd7"
|
||||
checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"crc32fast",
|
||||
|
||||
@@ -23,7 +23,7 @@ brk_reader = { workspace = true }
|
||||
brk_rpc = { workspace = true }
|
||||
brk_server = { workspace = true }
|
||||
vecdb = { workspace = true }
|
||||
clap = { version = "4.5.50", features = ["derive", "string"] }
|
||||
clap = { version = "4.5.51", features = ["derive", "string"] }
|
||||
color-eyre = "0.6.5"
|
||||
log = { workspace = true }
|
||||
minreq = { workspace = true }
|
||||
|
||||
@@ -29,5 +29,6 @@ pco = "0.4.7"
|
||||
rayon = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
smallvec = "1.15.1"
|
||||
vecdb = { workspace = true }
|
||||
zerocopy = { workspace = true }
|
||||
|
||||
@@ -98,7 +98,7 @@ pub struct Vecs {
|
||||
pub indexes_to_tx_vsize: ComputedVecsFromTxindex<StoredU64>,
|
||||
pub indexes_to_tx_weight: ComputedVecsFromTxindex<Weight>,
|
||||
pub indexes_to_unknownoutput_count: ComputedVecsFromHeight<StoredU64>,
|
||||
pub txinindex_to_value: LazyVecFrom2<TxInIndex, Sats, TxInIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub txinindex_to_value: EagerVec<TxInIndex, Sats>,
|
||||
pub indexes_to_input_count: ComputedVecsFromTxindex<StoredU64>,
|
||||
pub txindex_to_is_coinbase: LazyVecFrom2<TxIndex, StoredBool, TxIndex, Height, Height, TxIndex>,
|
||||
pub indexes_to_output_count: ComputedVecsFromTxindex<StoredU64>,
|
||||
@@ -158,29 +158,8 @@ impl Vecs {
|
||||
|
||||
let compute_dollars = price.is_some();
|
||||
|
||||
let txinindex_to_value = LazyVecFrom2::init(
|
||||
"value",
|
||||
version + Version::ZERO,
|
||||
indexes.txinindex_to_txoutindex.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index: TxInIndex, txinindex_to_txoutindex_iter, txoutindex_to_value_iter| {
|
||||
txinindex_to_txoutindex_iter.next_at(index.to_usize()).map(
|
||||
|(txinindex, txoutindex)| {
|
||||
let txoutindex = txoutindex.into_owned();
|
||||
if txoutindex == TxOutIndex::COINBASE {
|
||||
Sats::MAX
|
||||
} else if let Some((_, value)) =
|
||||
txoutindex_to_value_iter.next_at(txoutindex.to_usize())
|
||||
{
|
||||
value.into_owned()
|
||||
} else {
|
||||
dbg!(txinindex, txoutindex);
|
||||
panic!()
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
);
|
||||
let txinindex_to_value: EagerVec<TxInIndex, Sats> =
|
||||
EagerVec::forced_import_compressed(&db, "value", version + Version::ZERO)?;
|
||||
|
||||
let txindex_to_weight = LazyVecFrom2::init(
|
||||
"weight",
|
||||
@@ -192,12 +171,7 @@ impl Vecs {
|
||||
txindex_to_base_size_iter
|
||||
.next_at(index)
|
||||
.map(|(_, base_size)| {
|
||||
let base_size = base_size.into_owned();
|
||||
let total_size = txindex_to_total_size_iter
|
||||
.next_at(index)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
let total_size = txindex_to_total_size_iter.next_at(index).unwrap().1;
|
||||
|
||||
// This is the exact definition of a weight unit, as defined by BIP-141 (quote above).
|
||||
let wu = usize::from(base_size) * 3 + usize::from(total_size);
|
||||
@@ -214,9 +188,7 @@ impl Vecs {
|
||||
|index: TxIndex, iter| {
|
||||
let index = index.to_usize();
|
||||
iter.next_at(index).map(|(_, weight)| {
|
||||
StoredU64::from(
|
||||
bitcoin::Weight::from(weight.into_owned()).to_vbytes_ceil() as usize
|
||||
)
|
||||
StoredU64::from(bitcoin::Weight::from(weight).to_vbytes_ceil() as usize)
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -230,12 +202,10 @@ impl Vecs {
|
||||
txindex_to_height_iter
|
||||
.next_at(index.to_usize())
|
||||
.map(|(_, height)| {
|
||||
let height = height.into_owned();
|
||||
let txindex = height_to_first_txindex_iter
|
||||
.next_at(height.to_usize())
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
.1;
|
||||
StoredBool::from(index == txindex)
|
||||
})
|
||||
},
|
||||
@@ -255,20 +225,11 @@ impl Vecs {
|
||||
txindex_to_first_txinindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, first_index)| {
|
||||
let first_index = usize::from(first_index.into_owned());
|
||||
let count = *txindex_to_input_count_iter
|
||||
.next_at(txindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
let first_index = usize::from(first_index);
|
||||
let count = *txindex_to_input_count_iter.next_at(txindex).unwrap().1;
|
||||
let range = first_index..first_index + count as usize;
|
||||
range.into_iter().fold(Sats::ZERO, |total, txinindex| {
|
||||
total
|
||||
+ txinindex_to_value_iter
|
||||
.next_at(txinindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned()
|
||||
total + txinindex_to_value_iter.next_at(txinindex).unwrap().1
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -302,19 +263,11 @@ impl Vecs {
|
||||
txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, first_index)| {
|
||||
let first_index = usize::from(first_index.into_owned());
|
||||
let count = *txindex_to_output_count_iter
|
||||
.next_at(txindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
let first_index = usize::from(first_index);
|
||||
let count = *txindex_to_output_count_iter.next_at(txindex).unwrap().1;
|
||||
let range = first_index..first_index + count as usize;
|
||||
range.into_iter().fold(Sats::ZERO, |total, txoutindex| {
|
||||
let v = txoutindex_to_value_iter
|
||||
.next_at(txoutindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned();
|
||||
let v = txoutindex_to_value_iter.next_at(txoutindex).unwrap().1;
|
||||
total + v
|
||||
})
|
||||
})
|
||||
@@ -1424,6 +1377,41 @@ impl Vecs {
|
||||
compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v2, TxVersion::TWO)?;
|
||||
compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v3, TxVersion::THREE)?;
|
||||
|
||||
let mut txoutindex_to_value_iter = indexer.vecs.txoutindex_to_value.into_iter();
|
||||
self.txinindex_to_value.compute_transform(
|
||||
starting_indexes.txinindex,
|
||||
&indexes.txinindex_to_txoutindex,
|
||||
|(txinindex, txoutindex, ..)| {
|
||||
let value = if txoutindex == TxOutIndex::COINBASE {
|
||||
Sats::MAX
|
||||
} else {
|
||||
txoutindex_to_value_iter.unwrap_get_inner(txoutindex)
|
||||
};
|
||||
(txinindex, value)
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// indexes.txinindex_to_txoutindex.boxed_clone(),
|
||||
// indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
// |index: TxInIndex, txinindex_to_txoutindex_iter, txoutindex_to_value_iter| {
|
||||
// txinindex_to_txoutindex_iter.next_at(index.to_usize()).map(
|
||||
// |(txinindex, txoutindex)| {
|
||||
// let txoutindex = txoutindex;
|
||||
// if txoutindex == TxOutIndex::COINBASE {
|
||||
// Sats::MAX
|
||||
// } else if let Some((_, value)) =
|
||||
// txoutindex_to_value_iter.next_at(txoutindex.to_usize())
|
||||
// {
|
||||
// value
|
||||
// } else {
|
||||
// dbg!(txinindex, txoutindex);
|
||||
// panic!()
|
||||
// }
|
||||
// },
|
||||
// )
|
||||
// },
|
||||
|
||||
// self.indexes_to_output_value.compute_all(
|
||||
// indexer,
|
||||
// indexes,
|
||||
|
||||
@@ -78,7 +78,6 @@ impl Vecs {
|
||||
height_to_timestamp
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let v = v.into_owned();
|
||||
self.height_to_price_ohlc_in_cents.forced_push_at(
|
||||
i,
|
||||
self.fetcher
|
||||
@@ -103,8 +102,7 @@ impl Vecs {
|
||||
indexes
|
||||
.dateindex_to_date
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let d = v.into_owned();
|
||||
.try_for_each(|(i, d)| -> Result<()> {
|
||||
if prev.is_none() {
|
||||
let i = i.to_usize();
|
||||
prev.replace(if i > 0 {
|
||||
|
||||
@@ -222,7 +222,7 @@ where
|
||||
cumulative_vec.iter().unwrap_get_inner(index)
|
||||
});
|
||||
source.iter_at(index).try_for_each(|(i, v)| -> Result<()> {
|
||||
cumulative += v.into_owned();
|
||||
cumulative += v;
|
||||
cumulative_vec.forced_push_at(i, cumulative, exit)?;
|
||||
Ok(())
|
||||
})?;
|
||||
@@ -263,8 +263,6 @@ where
|
||||
first_indexes
|
||||
.iter_at(index)
|
||||
.try_for_each(|(index, first_index)| -> Result<()> {
|
||||
let first_index = first_index.into_owned();
|
||||
|
||||
let count_index = count_indexes_iter.unwrap_get_inner(index);
|
||||
|
||||
if let Some(first) = self.first.as_mut() {
|
||||
@@ -286,7 +284,7 @@ where
|
||||
// dbg!(first_index, count_index, last_index);
|
||||
// })
|
||||
// .unwrap()
|
||||
// .into_owned();
|
||||
// ;
|
||||
last.forced_push_at(index, v, exit)?;
|
||||
}
|
||||
|
||||
@@ -306,7 +304,7 @@ where
|
||||
source_iter.set(first_index);
|
||||
let mut values = (&mut source_iter)
|
||||
.take(*count_index as usize)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if needs_sorted {
|
||||
@@ -436,8 +434,6 @@ where
|
||||
first_indexes
|
||||
.iter_at(index)
|
||||
.try_for_each(|(index, first_index, ..)| -> Result<()> {
|
||||
let first_index = first_index.into_owned();
|
||||
|
||||
let count_index = count_indexes_iter.unwrap_get_inner(index);
|
||||
|
||||
if let Some(first) = self.first.as_mut() {
|
||||
@@ -474,7 +470,7 @@ where
|
||||
source_max_iter.set(first_index);
|
||||
let mut values = source_max_iter
|
||||
.take(*count_index as usize)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>();
|
||||
values.sort_unstable();
|
||||
max.forced_push_at(index, *values.last().unwrap(), exit)?;
|
||||
@@ -485,7 +481,7 @@ where
|
||||
source_min_iter.set(first_index);
|
||||
let mut values = source_min_iter
|
||||
.take(*count_index as usize)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>();
|
||||
values.sort_unstable();
|
||||
min.forced_push_at(index, *values.first().unwrap(), exit)?;
|
||||
@@ -498,7 +494,7 @@ where
|
||||
source_average_iter.set(first_index);
|
||||
let values = source_average_iter
|
||||
.take(*count_index as usize)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let len = values.len();
|
||||
@@ -514,7 +510,7 @@ where
|
||||
source_sum_iter.set(first_index);
|
||||
let values = source_sum_iter
|
||||
.take(*count_index as usize)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let sum = values.into_iter().fold(T::from(0), |a, b| a + b);
|
||||
|
||||
@@ -71,9 +71,7 @@ where
|
||||
if i.to_usize() >= len_source.len() {
|
||||
return None;
|
||||
}
|
||||
source
|
||||
.next_at(S1I::min_from(i))
|
||||
.map(|(_, cow)| cow.into_owned())
|
||||
source.next_at(S1I::min_from(i)).map(|(_, v)| v)
|
||||
},
|
||||
))
|
||||
}),
|
||||
@@ -100,7 +98,7 @@ where
|
||||
}
|
||||
source
|
||||
.next_at(S1I::max_from(i, source.len()))
|
||||
.map(|(_, cow)| cow.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
},
|
||||
))
|
||||
}),
|
||||
@@ -118,7 +116,7 @@ where
|
||||
return None;
|
||||
}
|
||||
S1I::inclusive_range_from(i, source.len())
|
||||
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
|
||||
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
|
||||
.min()
|
||||
},
|
||||
))
|
||||
@@ -137,7 +135,7 @@ where
|
||||
return None;
|
||||
}
|
||||
S1I::inclusive_range_from(i, source.len())
|
||||
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
|
||||
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
|
||||
.max()
|
||||
},
|
||||
))
|
||||
@@ -156,7 +154,7 @@ where
|
||||
return None;
|
||||
}
|
||||
let vec = S1I::inclusive_range_from(i, source.len())
|
||||
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
|
||||
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
|
||||
.collect::<Vec<_>>();
|
||||
if vec.is_empty() {
|
||||
return None;
|
||||
@@ -186,7 +184,7 @@ where
|
||||
return None;
|
||||
}
|
||||
let vec = S1I::inclusive_range_from(i, source.len())
|
||||
.flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned()))
|
||||
.flat_map(|i| source.next_at(i).map(|(_, v)| v))
|
||||
.collect::<Vec<_>>();
|
||||
if vec.is_empty() {
|
||||
return None;
|
||||
@@ -209,7 +207,7 @@ where
|
||||
}
|
||||
source
|
||||
.next_at(S1I::max_from(i, source.len()))
|
||||
.map(|(_, cow)| cow.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
},
|
||||
))
|
||||
}),
|
||||
@@ -259,6 +257,7 @@ pub struct LazyVecBuilderOptions {
|
||||
}
|
||||
|
||||
impl From<VecBuilderOptions> for LazyVecBuilderOptions {
|
||||
#[inline]
|
||||
fn from(value: VecBuilderOptions) -> Self {
|
||||
Self {
|
||||
average: value.average(),
|
||||
|
||||
@@ -440,7 +440,6 @@ impl ComputedRatioVecsFromDateIndex {
|
||||
.unwrap()
|
||||
.forced_push_at(index, StoredF32::NAN, exit)?;
|
||||
} else {
|
||||
let ratio = ratio.into_owned();
|
||||
let pos = sorted.binary_search(&ratio).unwrap_or_else(|pos| pos);
|
||||
sorted.insert(pos, ratio);
|
||||
|
||||
|
||||
@@ -545,7 +545,6 @@ impl ComputedStandardDeviationVecsFromDateIndex {
|
||||
v.forced_push_at(index, StoredF32::NAN, exit)?
|
||||
}
|
||||
} else {
|
||||
let ratio = ratio.into_owned();
|
||||
let pos = sorted.binary_search(&ratio).unwrap_or_else(|pos| pos);
|
||||
sorted.insert(pos, ratio);
|
||||
|
||||
|
||||
@@ -29,18 +29,21 @@ impl<I, T> Source<I, T> {
|
||||
}
|
||||
|
||||
impl<I, T> From<bool> for Source<I, T> {
|
||||
#[inline]
|
||||
fn from(value: bool) -> Self {
|
||||
if value { Self::Compute } else { Self::None }
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, T> From<AnyBoxedIterableVec<I, T>> for Source<I, T> {
|
||||
#[inline]
|
||||
fn from(value: AnyBoxedIterableVec<I, T>) -> Self {
|
||||
Self::Vec(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, T> From<Option<AnyBoxedIterableVec<I, T>>> for Source<I, T> {
|
||||
#[inline]
|
||||
fn from(value: Option<AnyBoxedIterableVec<I, T>>) -> Self {
|
||||
if let Some(v) = value {
|
||||
Self::Vec(v)
|
||||
|
||||
@@ -59,10 +59,8 @@ impl ComputedValueVecsFromTxindex {
|
||||
version + VERSION,
|
||||
source_vec.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s),
|
||||
|txindex: TxIndex, iter| {
|
||||
iter.next_at(txindex.to_usize()).map(|(_, value)| {
|
||||
let sats = value.into_owned();
|
||||
Bitcoin::from(sats)
|
||||
})
|
||||
iter.next_at(txindex.to_usize())
|
||||
.map(|(_, sats)| Bitcoin::from(sats))
|
||||
},
|
||||
);
|
||||
|
||||
@@ -87,15 +85,13 @@ impl ComputedValueVecsFromTxindex {
|
||||
txindex_to_height_iter,
|
||||
height_to_price_close_iter| {
|
||||
let txindex = txindex.to_usize();
|
||||
txindex_to_btc_iter.next_at(txindex).and_then(|(_, value)| {
|
||||
let btc = value.into_owned();
|
||||
txindex_to_btc_iter.next_at(txindex).and_then(|(_, btc)| {
|
||||
txindex_to_height_iter
|
||||
.next_at(txindex)
|
||||
.and_then(|(_, value)| {
|
||||
let height = value.into_owned();
|
||||
.and_then(|(_, height)| {
|
||||
height_to_price_close_iter
|
||||
.next_at(height.to_usize())
|
||||
.map(|(_, close)| *close.into_owned() * btc)
|
||||
.map(|(_, close)| *close * btc)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -119,7 +119,6 @@ impl Vecs {
|
||||
txinindex_to_outpoint_iter
|
||||
.next_at(index.to_usize())
|
||||
.map(|(_, outpoint)| {
|
||||
let outpoint = outpoint.into_owned();
|
||||
if outpoint.is_coinbase() {
|
||||
return TxOutIndex::COINBASE;
|
||||
}
|
||||
@@ -127,7 +126,6 @@ impl Vecs {
|
||||
.next_at(outpoint.txindex().to_usize())
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned()
|
||||
+ outpoint.vout()
|
||||
})
|
||||
},
|
||||
@@ -164,10 +162,10 @@ impl Vecs {
|
||||
txindex_to_first_txinindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, start)| {
|
||||
let start = usize::from(start.into_owned());
|
||||
let start = usize::from(start);
|
||||
let end = txindex_to_first_txinindex_iter
|
||||
.next_at(txindex + 1)
|
||||
.map(|(_, v)| usize::from(v.into_owned()))
|
||||
.map(|(_, v)| usize::from(v))
|
||||
.unwrap_or_else(|| txinindex_to_txoutindex_iter.len());
|
||||
StoredU64::from((start..end).count())
|
||||
})
|
||||
@@ -184,10 +182,10 @@ impl Vecs {
|
||||
txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex)
|
||||
.map(|(_, start)| {
|
||||
let start = usize::from(start.into_owned());
|
||||
let start = usize::from(start);
|
||||
let end = txindex_to_first_txoutindex_iter
|
||||
.next_at(txindex + 1)
|
||||
.map(|(_, v)| usize::from(v.into_owned()))
|
||||
.map(|(_, v)| usize::from(v))
|
||||
.unwrap_or_else(|| txoutindex_to_value_iter.len());
|
||||
StoredU64::from((start..end).count())
|
||||
})
|
||||
|
||||
@@ -389,11 +389,8 @@ impl Vecs {
|
||||
.height_to_price_ohlc_in_cents
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
self.height_to_price_ohlc.forced_push_at(
|
||||
i,
|
||||
OHLCDollars::from(v.into_owned()),
|
||||
exit,
|
||||
)?;
|
||||
self.height_to_price_ohlc
|
||||
.forced_push_at(i, OHLCDollars::from(v), exit)?;
|
||||
Ok(())
|
||||
})?;
|
||||
self.height_to_price_ohlc.safe_flush(exit)?;
|
||||
@@ -433,11 +430,8 @@ impl Vecs {
|
||||
.dateindex_to_price_ohlc_in_cents
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
self.dateindex_to_price_ohlc.forced_push_at(
|
||||
i,
|
||||
OHLCDollars::from(v.into_owned()),
|
||||
exit,
|
||||
)?;
|
||||
self.dateindex_to_price_ohlc
|
||||
.forced_push_at(i, OHLCDollars::from(v), exit)?;
|
||||
Ok(())
|
||||
})?;
|
||||
self.dateindex_to_price_ohlc.safe_flush(exit)?;
|
||||
@@ -544,8 +538,7 @@ impl Vecs {
|
||||
.weekindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = weekindex_first_iter.unwrap_get_inner(i);
|
||||
let high = weekindex_max_iter.unwrap_get_inner(i);
|
||||
let low = weekindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -585,8 +578,7 @@ impl Vecs {
|
||||
.difficultyepoch
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = difficultyepoch_first_iter.unwrap_get_inner(i);
|
||||
let high = difficultyepoch_max_iter.unwrap_get_inner(i);
|
||||
let low = difficultyepoch_min_iter.unwrap_get_inner(i);
|
||||
@@ -622,8 +614,7 @@ impl Vecs {
|
||||
.monthindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = monthindex_first_iter.unwrap_get_inner(i);
|
||||
let high = monthindex_max_iter.unwrap_get_inner(i);
|
||||
let low = monthindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -663,8 +654,7 @@ impl Vecs {
|
||||
.quarterindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = quarterindex_first_iter.unwrap_get_inner(i);
|
||||
let high = quarterindex_max_iter.unwrap_get_inner(i);
|
||||
let low = quarterindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -704,8 +694,7 @@ impl Vecs {
|
||||
.semesterindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = semesterindex_first_iter.unwrap_get_inner(i);
|
||||
let high = semesterindex_max_iter.unwrap_get_inner(i);
|
||||
let low = semesterindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -737,8 +726,7 @@ impl Vecs {
|
||||
.yearindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = yearindex_first_iter.unwrap_get_inner(i);
|
||||
let high = yearindex_max_iter.unwrap_get_inner(i);
|
||||
let low = yearindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -781,8 +769,7 @@ impl Vecs {
|
||||
.decadeindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
let open = decadeindex_first_iter.unwrap_get_inner(i);
|
||||
let high = decadeindex_max_iter.unwrap_get_inner(i);
|
||||
let low = decadeindex_min_iter.unwrap_get_inner(i);
|
||||
@@ -897,8 +884,7 @@ impl Vecs {
|
||||
self.chainindexes_to_price_close_in_sats
|
||||
.height
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.height_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -939,8 +925,7 @@ impl Vecs {
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.dateindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -977,8 +962,7 @@ impl Vecs {
|
||||
.weekindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.weekindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1015,8 +999,7 @@ impl Vecs {
|
||||
.difficultyepoch
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.difficultyepoch_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1054,8 +1037,7 @@ impl Vecs {
|
||||
.monthindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.monthindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1092,8 +1074,7 @@ impl Vecs {
|
||||
.quarterindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.quarterindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1130,8 +1111,7 @@ impl Vecs {
|
||||
.semesterindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.semesterindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1168,8 +1148,7 @@ impl Vecs {
|
||||
.yearindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.yearindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
@@ -1209,8 +1188,7 @@ impl Vecs {
|
||||
.decadeindex
|
||||
.unwrap_last()
|
||||
.iter_at(index)
|
||||
.try_for_each(|(i, v)| -> Result<()> {
|
||||
let close = v.into_owned();
|
||||
.try_for_each(|(i, close)| -> Result<()> {
|
||||
self.decadeindex_to_price_ohlc_in_sats.forced_push_at(
|
||||
i,
|
||||
OHLCSats {
|
||||
|
||||
@@ -9,6 +9,7 @@ use super::AddressTypeToHeightToAddressCount;
|
||||
pub struct AddressTypeToAddressCount(ByAddressType<u64>);
|
||||
|
||||
impl From<(&AddressTypeToHeightToAddressCount, Height)> for AddressTypeToAddressCount {
|
||||
#[inline]
|
||||
fn from((groups, starting_height): (&AddressTypeToHeightToAddressCount, Height)) -> Self {
|
||||
if let Some(prev_height) = starting_height.decremented() {
|
||||
Self(ByAddressType {
|
||||
|
||||
@@ -11,6 +11,7 @@ use super::AddressTypeToAddressCount;
|
||||
pub struct AddressTypeToHeightToAddressCount(ByAddressType<EagerVec<Height, StoredU64>>);
|
||||
|
||||
impl From<ByAddressType<EagerVec<Height, StoredU64>>> for AddressTypeToHeightToAddressCount {
|
||||
#[inline]
|
||||
fn from(value: ByAddressType<EagerVec<Height, StoredU64>>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use super::AddressTypeToHeightToAddressCount;
|
||||
pub struct AddressTypeToIndexesToAddressCount(ByAddressType<ComputedVecsFromHeight<StoredU64>>);
|
||||
|
||||
impl From<ByAddressType<ComputedVecsFromHeight<StoredU64>>> for AddressTypeToIndexesToAddressCount {
|
||||
#[inline]
|
||||
fn from(value: ByAddressType<ComputedVecsFromHeight<StoredU64>>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -66,3 +66,26 @@ impl<T> Default for AddressTypeToTypeIndexMap<T> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AddressTypeToTypeIndexMap<Vec<T>>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
pub fn merge_vec(mut self, other: Self) -> Self {
|
||||
for (address_type, other_map) in other.0.into_iter_typed() {
|
||||
let self_map = self.0.get_mut_unwrap(address_type);
|
||||
for (typeindex, mut other_vec) in other_map {
|
||||
self_map
|
||||
.entry(typeindex)
|
||||
.and_modify(|self_vec| {
|
||||
if other_vec.len() > self_vec.len() {
|
||||
mem::swap(self_vec, &mut other_vec);
|
||||
}
|
||||
self_vec.extend(other_vec.iter().copied());
|
||||
})
|
||||
.or_insert(other_vec);
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,17 @@ use brk_types::{
|
||||
AnyAddressDataIndexEnum, AnyAddressIndex, CheckedSub, DateIndex, Dollars, EmptyAddressData,
|
||||
EmptyAddressIndex, Height, LoadedAddressData, LoadedAddressIndex, OutputType, P2AAddressIndex,
|
||||
P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex,
|
||||
P2WPKHAddressIndex, P2WSHAddressIndex, Sats, StoredU64, Timestamp, TxInIndex, TxOutIndex,
|
||||
TypeIndex, Version,
|
||||
P2WPKHAddressIndex, P2WSHAddressIndex, Sats, StoredU64, Timestamp, TxInIndex, TxIndex,
|
||||
TxOutIndex, TypeIndex, Version,
|
||||
};
|
||||
use log::info;
|
||||
use rayon::prelude::*;
|
||||
use rustc_hash::FxHashMap;
|
||||
use smallvec::SmallVec;
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit,
|
||||
Format, GenericStoredVec, ImportOptions, LazyVecFrom1, PAGE_SIZE, RawVec, Reader, Stamp,
|
||||
StoredIndex, VecIterator,
|
||||
AnyCloneableIterableVec, AnyIterableVec, AnyStoredVec, AnyVec, BoxedVecIterator,
|
||||
CollectableVec, Database, EagerVec, Exit, Format, GenericStoredVec, ImportOptions,
|
||||
LazyVecFrom1, PAGE_SIZE, RawVec, Reader, Stamp, StoredIndex, VecIterator,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -44,6 +45,8 @@ use range_map::*;
|
||||
use r#trait::*;
|
||||
use withaddressdatasource::*;
|
||||
|
||||
type TxIndexVec = SmallVec<[TxIndex; 4]>;
|
||||
|
||||
const VERSION: Version = Version::new(21);
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
@@ -186,12 +189,7 @@ impl Vecs {
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.boxed_clone(),
|
||||
|height: Height, iter| {
|
||||
iter.next_at(height.to_usize()).map(|(_, value)| {
|
||||
let d: Dollars = value.into_owned();
|
||||
d
|
||||
})
|
||||
},
|
||||
|height: Height, iter| iter.next_at(height.to_usize()).map(|(_, d)| d),
|
||||
)
|
||||
}),
|
||||
indexes_to_market_cap: compute_dollars.then(|| {
|
||||
@@ -519,8 +517,12 @@ impl Vecs {
|
||||
starting_indexes: &mut Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex;
|
||||
let height_to_first_txinindex = &indexer.vecs.height_to_first_txinindex;
|
||||
let dateindex_to_first_height = &indexes.dateindex_to_first_height;
|
||||
let dateindex_to_height_count = &indexes.dateindex_to_height_count;
|
||||
let dateindex_to_price_close = price
|
||||
.as_ref()
|
||||
.map(|price| price.timeindexes_to_price_close.dateindex.as_ref().unwrap());
|
||||
let height_to_date_fixed = &indexes.height_to_date_fixed;
|
||||
let height_to_first_p2aaddressindex = &indexer.vecs.height_to_first_p2aaddressindex;
|
||||
let height_to_first_p2pk33addressindex = &indexer.vecs.height_to_first_p2pk33addressindex;
|
||||
let height_to_first_p2pk65addressindex = &indexer.vecs.height_to_first_p2pk65addressindex;
|
||||
@@ -529,38 +531,42 @@ impl Vecs {
|
||||
let height_to_first_p2traddressindex = &indexer.vecs.height_to_first_p2traddressindex;
|
||||
let height_to_first_p2wpkhaddressindex = &indexer.vecs.height_to_first_p2wpkhaddressindex;
|
||||
let height_to_first_p2wshaddressindex = &indexer.vecs.height_to_first_p2wshaddressindex;
|
||||
let height_to_output_count = chain.indexes_to_output_count.height.unwrap_sum();
|
||||
let height_to_first_txindex = &indexer.vecs.height_to_first_txindex;
|
||||
let height_to_first_txinindex = &indexer.vecs.height_to_first_txinindex;
|
||||
let height_to_first_txoutindex = &indexer.vecs.height_to_first_txoutindex;
|
||||
let height_to_input_count = chain.indexes_to_input_count.height.unwrap_sum();
|
||||
let txinindex_to_outpoint = &indexer.vecs.txinindex_to_outpoint;
|
||||
let txindex_to_first_txoutindex = &indexer.vecs.txindex_to_first_txoutindex;
|
||||
let txoutindex_to_value = &indexer.vecs.txoutindex_to_value;
|
||||
let txindex_to_height = &indexer.vecs.txindex_to_height;
|
||||
let height_to_output_count = chain.indexes_to_output_count.height.unwrap_sum();
|
||||
let height_to_price_close = price
|
||||
.as_ref()
|
||||
.map(|price| &price.chainindexes_to_price_close.height);
|
||||
let height_to_timestamp_fixed = &indexes.height_to_timestamp_fixed;
|
||||
let txoutindex_to_txindex = &indexer.vecs.txoutindex_to_txindex;
|
||||
let txoutindex_to_outputtype = &indexer.vecs.txoutindex_to_outputtype;
|
||||
let txoutindex_to_typeindex = &indexer.vecs.txoutindex_to_typeindex;
|
||||
let height_to_tx_count = chain.indexes_to_tx_count.height.as_ref().unwrap();
|
||||
let height_to_unclaimed_rewards = chain
|
||||
.indexes_to_unclaimed_rewards
|
||||
.sats
|
||||
.height
|
||||
.as_ref()
|
||||
.unwrap();
|
||||
let height_to_price_close = price
|
||||
.as_ref()
|
||||
.map(|price| &price.chainindexes_to_price_close.height);
|
||||
let dateindex_to_price_close = price
|
||||
.as_ref()
|
||||
.map(|price| price.timeindexes_to_price_close.dateindex.as_ref().unwrap());
|
||||
let height_to_date_fixed = &indexes.height_to_date_fixed;
|
||||
let dateindex_to_first_height = &indexes.dateindex_to_first_height;
|
||||
let dateindex_to_height_count = &indexes.dateindex_to_height_count;
|
||||
let txindex_to_first_txoutindex = &indexer.vecs.txindex_to_first_txoutindex;
|
||||
let txindex_to_height = &indexer.vecs.txindex_to_height;
|
||||
let txindex_to_input_count = &indexes.txindex_to_input_count;
|
||||
let txindex_to_output_count = &indexes.txindex_to_output_count;
|
||||
let txinindex_to_outpoint = &indexer.vecs.txinindex_to_outpoint;
|
||||
let txoutindex_to_outputtype = &indexer.vecs.txoutindex_to_outputtype;
|
||||
let txoutindex_to_txindex = &indexer.vecs.txoutindex_to_txindex;
|
||||
let txoutindex_to_typeindex = &indexer.vecs.txoutindex_to_typeindex;
|
||||
let txoutindex_to_value = &indexer.vecs.txoutindex_to_value;
|
||||
|
||||
let mut height_to_price_close_iter = height_to_price_close.as_ref().map(|v| v.into_iter());
|
||||
let mut height_to_timestamp_fixed_iter = height_to_timestamp_fixed.into_iter();
|
||||
|
||||
let base_version = Version::ZERO
|
||||
+ height_to_first_txoutindex.version()
|
||||
+ height_to_first_txinindex.version()
|
||||
+ dateindex_to_first_height.version()
|
||||
+ dateindex_to_height_count.version()
|
||||
+ dateindex_to_price_close
|
||||
.as_ref()
|
||||
.map_or(Version::ZERO, |v| v.version())
|
||||
+ height_to_date_fixed.version()
|
||||
+ height_to_first_p2aaddressindex.version()
|
||||
+ height_to_first_p2pk33addressindex.version()
|
||||
+ height_to_first_p2pk65addressindex.version()
|
||||
@@ -569,26 +575,26 @@ impl Vecs {
|
||||
+ height_to_first_p2traddressindex.version()
|
||||
+ height_to_first_p2wpkhaddressindex.version()
|
||||
+ height_to_first_p2wshaddressindex.version()
|
||||
+ height_to_timestamp_fixed.version()
|
||||
+ height_to_output_count.version()
|
||||
+ height_to_first_txindex.version()
|
||||
+ height_to_first_txinindex.version()
|
||||
+ height_to_first_txoutindex.version()
|
||||
+ height_to_input_count.version()
|
||||
+ txinindex_to_outpoint.version()
|
||||
+ txoutindex_to_value.version()
|
||||
+ txindex_to_height.version()
|
||||
+ txindex_to_first_txoutindex.version()
|
||||
+ txoutindex_to_txindex.version()
|
||||
+ txoutindex_to_outputtype.version()
|
||||
+ txoutindex_to_typeindex.version()
|
||||
+ height_to_unclaimed_rewards.version()
|
||||
+ height_to_output_count.version()
|
||||
+ height_to_price_close
|
||||
.as_ref()
|
||||
.map_or(Version::ZERO, |v| v.version())
|
||||
+ dateindex_to_price_close
|
||||
.as_ref()
|
||||
.map_or(Version::ZERO, |v| v.version())
|
||||
+ height_to_date_fixed.version()
|
||||
+ dateindex_to_first_height.version()
|
||||
+ dateindex_to_height_count.version();
|
||||
+ height_to_timestamp_fixed.version()
|
||||
+ height_to_tx_count.version()
|
||||
+ height_to_unclaimed_rewards.version()
|
||||
+ txindex_to_first_txoutindex.version()
|
||||
+ txindex_to_height.version()
|
||||
+ txindex_to_input_count.version()
|
||||
+ txindex_to_output_count.version()
|
||||
+ txinindex_to_outpoint.version()
|
||||
+ txoutindex_to_outputtype.version()
|
||||
+ txoutindex_to_txindex.version()
|
||||
+ txoutindex_to_typeindex.version()
|
||||
+ txoutindex_to_value.version();
|
||||
|
||||
let mut separate_utxo_vecs = self.utxo_cohorts.iter_separate_mut().collect::<Vec<_>>();
|
||||
let mut separate_address_vecs =
|
||||
@@ -748,8 +754,11 @@ impl Vecs {
|
||||
|
||||
let ir = IndexerReaders::new(indexer);
|
||||
|
||||
let mut height_to_first_txoutindex_iter = height_to_first_txoutindex.into_iter();
|
||||
let mut height_to_first_txinindex_iter = height_to_first_txinindex.into_iter();
|
||||
let mut dateindex_to_first_height_iter = dateindex_to_first_height.into_iter();
|
||||
let mut dateindex_to_height_count_iter = dateindex_to_height_count.into_iter();
|
||||
let mut dateindex_to_price_close_iter =
|
||||
dateindex_to_price_close.as_ref().map(|v| v.into_iter());
|
||||
let mut height_to_date_fixed_iter = height_to_date_fixed.into_iter();
|
||||
let mut height_to_first_p2aaddressindex_iter =
|
||||
height_to_first_p2aaddressindex.into_iter();
|
||||
let mut height_to_first_p2pk33addressindex_iter =
|
||||
@@ -766,14 +775,15 @@ impl Vecs {
|
||||
height_to_first_p2wpkhaddressindex.into_iter();
|
||||
let mut height_to_first_p2wshaddressindex_iter =
|
||||
height_to_first_p2wshaddressindex.into_iter();
|
||||
let mut height_to_output_count_iter = height_to_output_count.into_iter();
|
||||
let mut height_to_first_txindex_iter = height_to_first_txindex.into_iter();
|
||||
let mut height_to_first_txinindex_iter = height_to_first_txinindex.into_iter();
|
||||
let mut height_to_first_txoutindex_iter = height_to_first_txoutindex.into_iter();
|
||||
let mut height_to_input_count_iter = height_to_input_count.into_iter();
|
||||
let mut height_to_output_count_iter = height_to_output_count.into_iter();
|
||||
let mut height_to_tx_count_iter = height_to_tx_count.into_iter();
|
||||
let mut height_to_unclaimed_rewards_iter = height_to_unclaimed_rewards.into_iter();
|
||||
let mut dateindex_to_price_close_iter =
|
||||
dateindex_to_price_close.as_ref().map(|v| v.into_iter());
|
||||
let mut height_to_date_fixed_iter = height_to_date_fixed.into_iter();
|
||||
let mut dateindex_to_first_height_iter = dateindex_to_first_height.into_iter();
|
||||
let mut dateindex_to_height_count_iter = dateindex_to_height_count.into_iter();
|
||||
let mut txindex_to_input_count_iter = txindex_to_input_count.boxed_iter();
|
||||
let mut txindex_to_output_count_iter = txindex_to_output_count.boxed_iter();
|
||||
|
||||
let height_to_price_close_vec =
|
||||
height_to_price_close.map(|height_to_price_close| height_to_price_close.collect());
|
||||
@@ -841,15 +851,29 @@ impl Vecs {
|
||||
let price = height_to_price_close_iter
|
||||
.as_mut()
|
||||
.map(|i| *i.unwrap_get_inner(height));
|
||||
let first_txindex = height_to_first_txindex_iter.unwrap_get_inner(height);
|
||||
let first_txoutindex = height_to_first_txoutindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
.to_usize();
|
||||
let first_txinindex = height_to_first_txinindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
.to_usize();
|
||||
let tx_count = height_to_tx_count_iter.unwrap_get_inner(height);
|
||||
let output_count = height_to_output_count_iter.unwrap_get_inner(height);
|
||||
let input_count = height_to_input_count_iter.unwrap_get_inner(height);
|
||||
|
||||
let txoutindex_to_txindex = build_txoutindex_to_txindex(
|
||||
first_txindex,
|
||||
u64::from(tx_count),
|
||||
&mut txindex_to_output_count_iter,
|
||||
);
|
||||
|
||||
let txinindex_to_txindex = build_txinindex_to_txindex(
|
||||
first_txindex,
|
||||
u64::from(tx_count),
|
||||
&mut txindex_to_input_count_iter,
|
||||
);
|
||||
|
||||
let first_addressindexes: ByAddressType<TypeIndex> = ByAddressType {
|
||||
p2a: height_to_first_p2aaddressindex_iter
|
||||
.unwrap_get_inner(height)
|
||||
@@ -1499,8 +1523,7 @@ impl Vecs {
|
||||
.loaded
|
||||
.get_any_or_read(loadedaddressindex, reader)
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
.unwrap();
|
||||
|
||||
WithAddressDataSource::FromLoadedAddressDataVec((
|
||||
loadedaddressindex,
|
||||
@@ -1514,8 +1537,7 @@ impl Vecs {
|
||||
.empty
|
||||
.get_any_or_read(emtpyaddressindex, reader)
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
.unwrap();
|
||||
|
||||
WithAddressDataSource::FromEmptyAddressDataVec((
|
||||
emtpyaddressindex,
|
||||
@@ -1969,7 +1991,7 @@ impl AnyAddressIndexes {
|
||||
OutputType::P2A => self.p2a.get_any_or_read(typeindex.into(), reader),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
result.unwrap().unwrap().into_owned()
|
||||
result.unwrap().unwrap()
|
||||
}
|
||||
|
||||
fn update_or_push(
|
||||
@@ -2104,3 +2126,43 @@ impl VecsReaders {
|
||||
.get_unwrap(address_type)
|
||||
}
|
||||
}
|
||||
|
||||
fn build_txoutindex_to_txindex<'a>(
|
||||
block_first_txindex: TxIndex,
|
||||
block_tx_count: u64,
|
||||
txindex_to_output_count: &mut BoxedVecIterator<'a, TxIndex, StoredU64>,
|
||||
) -> Vec<TxIndex> {
|
||||
let mut vec = Vec::new();
|
||||
|
||||
let block_first_txindex = block_first_txindex.to_usize();
|
||||
for tx_offset in 0..block_tx_count as usize {
|
||||
let txindex = TxIndex::from(block_first_txindex + tx_offset);
|
||||
let output_count = u64::from(txindex_to_output_count.unwrap_get_inner(txindex));
|
||||
|
||||
for _ in 0..output_count {
|
||||
vec.push(txindex);
|
||||
}
|
||||
}
|
||||
|
||||
vec
|
||||
}
|
||||
|
||||
fn build_txinindex_to_txindex<'a>(
|
||||
block_first_txindex: TxIndex,
|
||||
block_tx_count: u64,
|
||||
txindex_to_input_count: &mut BoxedVecIterator<'a, TxIndex, StoredU64>,
|
||||
) -> Vec<TxIndex> {
|
||||
let mut vec = Vec::new();
|
||||
|
||||
let block_first_txindex = block_first_txindex.to_usize();
|
||||
for tx_offset in 0..block_tx_count as usize {
|
||||
let txindex = TxIndex::from(block_first_txindex + tx_offset);
|
||||
let input_count = u64::from(txindex_to_input_count.unwrap_get_inner(txindex));
|
||||
|
||||
for _ in 0..input_count {
|
||||
vec.push(txindex);
|
||||
}
|
||||
}
|
||||
|
||||
vec
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ where
|
||||
I: StoredIndex,
|
||||
T: StoredIndex + StoredRaw,
|
||||
{
|
||||
#[inline]
|
||||
fn from(vec: &RawVec<I, T>) -> Self {
|
||||
Self(
|
||||
vec.into_iter()
|
||||
.map(|(i, v)| (v.into_owned(), i))
|
||||
.map(|(i, v)| (v, i))
|
||||
.collect::<BTreeMap<_, _>>(),
|
||||
)
|
||||
}
|
||||
@@ -39,10 +40,11 @@ where
|
||||
I: StoredIndex,
|
||||
T: StoredIndex + StoredCompressed,
|
||||
{
|
||||
#[inline]
|
||||
fn from(vec: &CompressedVec<I, T>) -> Self {
|
||||
Self(
|
||||
vec.into_iter()
|
||||
.map(|(i, v)| (v.into_owned(), i))
|
||||
.map(|(i, v)| (v, i))
|
||||
.collect::<BTreeMap<_, _>>(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ impl<T> WithAddressDataSource<T> {
|
||||
}
|
||||
|
||||
impl From<WithAddressDataSource<EmptyAddressData>> for WithAddressDataSource<LoadedAddressData> {
|
||||
#[inline]
|
||||
fn from(value: WithAddressDataSource<EmptyAddressData>) -> Self {
|
||||
match value {
|
||||
WithAddressDataSource::New(v) => Self::New(v.into()),
|
||||
@@ -40,6 +41,7 @@ impl From<WithAddressDataSource<EmptyAddressData>> for WithAddressDataSource<Loa
|
||||
}
|
||||
|
||||
impl From<WithAddressDataSource<LoadedAddressData>> for WithAddressDataSource<EmptyAddressData> {
|
||||
#[inline]
|
||||
fn from(value: WithAddressDataSource<LoadedAddressData>) -> Self {
|
||||
match value {
|
||||
WithAddressDataSource::New(v) => Self::New(v.into()),
|
||||
|
||||
@@ -41,6 +41,7 @@ impl SubAssign<&SupplyState> for SupplyState {
|
||||
}
|
||||
|
||||
impl From<&LoadedAddressData> for SupplyState {
|
||||
#[inline]
|
||||
fn from(value: &LoadedAddressData) -> Self {
|
||||
Self {
|
||||
utxo_count: value.utxo_count() as u64,
|
||||
|
||||
@@ -41,7 +41,7 @@ impl ComputeDCAStackViaLen for EagerVec<DateIndex, Sats> {
|
||||
|
||||
let index = max_from.min(DateIndex::from(self.len()));
|
||||
closes.iter_at(index).try_for_each(|(i, closes)| {
|
||||
let price = *closes.into_owned();
|
||||
let price = *closes;
|
||||
let i_usize = i.to_usize();
|
||||
if prev.is_none() {
|
||||
if i_usize == 0 {
|
||||
@@ -91,7 +91,7 @@ impl ComputeDCAStackViaLen for EagerVec<DateIndex, Sats> {
|
||||
|
||||
let index = max_from.min(DateIndex::from(self.len()));
|
||||
closes.iter_at(index).try_for_each(|(i, closes)| {
|
||||
let price = *closes.into_owned();
|
||||
let price = *closes;
|
||||
let i_usize = i.to_usize();
|
||||
if prev.is_none() {
|
||||
if i_usize == 0 {
|
||||
@@ -152,7 +152,6 @@ impl ComputeDCAAveragePriceViaLen for EagerVec<DateIndex, Dollars> {
|
||||
let first_price_date = DateIndex::try_from(Date::new(2010, 7, 12)).unwrap();
|
||||
|
||||
stacks.iter_at(index).try_for_each(|(i, stack)| {
|
||||
let stack = stack.into_owned();
|
||||
let mut avg_price = Dollars::from(f64::NAN);
|
||||
if i > first_price_date {
|
||||
avg_price = DCA_AMOUNT
|
||||
@@ -185,7 +184,6 @@ impl ComputeDCAAveragePriceViaLen for EagerVec<DateIndex, Dollars> {
|
||||
let from_usize = from.to_usize();
|
||||
|
||||
stacks.iter_at(index).try_for_each(|(i, stack)| {
|
||||
let stack = stack.into_owned();
|
||||
let mut avg_price = Dollars::from(f64::NAN);
|
||||
if i >= from {
|
||||
avg_price = DCA_AMOUNT * (i.to_usize() + 1 - from_usize) / Bitcoin::from(stack);
|
||||
@@ -223,7 +221,7 @@ where
|
||||
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
sats.iter_at(index).try_for_each(|(i, sats)| {
|
||||
let (i, v) = (i, Bitcoin::from(sats.into_owned()));
|
||||
let (i, v) = (i, Bitcoin::from(sats));
|
||||
self.forced_push_at(i, v, exit)
|
||||
})?;
|
||||
|
||||
@@ -261,7 +259,7 @@ where
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
bitcoin.iter_at(index).try_for_each(|(i, bitcoin)| {
|
||||
let dollars = price_iter.unwrap_get_inner(i);
|
||||
let (i, v) = (i, *dollars * bitcoin.into_owned());
|
||||
let (i, v) = (i, *dollars * bitcoin);
|
||||
self.forced_push_at(i, v, exit)
|
||||
})?;
|
||||
|
||||
@@ -298,7 +296,6 @@ where
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
let mut close_iter = close.iter();
|
||||
ath.iter_at(index).try_for_each(|(i, ath)| {
|
||||
let ath = ath.into_owned();
|
||||
if ath == Dollars::ZERO {
|
||||
self.forced_push_at(i, StoredF32::default(), exit)
|
||||
} else {
|
||||
|
||||
@@ -44,108 +44,126 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl From<bitcoin::block::Bip34Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::block::Bip34Error) -> Self {
|
||||
Self::BitcoinBip34Error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoin::consensus::encode::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::consensus::encode::Error) -> Self {
|
||||
Self::BitcoinConsensusEncode(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoin::consensus::encode::FromHexError> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::consensus::encode::FromHexError) -> Self {
|
||||
Self::BitcoinHexError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoin::hex::HexToArrayError> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::hex::HexToArrayError) -> Self {
|
||||
Self::BitcoinHexToArrayError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoin::address::FromScriptError> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::address::FromScriptError) -> Self {
|
||||
Self::BitcoinFromScriptError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<time::SystemTimeError> for Error {
|
||||
#[inline]
|
||||
fn from(value: time::SystemTimeError) -> Self {
|
||||
Self::SystemTimeError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sonic_rs::Error> for Error {
|
||||
#[inline]
|
||||
fn from(error: sonic_rs::Error) -> Self {
|
||||
Self::SonicRS(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: io::Error) -> Self {
|
||||
Self::IO(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<vecdb::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: vecdb::Error) -> Self {
|
||||
Self::VecDB(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<vecdb::SeqDBError> for Error {
|
||||
#[inline]
|
||||
fn from(value: vecdb::SeqDBError) -> Self {
|
||||
Self::SeqDB(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoincore_rpc::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: bitcoincore_rpc::Error) -> Self {
|
||||
Self::BitcoinRPC(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<minreq::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: minreq::Error) -> Self {
|
||||
Self::Minreq(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<jiff::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: jiff::Error) -> Self {
|
||||
Self::Jiff(value)
|
||||
}
|
||||
}
|
||||
|
||||
// impl From<fjall3::Error> for Error {
|
||||
// fn from(value: fjall3::Error) -> Self {
|
||||
// #[inline]
|
||||
// fn from(value: fjall3::Error) -> Self {
|
||||
// Self::FjallV3(value)
|
||||
// }
|
||||
// }
|
||||
|
||||
impl From<fjall2::Error> for Error {
|
||||
#[inline]
|
||||
fn from(value: fjall2::Error) -> Self {
|
||||
Self::FjallV2(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&'static str> for Error {
|
||||
#[inline]
|
||||
fn from(value: &'static str) -> Self {
|
||||
Self::Str(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B, C> From<zerocopy::error::ConvertError<A, B, C>> for Error {
|
||||
#[inline]
|
||||
fn from(_: zerocopy::error::ConvertError<A, B, C>) -> Self {
|
||||
Self::ZeroCopyError
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> From<zerocopy::error::SizeError<A, B>> for Error {
|
||||
#[inline]
|
||||
fn from(_: zerocopy::error::SizeError<A, B>) -> Self {
|
||||
Self::ZeroCopyError
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ impl<T> AddressGroups<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<AddressGroups<T>> for AddressGroups<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: AddressGroups<T>) -> Self {
|
||||
Self {
|
||||
amount_range: ByAmountRange::from(value.amount_range),
|
||||
|
||||
@@ -231,6 +231,7 @@ impl<T> ByAddressType<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByAddressType<T>> for ByAddressType<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByAddressType<T>) -> Self {
|
||||
Self {
|
||||
p2pk65: (Filter::Type(OutputType::P2PK65), value.p2pk65).into(),
|
||||
|
||||
@@ -30,6 +30,7 @@ pub struct ByAgeRange<T> {
|
||||
}
|
||||
|
||||
impl<T> From<ByAgeRange<T>> for ByAgeRange<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByAgeRange<T>) -> Self {
|
||||
Self {
|
||||
up_to_1d: (Filter::LowerThan(1), value.up_to_1d).into(),
|
||||
|
||||
@@ -26,6 +26,7 @@ pub struct ByAmountRange<T> {
|
||||
}
|
||||
|
||||
impl<T> From<ByAmountRange<T>> for ByAmountRange<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByAmountRange<T>) -> Self {
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
Self {
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct ByEpoch<T> {
|
||||
}
|
||||
|
||||
impl<T> From<ByEpoch<T>> for ByEpoch<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByEpoch<T>) -> Self {
|
||||
Self {
|
||||
_0: (Filter::Epoch(HalvingEpoch::new(0)), value._0).into(),
|
||||
|
||||
@@ -63,6 +63,7 @@ impl<T> ByGreatEqualAmount<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByGreatEqualAmount<T>> for ByGreatEqualAmount<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByGreatEqualAmount<T>) -> Self {
|
||||
Self {
|
||||
_1sat: (Filter::GreaterOrEqual(Sats::_1.into()), value._1sat).into(),
|
||||
|
||||
@@ -63,6 +63,7 @@ impl<T> ByLowerThanAmount<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByLowerThanAmount<T>> for ByLowerThanAmount<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByLowerThanAmount<T>) -> Self {
|
||||
Self {
|
||||
_10sats: (Filter::LowerThan(Sats::_10.into()), value._10sats).into(),
|
||||
|
||||
@@ -78,6 +78,7 @@ impl<T> ByMaxAge<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByMaxAge<T>> for ByMaxAge<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByMaxAge<T>) -> Self {
|
||||
Self {
|
||||
_1w: (Filter::LowerThan(7), value._1w).into(),
|
||||
|
||||
@@ -79,6 +79,7 @@ impl<T> ByMinAge<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByMinAge<T>> for ByMinAge<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByMinAge<T>) -> Self {
|
||||
Self {
|
||||
_1d: (Filter::GreaterOrEqual(1), value._1d).into(),
|
||||
|
||||
@@ -114,6 +114,7 @@ impl<T> BySpendableType<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<BySpendableType<T>> for BySpendableType<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: BySpendableType<T>) -> Self {
|
||||
Self {
|
||||
p2pk65: (Filter::Type(OutputType::P2PK65), value.p2pk65).into(),
|
||||
|
||||
@@ -23,6 +23,7 @@ impl<T> ByTerm<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<ByTerm<T>> for ByTerm<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: ByTerm<T>) -> Self {
|
||||
Self {
|
||||
short: (Filter::LowerThan(5 * 30), value.short).into(),
|
||||
|
||||
@@ -71,6 +71,7 @@ impl<T> Filtered<T> {
|
||||
}
|
||||
|
||||
impl<T> From<(Filter, T)> for Filtered<T> {
|
||||
#[inline]
|
||||
fn from(value: (Filter, T)) -> Self {
|
||||
Self(value.0, value.1)
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ impl<T> UTXOGroups<Filtered<T>> {
|
||||
}
|
||||
|
||||
impl<T> From<UTXOGroups<T>> for UTXOGroups<Filtered<T>> {
|
||||
#[inline]
|
||||
fn from(value: UTXOGroups<T>) -> Self {
|
||||
Self {
|
||||
all: (Filter::All, value.all).into(),
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
MBP M3 Pro
|
||||
|
||||
0..920750
|
||||
Time: 13h 6mn
|
||||
|
||||
Time: 13h 6mn (checked) / 12h 20mn (unchecked)
|
||||
|
||||
RAM:
|
||||
Peak: ~12GB
|
||||
After finish: ~8GB
|
||||
After restart ~6.5GB
|
||||
After auto compaction: ~6.5GB
|
||||
|
||||
storage: 230GB
|
||||
storage: 223GB
|
||||
|
||||
mode: checked
|
||||
|
||||
25
crates/brk_indexer/examples/indexer_read.rs
Normal file
25
crates/brk_indexer/examples/indexer_read.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_types::Sats;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
brk_logger::init(Some(Path::new(".log")))?;
|
||||
|
||||
let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
|
||||
fs::create_dir_all(&outputs_dir)?;
|
||||
|
||||
let indexer = Indexer::forced_import(&outputs_dir)?;
|
||||
|
||||
let mut sum = Sats::ZERO;
|
||||
let mut count: usize = 0;
|
||||
|
||||
for value in indexer.vecs.txoutindex_to_value.clean_values().unwrap() {
|
||||
sum += value;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
println!("sum = {sum}, count = {count}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
102
crates/brk_indexer/examples/indexer_read_speed.rs
Normal file
102
crates/brk_indexer/examples/indexer_read_speed.rs
Normal file
@@ -0,0 +1,102 @@
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_types::Sats;
|
||||
use std::{fs, path::Path, time::Instant};
|
||||
|
||||
fn run_benchmark(indexer: &Indexer) -> (Sats, std::time::Duration, usize) {
|
||||
let start = Instant::now();
|
||||
let mut sum = Sats::ZERO;
|
||||
let mut count = 0;
|
||||
|
||||
for value in indexer.vecs.txoutindex_to_value.clean_values().unwrap() {
|
||||
// for value in indexer.vecs.txoutindex_to_value.values() {
|
||||
sum += value;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
let duration = start.elapsed();
|
||||
(sum, duration, count)
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
brk_logger::init(Some(Path::new(".log")))?;
|
||||
|
||||
let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
|
||||
fs::create_dir_all(&outputs_dir)?;
|
||||
|
||||
println!("\n╔════════════════════════════════════════════════════════╗");
|
||||
println!("║ BRK INDEXER SEQUENTIAL READ BENCHMARK ║");
|
||||
println!("╚════════════════════════════════════════════════════════╝\n");
|
||||
|
||||
println!("Loading indexer from: {}", outputs_dir.display());
|
||||
let indexer = Indexer::forced_import(&outputs_dir)?;
|
||||
println!("✅ Indexer loaded\n");
|
||||
|
||||
// Warmup run
|
||||
println!("🔥 Warmup run...");
|
||||
let (sum, duration, count) = run_benchmark(&indexer);
|
||||
println!(" Sum: {} sats", sum);
|
||||
println!(" Time: {:.3}s", duration.as_secs_f64());
|
||||
println!(" Count: {} values\n", count);
|
||||
|
||||
// Benchmark runs
|
||||
let num_runs = 4;
|
||||
let mut throughputs: Vec<f64> = Vec::new();
|
||||
|
||||
println!("📊 Running {} benchmark iterations...\n", num_runs);
|
||||
|
||||
for run in 1..=num_runs {
|
||||
let (_, duration, count) = run_benchmark(&indexer);
|
||||
let estimated_bytes = count * 8;
|
||||
let throughput = estimated_bytes as f64 / duration.as_secs_f64() / (1024.0 * 1024.0);
|
||||
let values_per_sec = count as f64 / duration.as_secs_f64() / 1_000_000.0;
|
||||
|
||||
throughputs.push(throughput);
|
||||
|
||||
println!(
|
||||
"Run {:2}/{num_runs}: {:.3}s - {:>6.0} MB/s - {:>6.1}M values/s",
|
||||
run,
|
||||
duration.as_secs_f64(),
|
||||
throughput,
|
||||
values_per_sec
|
||||
);
|
||||
}
|
||||
|
||||
// Statistics
|
||||
let mean = throughputs.iter().sum::<f64>() / throughputs.len() as f64;
|
||||
let min = throughputs.iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
let max = throughputs
|
||||
.iter()
|
||||
.cloned()
|
||||
.fold(f64::NEG_INFINITY, f64::max);
|
||||
let variance =
|
||||
throughputs.iter().map(|x| (x - mean).powi(2)).sum::<f64>() / throughputs.len() as f64;
|
||||
let std_dev = variance.sqrt();
|
||||
let cv = (std_dev / mean) * 100.0;
|
||||
|
||||
println!("\n╔════════════════════════════════════════════════════════╗");
|
||||
println!("║ 📊 SUMMARY STATISTICS ║");
|
||||
println!("╚════════════════════════════════════════════════════════╝\n");
|
||||
|
||||
println!(
|
||||
"Values: {} ({:.2} MB)",
|
||||
count,
|
||||
(count * 8) as f64 / (1024.0 * 1024.0)
|
||||
);
|
||||
println!("Mean: {:.0} MB/s", mean);
|
||||
println!("Min: {:.0} MB/s", min);
|
||||
println!("Max: {:.0} MB/s", max);
|
||||
println!("StdDev: {:.1} MB/s", std_dev);
|
||||
println!("Variance: {:.1}%", cv);
|
||||
|
||||
if cv < 2.0 {
|
||||
println!("✅ Excellent consistency");
|
||||
} else if cv < 5.0 {
|
||||
println!("✅ Good consistency");
|
||||
} else {
|
||||
println!("⚠️ High variance");
|
||||
}
|
||||
|
||||
println!();
|
||||
Ok(())
|
||||
}
|
||||
@@ -300,21 +300,21 @@ fn run_method2(
|
||||
.txoutindex_to_value
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let output_types: Vec<_> = vecs
|
||||
.txoutindex_to_outputtype
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let typeindexes: Vec<_> = vecs
|
||||
.txoutindex_to_typeindex
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let _outputs: Vec<_> = (0..outputs_per_block)
|
||||
@@ -330,7 +330,7 @@ fn run_method2(
|
||||
.txinindex_to_outpoint
|
||||
.iter_at(input_block_start)
|
||||
.take(inputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let txindex_to_first_txoutindex_reader = vecs.txindex_to_first_txoutindex.create_reader();
|
||||
@@ -384,7 +384,7 @@ fn run_method4(
|
||||
vecs.txoutindex_to_value
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
@@ -392,7 +392,7 @@ fn run_method4(
|
||||
vecs.txoutindex_to_outputtype
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
@@ -400,7 +400,7 @@ fn run_method4(
|
||||
vecs.txoutindex_to_typeindex
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
@@ -420,7 +420,7 @@ fn run_method4(
|
||||
.txinindex_to_outpoint
|
||||
.iter_at(input_block_start)
|
||||
.take(inputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let txindex_to_first_txoutindex_reader = vecs.txindex_to_first_txoutindex.create_reader();
|
||||
@@ -541,21 +541,21 @@ fn run_method6(
|
||||
.txoutindex_to_value
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let output_types: Vec<_> = vecs
|
||||
.txoutindex_to_outputtype
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let typeindexes: Vec<_> = vecs
|
||||
.txoutindex_to_typeindex
|
||||
.iter_at(block_start)
|
||||
.take(outputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
// Read inputs sequentially
|
||||
@@ -566,7 +566,7 @@ fn run_method6(
|
||||
.txinindex_to_outpoint
|
||||
.iter_at(input_block_start)
|
||||
.take(inputs_per_block)
|
||||
.map(|(_, v)| v.into_owned())
|
||||
.map(|(_, v)| v)
|
||||
.collect();
|
||||
|
||||
let txindex_to_first_txoutindex_reader = vecs.txindex_to_first_txoutindex.create_reader();
|
||||
|
||||
@@ -86,6 +86,7 @@ impl Indexes {
|
||||
}
|
||||
|
||||
impl From<(Height, &mut Vecs, &Stores)> for Indexes {
|
||||
#[inline]
|
||||
fn from((min_height, vecs, stores): (Height, &mut Vecs, &Stores)) -> Self {
|
||||
// Height at which we want to start: min last saved + 1 or 0
|
||||
let vecs_starting_height = vecs.starting_height();
|
||||
|
||||
@@ -81,7 +81,7 @@ impl Indexer {
|
||||
check_collisions: bool,
|
||||
) -> Result<Indexes> {
|
||||
let (starting_indexes, prev_hash) = if let Some(hash) =
|
||||
VecIterator::last(self.vecs.height_to_blockhash.iter()).map(|(_, v)| v.into_owned())
|
||||
VecIterator::last(self.vecs.height_to_blockhash.iter()).map(|(_, v)| v)
|
||||
{
|
||||
let (height, hash) = client.get_closest_valid_height(hash)?;
|
||||
let starting_indexes =
|
||||
@@ -265,13 +265,13 @@ impl Indexer {
|
||||
.ok_or(Error::Str("Expect txoutindex to not be none"))
|
||||
.inspect_err(|_| {
|
||||
dbg!(outpoint.txid, prev_txindex, vout);
|
||||
})?.into_owned()
|
||||
})?
|
||||
+ vout;
|
||||
|
||||
let outpoint = OutPoint::new(prev_txindex, vout);
|
||||
|
||||
let outputtype = vecs.txoutindex_to_outputtype.get_pushed_or_read(txoutindex, &readers.txoutindex_to_outputtype)?
|
||||
.ok_or(Error::Str("Expect outputtype to not be none"))?.into_owned();
|
||||
.ok_or(Error::Str("Expect outputtype to not be none"))?;
|
||||
|
||||
let mut tuple = (
|
||||
vin,
|
||||
@@ -286,7 +286,7 @@ impl Indexer {
|
||||
let typeindex = vecs
|
||||
.txoutindex_to_typeindex
|
||||
.get_pushed_or_read(txoutindex, &readers.txoutindex_to_typeindex)?
|
||||
.ok_or(Error::Str("Expect typeindex to not be none"))?.into_owned();
|
||||
.ok_or(Error::Str("Expect typeindex to not be none"))?;
|
||||
tuple.3 = Some((outputtype, typeindex));
|
||||
}
|
||||
|
||||
@@ -377,56 +377,56 @@ impl Indexer {
|
||||
typeindex.into(),
|
||||
&readers.p2pk65addressindex_to_p2pk65bytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2PK33 => vecs
|
||||
.p2pk33addressindex_to_p2pk33bytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2pk33addressindex_to_p2pk33bytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2PKH => vecs
|
||||
.p2pkhaddressindex_to_p2pkhbytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2pkhaddressindex_to_p2pkhbytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2SH => vecs
|
||||
.p2shaddressindex_to_p2shbytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2shaddressindex_to_p2shbytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2WPKH => vecs
|
||||
.p2wpkhaddressindex_to_p2wpkhbytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2wpkhaddressindex_to_p2wpkhbytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2WSH => vecs
|
||||
.p2wshaddressindex_to_p2wshbytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2wshaddressindex_to_p2wshbytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2TR => vecs
|
||||
.p2traddressindex_to_p2trbytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2traddressindex_to_p2trbytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
OutputType::P2A => vecs
|
||||
.p2aaddressindex_to_p2abytes
|
||||
.get_pushed_or_read(
|
||||
typeindex.into(),
|
||||
&readers.p2aaddressindex_to_p2abytes,
|
||||
)?
|
||||
.map(|v| AddressBytes::from(v.into_owned())),
|
||||
.map(AddressBytes::from),
|
||||
_ => {
|
||||
unreachable!()
|
||||
}
|
||||
@@ -677,8 +677,6 @@ impl Indexer {
|
||||
dbg!(txindex, len);
|
||||
})?;
|
||||
|
||||
let prev_txid = prev_txid.as_ref();
|
||||
|
||||
// If another Txid needs to be added to the list
|
||||
// We need to check that it's also a coinbase tx otherwise par_iter inputs needs to be updated
|
||||
let only_known_dup_txids = [
|
||||
@@ -694,7 +692,7 @@ impl Indexer {
|
||||
.into(),
|
||||
];
|
||||
|
||||
let is_dup = only_known_dup_txids.contains(prev_txid);
|
||||
let is_dup = only_known_dup_txids.contains(&prev_txid);
|
||||
|
||||
if !is_dup {
|
||||
dbg!(height, txindex, prev_txid, prev_txindex);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, fs, path::Path};
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
@@ -162,7 +162,7 @@ impl Stores {
|
||||
vecs.height_to_blockhash
|
||||
.iter_at(starting_indexes.height)
|
||||
.for_each(|(_, v)| {
|
||||
let blockhashprefix = BlockHashPrefix::from(v.into_owned());
|
||||
let blockhashprefix = BlockHashPrefix::from(v);
|
||||
self.blockhashprefix_to_height.remove(blockhashprefix);
|
||||
});
|
||||
|
||||
@@ -176,15 +176,11 @@ impl Stores {
|
||||
.height_to_first_p2pk65addressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2pk65addressindex_to_p2pk65bytes_iter =
|
||||
vecs.p2pk65addressindex_to_p2pk65bytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2pk65addressindex_to_p2pk65bytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2pk65addressindex_to_p2pk65bytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -196,15 +192,11 @@ impl Stores {
|
||||
.height_to_first_p2pk33addressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2pk33addressindex_to_p2pk33bytes_iter =
|
||||
vecs.p2pk33addressindex_to_p2pk33bytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2pk33addressindex_to_p2pk33bytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2pk33addressindex_to_p2pk33bytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -216,15 +208,11 @@ impl Stores {
|
||||
.height_to_first_p2pkhaddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2pkhaddressindex_to_p2pkhbytes_iter =
|
||||
vecs.p2pkhaddressindex_to_p2pkhbytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2pkhaddressindex_to_p2pkhbytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2pkhaddressindex_to_p2pkhbytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -236,15 +224,11 @@ impl Stores {
|
||||
.height_to_first_p2shaddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2shaddressindex_to_p2shbytes_iter =
|
||||
vecs.p2shaddressindex_to_p2shbytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2shaddressindex_to_p2shbytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2shaddressindex_to_p2shbytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -256,15 +240,11 @@ impl Stores {
|
||||
.height_to_first_p2traddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2traddressindex_to_p2trbytes_iter =
|
||||
vecs.p2traddressindex_to_p2trbytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2traddressindex_to_p2trbytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2traddressindex_to_p2trbytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -276,15 +256,11 @@ impl Stores {
|
||||
.height_to_first_p2wpkhaddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2wpkhaddressindex_to_p2wpkhbytes_iter =
|
||||
vecs.p2wpkhaddressindex_to_p2wpkhbytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2wpkhaddressindex_to_p2wpkhbytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2wpkhaddressindex_to_p2wpkhbytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -296,15 +272,11 @@ impl Stores {
|
||||
.height_to_first_p2wshaddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2wshaddressindex_to_p2wshbytes_iter =
|
||||
vecs.p2wshaddressindex_to_p2wshbytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2wshaddressindex_to_p2wshbytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2wshaddressindex_to_p2wshbytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -316,14 +288,10 @@ impl Stores {
|
||||
.height_to_first_p2aaddressindex
|
||||
.iter()
|
||||
.get(starting_indexes.height)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
let mut p2aaddressindex_to_p2abytes_iter = vecs.p2aaddressindex_to_p2abytes.iter();
|
||||
|
||||
while let Some(typedbytes) = p2aaddressindex_to_p2abytes_iter
|
||||
.get(index)
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
while let Some(typedbytes) = p2aaddressindex_to_p2abytes_iter.get(index) {
|
||||
let bytes = AddressBytes::from(typedbytes);
|
||||
let hash = AddressBytesHash::from(&bytes);
|
||||
self.addressbyteshash_to_typeindex.remove(hash);
|
||||
@@ -340,7 +308,7 @@ impl Stores {
|
||||
vecs.txindex_to_txid
|
||||
.iter_at(starting_indexes.txindex)
|
||||
.for_each(|(txindex, txid)| {
|
||||
let txidprefix = TxidPrefix::from(&txid.into_owned());
|
||||
let txidprefix = TxidPrefix::from(&txid);
|
||||
|
||||
// "d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599"
|
||||
let is_not_first_dup = txindex != TxIndex::new(142783)
|
||||
@@ -368,15 +336,7 @@ impl Stores {
|
||||
)
|
||||
.filter(|((_, outputtype), _)| outputtype.is_address())
|
||||
.for_each(|((txoutindex, outputtype), (_, typeindex))| {
|
||||
let outputtype = outputtype.into_owned();
|
||||
let typeindex = typeindex.into_owned();
|
||||
|
||||
let txindex = vecs
|
||||
.txoutindex_to_txindex
|
||||
.iter()
|
||||
.get(txoutindex)
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
let txindex = vecs.txoutindex_to_txindex.iter().get(txoutindex).unwrap();
|
||||
|
||||
let vout = Vout::from(
|
||||
txoutindex.to_usize()
|
||||
@@ -385,7 +345,6 @@ impl Stores {
|
||||
.iter()
|
||||
.get(txindex)
|
||||
.unwrap()
|
||||
.into_owned()
|
||||
.to_usize(),
|
||||
);
|
||||
let outpoint = OutPoint::new(txindex, vout);
|
||||
@@ -400,8 +359,6 @@ impl Stores {
|
||||
vecs.txinindex_to_outpoint
|
||||
.iter_at(starting_indexes.txinindex)
|
||||
.for_each(|(_, outpoint)| {
|
||||
let outpoint = outpoint.into_owned();
|
||||
|
||||
if outpoint.is_coinbase() {
|
||||
return;
|
||||
}
|
||||
@@ -415,7 +372,6 @@ impl Stores {
|
||||
.iter()
|
||||
.get(txindex)
|
||||
.unwrap()
|
||||
.into_owned()
|
||||
+ vout;
|
||||
|
||||
// Only process if this output was created before the rollback point
|
||||
@@ -424,16 +380,11 @@ impl Stores {
|
||||
.txoutindex_to_outputtype
|
||||
.iter()
|
||||
.get(txoutindex)
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
.unwrap();
|
||||
|
||||
if outputtype.is_address() {
|
||||
let typeindex = vecs
|
||||
.txoutindex_to_typeindex
|
||||
.iter()
|
||||
.get(txoutindex)
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
let typeindex =
|
||||
vecs.txoutindex_to_typeindex.iter().get(txoutindex).unwrap();
|
||||
|
||||
self.addresstype_to_typeindex_and_unspentoutpoint
|
||||
.get_mut(outputtype)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use brk_types::{Format, Index, Metric, Metrics};
|
||||
use derive_deref::Deref;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -28,6 +27,7 @@ impl Deref for Params {
|
||||
}
|
||||
|
||||
impl From<(Index, Metric, ParamsOpt)> for Params {
|
||||
#[inline]
|
||||
fn from((index, metric, rest): (Index, Metric, ParamsOpt)) -> Self {
|
||||
Self {
|
||||
index,
|
||||
@@ -38,6 +38,7 @@ impl From<(Index, Metric, ParamsOpt)> for Params {
|
||||
}
|
||||
|
||||
impl From<(Index, Metrics, ParamsOpt)> for Params {
|
||||
#[inline]
|
||||
fn from((index, metrics, rest): (Index, Metrics, ParamsOpt)) -> Self {
|
||||
Self {
|
||||
index,
|
||||
@@ -118,6 +119,7 @@ pub struct ParamsDeprec {
|
||||
}
|
||||
|
||||
impl From<ParamsDeprec> for Params {
|
||||
#[inline]
|
||||
fn from(value: ParamsDeprec) -> Self {
|
||||
Params {
|
||||
index: value.index,
|
||||
|
||||
@@ -8,6 +8,7 @@ pub const XOR_LEN: usize = 8;
|
||||
pub struct XORBytes([u8; XOR_LEN]);
|
||||
|
||||
impl From<&Path> for XORBytes {
|
||||
#[inline]
|
||||
fn from(value: &Path) -> Self {
|
||||
Self(
|
||||
fs::read(value.join("xor.dat"))
|
||||
|
||||
@@ -265,6 +265,7 @@ where
|
||||
K: Into<ByteView>,
|
||||
V: Into<ByteView>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Item<K, V>) -> Self {
|
||||
match value {
|
||||
Item::Value { key, value } => Self {
|
||||
|
||||
@@ -24,6 +24,7 @@ impl fmt::Display for Address {
|
||||
}
|
||||
|
||||
impl From<String> for Address {
|
||||
#[inline]
|
||||
fn from(address: String) -> Self {
|
||||
Self { address }
|
||||
}
|
||||
|
||||
@@ -130,48 +130,56 @@ impl TryFrom<(&ScriptBuf, OutputType)> for AddressBytes {
|
||||
}
|
||||
|
||||
impl From<P2PK65Bytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2PK65Bytes) -> Self {
|
||||
Self::P2PK65(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2PK33Bytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2PK33Bytes) -> Self {
|
||||
Self::P2PK33(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2PKHBytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2PKHBytes) -> Self {
|
||||
Self::P2PKH(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2SHBytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2SHBytes) -> Self {
|
||||
Self::P2SH(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2WPKHBytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2WPKHBytes) -> Self {
|
||||
Self::P2WPKH(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2WSHBytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2WSHBytes) -> Self {
|
||||
Self::P2WSH(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2TRBytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2TRBytes) -> Self {
|
||||
Self::P2TR(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<P2ABytes> for AddressBytes {
|
||||
#[inline]
|
||||
fn from(value: P2ABytes) -> Self {
|
||||
Self::P2A(Box::new(value))
|
||||
}
|
||||
|
||||
@@ -22,24 +22,28 @@ use super::AddressBytes;
|
||||
pub struct AddressBytesHash(u64);
|
||||
|
||||
impl From<&AddressBytes> for AddressBytesHash {
|
||||
#[inline]
|
||||
fn from(address_bytes: &AddressBytes) -> Self {
|
||||
Self(address_bytes.hash())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ByteView> for AddressBytesHash {
|
||||
#[inline]
|
||||
fn from(value: ByteView) -> Self {
|
||||
Self::read_from_bytes(&value).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AddressBytesHash> for ByteView {
|
||||
#[inline]
|
||||
fn from(value: AddressBytesHash) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&AddressBytesHash> for ByteView {
|
||||
#[inline]
|
||||
fn from(value: &AddressBytesHash) -> Self {
|
||||
Self::new(value.as_bytes())
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ impl AnyAddressIndex {
|
||||
}
|
||||
|
||||
impl From<LoadedAddressIndex> for AnyAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: LoadedAddressIndex) -> Self {
|
||||
if u32::from(value) >= MIN_EMPTY_INDEX {
|
||||
panic!("{value} is higher than MIN_EMPTY_INDEX ({MIN_EMPTY_INDEX})")
|
||||
@@ -26,6 +27,7 @@ impl From<LoadedAddressIndex> for AnyAddressIndex {
|
||||
}
|
||||
|
||||
impl From<EmptyAddressIndex> for AnyAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: EmptyAddressIndex) -> Self {
|
||||
Self(*value + MIN_EMPTY_INDEX)
|
||||
}
|
||||
@@ -54,6 +56,7 @@ pub enum AnyAddressDataIndexEnum {
|
||||
}
|
||||
|
||||
impl From<AnyAddressIndex> for AnyAddressDataIndexEnum {
|
||||
#[inline]
|
||||
fn from(value: AnyAddressIndex) -> Self {
|
||||
let uvalue = u32::from(value.0);
|
||||
if uvalue >= MIN_EMPTY_INDEX {
|
||||
|
||||
@@ -68,30 +68,35 @@ impl Div<usize> for Bitcoin {
|
||||
}
|
||||
|
||||
impl From<Sats> for Bitcoin {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
Self(f64::from(value) / (f64::from(Sats::ONE_BTC)))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for Bitcoin {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StoredF64> for Bitcoin {
|
||||
#[inline]
|
||||
fn from(value: StoredF64) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Bitcoin> for f64 {
|
||||
#[inline]
|
||||
fn from(value: Bitcoin) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Bitcoin {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as f64)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ impl Block {
|
||||
}
|
||||
|
||||
impl From<(Height, bitcoin::Block)> for Block {
|
||||
#[inline]
|
||||
fn from((height, block): (Height, bitcoin::Block)) -> Self {
|
||||
Self::from((height, block.block_hash(), block))
|
||||
}
|
||||
@@ -57,6 +58,7 @@ impl From<(Height, BlockHash, bitcoin::Block)> for Block {
|
||||
}
|
||||
|
||||
impl From<ReadBlock> for Block {
|
||||
#[inline]
|
||||
fn from(value: ReadBlock) -> Self {
|
||||
value.block
|
||||
}
|
||||
@@ -77,6 +79,7 @@ pub struct ReadBlock {
|
||||
}
|
||||
|
||||
impl From<(Block, BlkMetadata, Vec<BlkMetadata>)> for ReadBlock {
|
||||
#[inline]
|
||||
fn from((block, metadata, tx_metadata): (Block, BlkMetadata, Vec<BlkMetadata>)) -> Self {
|
||||
Self {
|
||||
block,
|
||||
|
||||
@@ -22,30 +22,35 @@ impl TryFrom<&str> for BlockHash {
|
||||
}
|
||||
|
||||
impl From<bitcoin::BlockHash> for BlockHash {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::BlockHash) -> Self {
|
||||
unsafe { mem::transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&bitcoin::BlockHash> for &BlockHash {
|
||||
#[inline]
|
||||
fn from(value: &bitcoin::BlockHash) -> Self {
|
||||
unsafe { mem::transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BlockHash> for bitcoin::BlockHash {
|
||||
#[inline]
|
||||
fn from(value: BlockHash) -> Self {
|
||||
unsafe { mem::transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&BlockHash> for &bitcoin::BlockHash {
|
||||
#[inline]
|
||||
fn from(value: &BlockHash) -> Self {
|
||||
unsafe { mem::transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&BlockHash> for bitcoin::BlockHash {
|
||||
#[inline]
|
||||
fn from(value: &BlockHash) -> Self {
|
||||
bitcoin::BlockHash::from_slice(&value.0).unwrap()
|
||||
}
|
||||
|
||||
@@ -24,30 +24,35 @@ use super::BlockHash;
|
||||
pub struct BlockHashPrefix(u64);
|
||||
|
||||
impl From<BlockHash> for BlockHashPrefix {
|
||||
#[inline]
|
||||
fn from(value: BlockHash) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&BlockHash> for BlockHashPrefix {
|
||||
#[inline]
|
||||
fn from(value: &BlockHash) -> Self {
|
||||
Self(u64::from_ne_bytes(copy_first_8bytes(&value[..]).unwrap()))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ByteView> for BlockHashPrefix {
|
||||
#[inline]
|
||||
fn from(value: ByteView) -> Self {
|
||||
Self::read_from_bytes(&value).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&BlockHashPrefix> for ByteView {
|
||||
#[inline]
|
||||
fn from(value: &BlockHashPrefix) -> Self {
|
||||
Self::new(value.as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BlockHashPrefix> for ByteView {
|
||||
#[inline]
|
||||
fn from(value: BlockHashPrefix) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
)]
|
||||
pub struct U8x2([u8; 2]);
|
||||
impl From<&[u8]> for U8x2 {
|
||||
#[inline]
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
let mut arr = [0; 2];
|
||||
arr.copy_from_slice(slice);
|
||||
@@ -45,6 +46,7 @@ impl From<&[u8]> for U8x2 {
|
||||
)]
|
||||
pub struct U8x20([u8; 20]);
|
||||
impl From<&[u8]> for U8x20 {
|
||||
#[inline]
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
let mut arr = [0; 20];
|
||||
arr.copy_from_slice(slice);
|
||||
@@ -70,6 +72,7 @@ impl From<&[u8]> for U8x20 {
|
||||
)]
|
||||
pub struct U8x32([u8; 32]);
|
||||
impl From<&[u8]> for U8x32 {
|
||||
#[inline]
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
let mut arr = [0; 32];
|
||||
arr.copy_from_slice(slice);
|
||||
@@ -95,6 +98,7 @@ impl From<&[u8]> for U8x32 {
|
||||
)]
|
||||
pub struct U8x33(#[serde(with = "serde_bytes")] [u8; 33]);
|
||||
impl From<&[u8]> for U8x33 {
|
||||
#[inline]
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
let mut arr = [0; 33];
|
||||
arr.copy_from_slice(slice);
|
||||
@@ -120,6 +124,7 @@ impl From<&[u8]> for U8x33 {
|
||||
)]
|
||||
pub struct U8x65(#[serde(with = "serde_bytes")] [u8; 65]);
|
||||
impl From<&[u8]> for U8x65 {
|
||||
#[inline]
|
||||
fn from(slice: &[u8]) -> Self {
|
||||
let mut arr = [0; 65];
|
||||
arr.copy_from_slice(slice);
|
||||
|
||||
@@ -47,30 +47,35 @@ impl Cents {
|
||||
}
|
||||
|
||||
impl From<Dollars> for Cents {
|
||||
#[inline]
|
||||
fn from(value: Dollars) -> Self {
|
||||
Self((*value * 100.0).round() as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Cents> for f64 {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
value.0 as f64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i64> for Cents {
|
||||
#[inline]
|
||||
fn from(value: i64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for Cents {
|
||||
#[inline]
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Cents> for usize {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
if value.0 < 0 {
|
||||
panic!()
|
||||
@@ -80,18 +85,21 @@ impl From<Cents> for usize {
|
||||
}
|
||||
|
||||
impl From<usize> for Cents {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Cents> for i64 {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Cents> for u64 {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
if value.0 < 0 {
|
||||
panic!("Shouldn't convert neg cents to u64")
|
||||
@@ -122,6 +130,7 @@ impl Div<usize> for Cents {
|
||||
}
|
||||
|
||||
impl From<u128> for Cents {
|
||||
#[inline]
|
||||
fn from(value: u128) -> Self {
|
||||
if value > i64::MAX as u128 {
|
||||
panic!("u128 bigger than i64")
|
||||
@@ -131,6 +140,7 @@ impl From<u128> for Cents {
|
||||
}
|
||||
|
||||
impl From<Cents> for u128 {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
if value.0 < 0 {
|
||||
panic!("Shouldn't convert neg cents to u128")
|
||||
|
||||
@@ -77,24 +77,28 @@ impl Default for Date {
|
||||
}
|
||||
|
||||
impl From<Date_> for Date {
|
||||
#[inline]
|
||||
fn from(value: Date_) -> Self {
|
||||
Self::new(value.year() as u16, value.month() as u8, value.day() as u8)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Date> for Date_ {
|
||||
#[inline]
|
||||
fn from(value: Date) -> Self {
|
||||
Self::new(value.year() as i16, value.month() as i8, value.day() as i8).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Date> for jiff::Timestamp {
|
||||
#[inline]
|
||||
fn from(value: Date) -> Self {
|
||||
Self::from(Timestamp::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Timestamp> for Date {
|
||||
#[inline]
|
||||
fn from(value: Timestamp) -> Self {
|
||||
Self::from(Date_::from(
|
||||
jiff::Timestamp::from(value).to_zoned(TimeZone::UTC),
|
||||
@@ -103,6 +107,7 @@ impl From<Timestamp> for Date {
|
||||
}
|
||||
|
||||
impl From<DateIndex> for Date {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
if value == DateIndex::default() {
|
||||
Date::INDEX_ZERO
|
||||
|
||||
@@ -35,24 +35,28 @@ impl DateIndex {
|
||||
}
|
||||
|
||||
impl From<DateIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DateIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
value.0 as u64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for DateIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DateIndex> for i64 {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
value.0 as i64
|
||||
}
|
||||
|
||||
@@ -31,24 +31,28 @@ use super::{Date, DateIndex, YearIndex};
|
||||
pub struct DecadeIndex(u16);
|
||||
|
||||
impl From<u16> for DecadeIndex {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DecadeIndex> for u16 {
|
||||
#[inline]
|
||||
fn from(value: DecadeIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for DecadeIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DecadeIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: DecadeIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -84,12 +88,14 @@ impl Div<usize> for DecadeIndex {
|
||||
}
|
||||
|
||||
impl From<DateIndex> for DecadeIndex {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
Self::from(Date::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Date> for DecadeIndex {
|
||||
#[inline]
|
||||
fn from(value: Date) -> Self {
|
||||
let year = value.year();
|
||||
if year < 2000 {
|
||||
@@ -106,6 +112,7 @@ impl CheckedSub for DecadeIndex {
|
||||
}
|
||||
|
||||
impl From<YearIndex> for DecadeIndex {
|
||||
#[inline]
|
||||
fn from(value: YearIndex) -> Self {
|
||||
let v = usize::from(value);
|
||||
if v == 0 {
|
||||
|
||||
@@ -33,18 +33,21 @@ pub const BLOCKS_PER_DIFF_EPOCHS: u32 = 2016;
|
||||
pub struct DifficultyEpoch(u16);
|
||||
|
||||
impl From<u16> for DifficultyEpoch {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for DifficultyEpoch {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DifficultyEpoch> for usize {
|
||||
#[inline]
|
||||
fn from(value: DifficultyEpoch) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -80,6 +83,7 @@ impl Div<usize> for DifficultyEpoch {
|
||||
}
|
||||
|
||||
impl From<Height> for DifficultyEpoch {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / BLOCKS_PER_DIFF_EPOCHS) as u16)
|
||||
}
|
||||
|
||||
@@ -56,60 +56,70 @@ impl Dollars {
|
||||
}
|
||||
|
||||
impl From<f32> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: f32) -> Self {
|
||||
Self(value as f64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Cents> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: Cents) -> Self {
|
||||
Self(f64::from(value) / 100.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Dollars> for f32 {
|
||||
#[inline]
|
||||
fn from(value: Dollars) -> Self {
|
||||
value.0 as f32
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Dollars> for f64 {
|
||||
#[inline]
|
||||
fn from(value: Dollars) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Open<Dollars>> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: Open<Dollars>) -> Self {
|
||||
*value
|
||||
}
|
||||
}
|
||||
|
||||
impl From<High<Dollars>> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: High<Dollars>) -> Self {
|
||||
*value
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Low<Dollars>> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: Low<Dollars>) -> Self {
|
||||
*value
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Close<Dollars>> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: Close<Dollars>) -> Self {
|
||||
*value
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as f64)
|
||||
}
|
||||
@@ -301,24 +311,28 @@ impl Mul<usize> for Dollars {
|
||||
}
|
||||
|
||||
impl From<u128> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: u128) -> Self {
|
||||
Self::from(Cents::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StoredF64> for Dollars {
|
||||
#[inline]
|
||||
fn from(value: StoredF64) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Close<Dollars>> for u128 {
|
||||
#[inline]
|
||||
fn from(value: Close<Dollars>) -> Self {
|
||||
u128::from(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Dollars> for u128 {
|
||||
#[inline]
|
||||
fn from(value: Dollars) -> Self {
|
||||
u128::from(Cents::from(value))
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@ pub struct EmptyAddressData {
|
||||
}
|
||||
|
||||
impl From<LoadedAddressData> for EmptyAddressData {
|
||||
#[inline]
|
||||
fn from(value: LoadedAddressData) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&LoadedAddressData> for EmptyAddressData {
|
||||
#[inline]
|
||||
fn from(value: &LoadedAddressData) -> Self {
|
||||
if value.sent != value.received {
|
||||
dbg!(&value);
|
||||
|
||||
@@ -27,23 +27,27 @@ use crate::TypeIndex;
|
||||
pub struct EmptyAddressIndex(TypeIndex);
|
||||
|
||||
impl From<TypeIndex> for EmptyAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for EmptyAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<u32> for EmptyAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EmptyAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: EmptyAddressIndex) -> Self {
|
||||
usize::from(value.0)
|
||||
}
|
||||
|
||||
@@ -27,21 +27,25 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct EmptyOutputIndex(TypeIndex);
|
||||
impl From<TypeIndex> for EmptyOutputIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<EmptyOutputIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: EmptyOutputIndex) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
}
|
||||
impl From<EmptyOutputIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: EmptyOutputIndex) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
}
|
||||
impl From<usize> for EmptyOutputIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use super::{Sats, StoredU64};
|
||||
pub struct FeeRate(f64);
|
||||
|
||||
impl From<(Sats, StoredU64)> for FeeRate {
|
||||
#[inline]
|
||||
fn from((sats, vsize): (Sats, StoredU64)) -> Self {
|
||||
let sats = u64::from(sats);
|
||||
let vsize = u64::from(vsize);
|
||||
@@ -33,11 +34,13 @@ impl From<(Sats, StoredU64)> for FeeRate {
|
||||
}
|
||||
|
||||
impl From<f64> for FeeRate {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<FeeRate> for f64 {
|
||||
#[inline]
|
||||
fn from(value: FeeRate) -> Self {
|
||||
value.0
|
||||
}
|
||||
@@ -64,6 +67,7 @@ impl Div<usize> for FeeRate {
|
||||
}
|
||||
|
||||
impl From<usize> for FeeRate {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as f64)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ pub enum Format {
|
||||
}
|
||||
|
||||
impl From<Option<String>> for Format {
|
||||
#[inline]
|
||||
fn from(value: Option<String>) -> Self {
|
||||
if let Some(value) = value {
|
||||
let value = value.to_lowercase();
|
||||
|
||||
@@ -39,18 +39,21 @@ impl HalvingEpoch {
|
||||
}
|
||||
|
||||
impl From<u16> for HalvingEpoch {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for HalvingEpoch {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HalvingEpoch> for usize {
|
||||
#[inline]
|
||||
fn from(value: HalvingEpoch) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -79,6 +82,7 @@ impl Add<usize> for HalvingEpoch {
|
||||
}
|
||||
|
||||
impl From<Height> for HalvingEpoch {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / BLOCKS_PER_HALVING) as u16)
|
||||
}
|
||||
|
||||
@@ -173,46 +173,54 @@ impl Rem<usize> for Height {
|
||||
}
|
||||
|
||||
impl From<u32> for Height {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for Height {
|
||||
#[inline]
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StoredU64> for Height {
|
||||
#[inline]
|
||||
fn from(value: StoredU64) -> Self {
|
||||
Self(*value as u32)
|
||||
}
|
||||
}
|
||||
impl From<usize> for Height {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Height> for usize {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Height> for u32 {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<Height> for u64 {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
value.0 as u64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bitcoin::locktime::absolute::Height> for Height {
|
||||
#[inline]
|
||||
fn from(value: bitcoin::locktime::absolute::Height) -> Self {
|
||||
Self(value.to_consensus_u32())
|
||||
}
|
||||
@@ -226,18 +234,21 @@ impl TryFrom<&std::path::Path> for Height {
|
||||
}
|
||||
|
||||
impl From<ByteView> for Height {
|
||||
#[inline]
|
||||
fn from(value: ByteView) -> Self {
|
||||
Self(u32::from_be_bytes(copy_first_4bytes(&value).unwrap()))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Height> for ByteView {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self::new(&value.0.to_be_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Stamp> for Height {
|
||||
#[inline]
|
||||
fn from(value: Stamp) -> Self {
|
||||
let u = u64::from(value);
|
||||
assert!(u <= u32::MAX as u64);
|
||||
@@ -246,6 +257,7 @@ impl From<Stamp> for Height {
|
||||
}
|
||||
|
||||
impl From<Height> for Stamp {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self::from(value.0 as u64)
|
||||
}
|
||||
|
||||
@@ -104,12 +104,14 @@ impl LoadedAddressData {
|
||||
}
|
||||
|
||||
impl From<EmptyAddressData> for LoadedAddressData {
|
||||
#[inline]
|
||||
fn from(value: EmptyAddressData) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&EmptyAddressData> for LoadedAddressData {
|
||||
#[inline]
|
||||
fn from(value: &EmptyAddressData) -> Self {
|
||||
Self {
|
||||
tx_count: value.tx_count,
|
||||
|
||||
@@ -27,22 +27,26 @@ use crate::TypeIndex;
|
||||
pub struct LoadedAddressIndex(TypeIndex);
|
||||
|
||||
impl From<TypeIndex> for LoadedAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for LoadedAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<LoadedAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: LoadedAddressIndex) -> Self {
|
||||
usize::from(value.0)
|
||||
}
|
||||
}
|
||||
impl From<LoadedAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: LoadedAddressIndex) -> Self {
|
||||
u32::from(value.0)
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ pub struct Metric {
|
||||
}
|
||||
|
||||
impl From<String> for Metric {
|
||||
#[inline]
|
||||
fn from(metric: String) -> Self {
|
||||
Self { metric }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Metric {
|
||||
#[inline]
|
||||
fn from(metric: &str) -> Self {
|
||||
Self {
|
||||
metric: metric.to_string(),
|
||||
|
||||
@@ -16,6 +16,7 @@ const MAX_VECS: usize = 32;
|
||||
const MAX_STRING_SIZE: usize = 64 * MAX_VECS;
|
||||
|
||||
impl From<Metric> for Metrics {
|
||||
#[inline]
|
||||
fn from(metric: Metric) -> Self {
|
||||
Self {
|
||||
metrics: vec![metric],
|
||||
@@ -24,12 +25,14 @@ impl From<Metric> for Metrics {
|
||||
}
|
||||
|
||||
impl From<String> for Metrics {
|
||||
#[inline]
|
||||
fn from(value: String) -> Self {
|
||||
Self::from(Metric::from(value.replace("-", "_").to_lowercase()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Vec<&'a str>> for Metrics {
|
||||
#[inline]
|
||||
fn from(value: Vec<&'a str>) -> Self {
|
||||
Self {
|
||||
metrics: value
|
||||
|
||||
@@ -31,30 +31,35 @@ use super::{Date, DateIndex, YearIndex};
|
||||
pub struct MonthIndex(u16);
|
||||
|
||||
impl From<u16> for MonthIndex {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MonthIndex> for u16 {
|
||||
#[inline]
|
||||
fn from(value: MonthIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for MonthIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MonthIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: MonthIndex) -> Self {
|
||||
value.0 as u64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MonthIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: MonthIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -90,12 +95,14 @@ impl Div<usize> for MonthIndex {
|
||||
}
|
||||
|
||||
impl From<DateIndex> for MonthIndex {
|
||||
#[inline]
|
||||
fn from(value: DateIndex) -> Self {
|
||||
Self::from(Date::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Date> for MonthIndex {
|
||||
#[inline]
|
||||
fn from(value: Date) -> Self {
|
||||
Self(u16::from(YearIndex::from(value)) * 12 + value.month() as u16 - 1)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ pub struct OHLCCents {
|
||||
}
|
||||
|
||||
impl From<(Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>)> for OHLCCents {
|
||||
#[inline]
|
||||
fn from(value: (Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>)) -> Self {
|
||||
Self {
|
||||
open: value.0,
|
||||
@@ -34,6 +35,7 @@ impl From<(Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>)> for OHLCCents {
|
||||
}
|
||||
|
||||
impl From<Close<Cents>> for OHLCCents {
|
||||
#[inline]
|
||||
fn from(value: Close<Cents>) -> Self {
|
||||
Self {
|
||||
open: Open::from(value),
|
||||
@@ -92,6 +94,7 @@ impl Serialize for OHLCDollars {
|
||||
}
|
||||
|
||||
impl From<(Open<Dollars>, High<Dollars>, Low<Dollars>, Close<Dollars>)> for OHLCDollars {
|
||||
#[inline]
|
||||
fn from(value: (Open<Dollars>, High<Dollars>, Low<Dollars>, Close<Dollars>)) -> Self {
|
||||
Self {
|
||||
open: value.0,
|
||||
@@ -103,6 +106,7 @@ impl From<(Open<Dollars>, High<Dollars>, Low<Dollars>, Close<Dollars>)> for OHLC
|
||||
}
|
||||
|
||||
impl From<Close<Dollars>> for OHLCDollars {
|
||||
#[inline]
|
||||
fn from(value: Close<Dollars>) -> Self {
|
||||
Self {
|
||||
open: Open::from(value),
|
||||
@@ -114,12 +118,14 @@ impl From<Close<Dollars>> for OHLCDollars {
|
||||
}
|
||||
|
||||
impl From<OHLCCents> for OHLCDollars {
|
||||
#[inline]
|
||||
fn from(value: OHLCCents) -> Self {
|
||||
Self::from(&value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&OHLCCents> for OHLCDollars {
|
||||
#[inline]
|
||||
fn from(value: &OHLCCents) -> Self {
|
||||
Self {
|
||||
open: value.open.into(),
|
||||
@@ -164,6 +170,7 @@ impl Serialize for OHLCSats {
|
||||
}
|
||||
|
||||
impl From<(Open<Sats>, High<Sats>, Low<Sats>, Close<Sats>)> for OHLCSats {
|
||||
#[inline]
|
||||
fn from(value: (Open<Sats>, High<Sats>, Low<Sats>, Close<Sats>)) -> Self {
|
||||
Self {
|
||||
open: value.0,
|
||||
@@ -175,6 +182,7 @@ impl From<(Open<Sats>, High<Sats>, Low<Sats>, Close<Sats>)> for OHLCSats {
|
||||
}
|
||||
|
||||
impl From<Close<Sats>> for OHLCSats {
|
||||
#[inline]
|
||||
fn from(value: Close<Sats>) -> Self {
|
||||
Self {
|
||||
open: Open::from(value),
|
||||
@@ -226,6 +234,7 @@ impl<T> From<usize> for Open<T>
|
||||
where
|
||||
T: From<usize>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -235,6 +244,7 @@ impl<T> From<f64> for Open<T>
|
||||
where
|
||||
T: From<f64>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -244,6 +254,7 @@ impl<T> From<Open<T>> for f64
|
||||
where
|
||||
f64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Open<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -253,6 +264,7 @@ impl<T> From<Open<T>> for StoredF64
|
||||
where
|
||||
StoredF64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Open<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -262,12 +274,14 @@ impl<T> From<Close<T>> for Open<T>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Open<Cents>> for Open<Dollars> {
|
||||
#[inline]
|
||||
fn from(value: Open<Cents>) -> Self {
|
||||
Self(Dollars::from(*value))
|
||||
}
|
||||
@@ -342,6 +356,7 @@ impl<T> From<usize> for High<T>
|
||||
where
|
||||
T: From<usize>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -351,6 +366,7 @@ impl<T> From<f64> for High<T>
|
||||
where
|
||||
T: From<f64>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -360,6 +376,7 @@ impl<T> From<High<T>> for f64
|
||||
where
|
||||
f64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: High<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -369,6 +386,7 @@ impl<T> From<High<T>> for StoredF64
|
||||
where
|
||||
StoredF64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: High<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -378,12 +396,14 @@ impl<T> From<Close<T>> for High<T>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<High<Cents>> for High<Dollars> {
|
||||
#[inline]
|
||||
fn from(value: High<Cents>) -> Self {
|
||||
Self(Dollars::from(*value))
|
||||
}
|
||||
@@ -458,6 +478,7 @@ impl<T> From<usize> for Low<T>
|
||||
where
|
||||
T: From<usize>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -467,6 +488,7 @@ impl<T> From<f64> for Low<T>
|
||||
where
|
||||
T: From<f64>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -476,6 +498,7 @@ impl<T> From<Low<T>> for f64
|
||||
where
|
||||
f64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Low<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -485,6 +508,7 @@ impl<T> From<Low<T>> for StoredF64
|
||||
where
|
||||
StoredF64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Low<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -494,12 +518,14 @@ impl<T> From<Close<T>> for Low<T>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self(*value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Low<Cents>> for Low<Dollars> {
|
||||
#[inline]
|
||||
fn from(value: Low<Cents>) -> Self {
|
||||
Self(Dollars::from(*value))
|
||||
}
|
||||
@@ -575,6 +601,7 @@ impl<T> From<usize> for Close<T>
|
||||
where
|
||||
T: From<usize>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -584,6 +611,7 @@ impl<T> From<f32> for Close<T>
|
||||
where
|
||||
T: From<f32>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: f32) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -593,6 +621,7 @@ impl<T> From<f64> for Close<T>
|
||||
where
|
||||
T: From<f64>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(T::from(value))
|
||||
}
|
||||
@@ -602,6 +631,7 @@ impl<T> From<Close<T>> for f32
|
||||
where
|
||||
f32: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -611,6 +641,7 @@ impl<T> From<Close<T>> for f64
|
||||
where
|
||||
f64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -620,6 +651,7 @@ impl<T> From<Close<T>> for StoredF64
|
||||
where
|
||||
StoredF64: From<T>,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: Close<T>) -> Self {
|
||||
Self::from(value.0)
|
||||
}
|
||||
@@ -629,9 +661,11 @@ where
|
||||
// where
|
||||
// B: From<A>,
|
||||
// {
|
||||
// fn from(value: Close<A>) -> Self {
|
||||
// #[inline]
|
||||
// fn from(value: Close<A>) -> Self {
|
||||
// Self(B::from(*value))
|
||||
impl From<Close<Cents>> for Close<Dollars> {
|
||||
#[inline]
|
||||
fn from(value: Close<Cents>) -> Self {
|
||||
Self(Dollars::from(*value))
|
||||
}
|
||||
|
||||
@@ -28,21 +28,25 @@ use crate::TypeIndex;
|
||||
pub struct OpReturnIndex(TypeIndex);
|
||||
|
||||
impl From<TypeIndex> for OpReturnIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<OpReturnIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: OpReturnIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<OpReturnIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: OpReturnIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for OpReturnIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -836,6 +836,7 @@ impl OutputType {
|
||||
}
|
||||
|
||||
impl From<&ScriptBuf> for OutputType {
|
||||
#[inline]
|
||||
fn from(script: &ScriptBuf) -> Self {
|
||||
if script.is_p2pk() {
|
||||
let bytes = script.as_bytes();
|
||||
@@ -877,6 +878,7 @@ impl From<&ScriptBuf> for OutputType {
|
||||
}
|
||||
|
||||
impl From<AddressType> for OutputType {
|
||||
#[inline]
|
||||
fn from(value: AddressType) -> Self {
|
||||
match value {
|
||||
AddressType::P2a => Self::P2A,
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2AAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2AAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2AAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2AAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2AAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2AAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2AAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2AAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2AAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<P2AAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2AAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2AAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x2;
|
||||
pub struct P2ABytes(U8x2);
|
||||
|
||||
impl From<&[u8]> for P2ABytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x2::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x2> for P2ABytes {
|
||||
#[inline]
|
||||
fn from(value: U8x2) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,21 +27,25 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2MSOutputIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2MSOutputIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2MSOutputIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2MSOutputIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2MSOutputIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2MSOutputIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2MSOutputIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2PK33AddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2PK33AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2PK33AddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2PK33AddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2PK33AddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2PK33AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2PK33AddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2PK33AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2PK33AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<P2PK33AddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2PK33AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2PK33AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x33;
|
||||
pub struct P2PK33Bytes(U8x33);
|
||||
|
||||
impl From<&[u8]> for P2PK33Bytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x33::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x33> for P2PK33Bytes {
|
||||
#[inline]
|
||||
fn from(value: U8x33) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2PK65AddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2PK65AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2PK65AddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2PK65AddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2PK65AddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2PK65AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2PK65AddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2PK65AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2PK65AddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2PK65AddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2PK65AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2PK65AddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x65;
|
||||
pub struct P2PK65Bytes(U8x65);
|
||||
|
||||
impl From<&[u8]> for P2PK65Bytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x65::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x65> for P2PK65Bytes {
|
||||
#[inline]
|
||||
fn from(value: U8x65) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2PKHAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2PKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2PKHAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2PKHAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2PKHAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2PKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2PKHAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2PKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2PKHAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2PKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2PKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2PKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x20;
|
||||
pub struct P2PKHBytes(U8x20);
|
||||
|
||||
impl From<&[u8]> for P2PKHBytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x20::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x20> for P2PKHBytes {
|
||||
#[inline]
|
||||
fn from(value: U8x20) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,41 +27,49 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2SHAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2SHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2SHAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2SHAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2SHAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2SHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2SHAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2SHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2SHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<u64> for P2SHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u64) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<P2SHAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2SHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2SHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x20;
|
||||
pub struct P2SHBytes(U8x20);
|
||||
|
||||
impl From<&[u8]> for P2SHBytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x20::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x20> for P2SHBytes {
|
||||
#[inline]
|
||||
fn from(value: U8x20) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2TRAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2TRAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2TRAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2TRAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2TRAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2TRAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2TRAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2TRAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2TRAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<P2TRAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2TRAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2TRAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x32;
|
||||
pub struct P2TRBytes(U8x32);
|
||||
|
||||
impl From<&[u8]> for P2TRBytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x32::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x32> for P2TRBytes {
|
||||
#[inline]
|
||||
fn from(value: U8x32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2WPKHAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2WPKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2WPKHAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2WPKHAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2WPKHAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2WPKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2WPKHAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2WPKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2WPKHAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2WPKHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2WPKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2WPKHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x20;
|
||||
pub struct P2WPKHBytes(U8x20);
|
||||
|
||||
impl From<&[u8]> for P2WPKHBytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x20::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x20> for P2WPKHBytes {
|
||||
#[inline]
|
||||
fn from(value: U8x20) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -27,36 +27,43 @@ use crate::TypeIndex;
|
||||
)]
|
||||
pub struct P2WSHAddressIndex(TypeIndex);
|
||||
impl From<TypeIndex> for P2WSHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: TypeIndex) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl From<P2WSHAddressIndex> for TypeIndex {
|
||||
#[inline]
|
||||
fn from(value: P2WSHAddressIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
impl From<P2WSHAddressIndex> for u32 {
|
||||
#[inline]
|
||||
fn from(value: P2WSHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<P2WSHAddressIndex> for u64 {
|
||||
#[inline]
|
||||
fn from(value: P2WSHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<u32> for P2WSHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: u32) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
}
|
||||
impl From<P2WSHAddressIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: P2WSHAddressIndex) -> Self {
|
||||
Self::from(*value)
|
||||
}
|
||||
}
|
||||
impl From<usize> for P2WSHAddressIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(TypeIndex::from(value))
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ use crate::U8x32;
|
||||
pub struct P2WSHBytes(U8x32);
|
||||
|
||||
impl From<&[u8]> for P2WSHBytes {
|
||||
#[inline]
|
||||
fn from(value: &[u8]) -> Self {
|
||||
Self(U8x32::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U8x32> for P2WSHBytes {
|
||||
#[inline]
|
||||
fn from(value: U8x32) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ impl Pool {
|
||||
}
|
||||
|
||||
impl From<(usize, JSONPool)> for Pool {
|
||||
#[inline]
|
||||
fn from((index, pool): (usize, JSONPool)) -> Self {
|
||||
Self {
|
||||
id: (index as u8).into(),
|
||||
|
||||
@@ -1168,6 +1168,7 @@ pub fn pools() -> &'static Pools {
|
||||
}
|
||||
|
||||
impl From<[JSONPool; POOL_COUNT]> for Pools {
|
||||
#[inline]
|
||||
fn from(value: [JSONPool; POOL_COUNT]) -> Self {
|
||||
Pools(
|
||||
value
|
||||
|
||||
@@ -31,24 +31,28 @@ use super::MonthIndex;
|
||||
pub struct QuarterIndex(u16);
|
||||
|
||||
impl From<u16> for QuarterIndex {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for QuarterIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<QuarterIndex> for u16 {
|
||||
#[inline]
|
||||
fn from(value: QuarterIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<QuarterIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: QuarterIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -84,6 +88,7 @@ impl Div<usize> for QuarterIndex {
|
||||
}
|
||||
|
||||
impl From<MonthIndex> for QuarterIndex {
|
||||
#[inline]
|
||||
fn from(value: MonthIndex) -> Self {
|
||||
Self((usize::from(value) / 3) as u16)
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
pub struct RawLockTime(u32);
|
||||
|
||||
impl From<LockTime> for RawLockTime {
|
||||
#[inline]
|
||||
fn from(value: LockTime) -> Self {
|
||||
Self(value.to_consensus_u32())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RawLockTime> for LockTime {
|
||||
#[inline]
|
||||
fn from(value: RawLockTime) -> Self {
|
||||
let value = value.0;
|
||||
if value < LOCK_TIME_THRESHOLD {
|
||||
|
||||
@@ -81,6 +81,15 @@ impl Add for Sats {
|
||||
type Output = Self;
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
Self::from(self.0 + rhs.0)
|
||||
// Self::from(
|
||||
// self.0
|
||||
// .checked_add(rhs.0)
|
||||
// .or_else(|| {
|
||||
// dbg!(rhs);
|
||||
// panic!();
|
||||
// })
|
||||
// .unwrap(),
|
||||
// )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,59 +194,69 @@ impl Div<usize> for Sats {
|
||||
}
|
||||
|
||||
impl From<u64> for Sats {
|
||||
#[inline]
|
||||
fn from(value: u64) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Sats {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for Sats {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
Self(value.round() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Sats> for f64 {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
value.0 as f64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Sats> for usize {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Amount> for Sats {
|
||||
#[inline]
|
||||
fn from(value: Amount) -> Self {
|
||||
Self(value.to_sat())
|
||||
}
|
||||
}
|
||||
impl From<Sats> for Amount {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
Self::from_sat(value.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Bitcoin> for Sats {
|
||||
#[inline]
|
||||
fn from(value: Bitcoin) -> Self {
|
||||
Self((f64::from(value) * (Sats::ONE_BTC.0 as f64)).round() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Sats> for u64 {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u128> for Sats {
|
||||
#[inline]
|
||||
fn from(value: u128) -> Self {
|
||||
if value > u64::MAX as u128 {
|
||||
panic!("u128 bigger than u64")
|
||||
@@ -247,6 +266,7 @@ impl From<u128> for Sats {
|
||||
}
|
||||
|
||||
impl From<Sats> for u128 {
|
||||
#[inline]
|
||||
fn from(value: Sats) -> Self {
|
||||
value.0 as u128
|
||||
}
|
||||
|
||||
@@ -31,24 +31,28 @@ use super::MonthIndex;
|
||||
pub struct SemesterIndex(u16);
|
||||
|
||||
impl From<u16> for SemesterIndex {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for SemesterIndex {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SemesterIndex> for u16 {
|
||||
#[inline]
|
||||
fn from(value: SemesterIndex) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SemesterIndex> for usize {
|
||||
#[inline]
|
||||
fn from(value: SemesterIndex) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
@@ -84,6 +88,7 @@ impl Div<usize> for SemesterIndex {
|
||||
}
|
||||
|
||||
impl From<MonthIndex> for SemesterIndex {
|
||||
#[inline]
|
||||
fn from(value: MonthIndex) -> Self {
|
||||
Self((usize::from(value) / 6) as u16)
|
||||
}
|
||||
|
||||
@@ -38,12 +38,14 @@ impl StoredBool {
|
||||
}
|
||||
|
||||
impl From<bool> for StoredBool {
|
||||
#[inline]
|
||||
fn from(value: bool) -> Self {
|
||||
if value { Self(1) } else { Self(0) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StoredBool> for usize {
|
||||
#[inline]
|
||||
fn from(value: StoredBool) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user