bitview: reorg part 7 + fix hanging ?

This commit is contained in:
nym21
2025-09-28 20:33:55 +02:00
parent 9d03fdf31d
commit 7407c032e5
16 changed files with 581 additions and 495 deletions

287
Cargo.lock generated
View File

@@ -515,6 +515,52 @@ dependencies = [
"brk_structs",
]
[[package]]
name = "brk-file-id"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c1950d399f52e1f5094028ce390381e75649cf4409fca898047005a6dad3afd"
dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "brk-notify"
version = "8.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca1c0159b584e64e5dda5bcd1a773435514aeabbcf5b1afc194381b465d8fa01"
dependencies = [
"bitflags 2.9.4",
"brk-notify-types",
"fsevent-sys",
"inotify",
"kqueue",
"libc",
"log",
"mio",
"walkdir",
"windows-sys 0.60.2",
]
[[package]]
name = "brk-notify-debouncer-full"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36157ad4fe408d3958da182e0d56a2928eddb098649a241efcc9e1fe9076dc96"
dependencies = [
"brk-file-id",
"brk-notify",
"brk-notify-types",
"log",
"walkdir",
]
[[package]]
name = "brk-notify-types"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ff3e445e42475fba5e0cfaed51345f491e479b9f2069f29875f434a5327913"
[[package]]
name = "brk_bridge"
version = "0.0.109"
@@ -542,13 +588,13 @@ dependencies = [
"brk_bridge",
"brk_bundler",
"brk_computer",
"brk_error",
"brk_fetcher",
"brk_indexer",
"brk_interface",
"brk_logger",
"brk_parser",
"brk_server",
"brk_structs",
"clap",
"color-eyre",
"log",
@@ -727,14 +773,15 @@ dependencies = [
[[package]]
name = "brk_rolldown"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0dfb4767a625199016aa5be14edc12e63e7a3b22e9b7d5cc37582f76d1d7d24"
checksum = "76d5237104ef0c275a1c50354392a7edb45fc736998479530c231d811a0a38e0"
dependencies = [
"anyhow",
"append-only-vec",
"arcstr",
"bitflags 2.9.4",
"brk-notify",
"brk_rolldown_common",
"brk_rolldown_debug",
"brk_rolldown_ecmascript",
@@ -745,6 +792,7 @@ dependencies = [
"brk_rolldown_plugin_chunk_import_map",
"brk_rolldown_plugin_data_uri",
"brk_rolldown_plugin_hmr",
"brk_rolldown_plugin_oxc_runtime",
"brk_rolldown_resolver",
"brk_rolldown_sourcemap",
"brk_rolldown_std_utils",
@@ -754,13 +802,13 @@ dependencies = [
"brk_string_wizard",
"commondir",
"css-module-lexer",
"derive_more",
"dunce",
"futures",
"indexmap 2.11.4",
"itertools",
"itoa",
"memchr",
"notify",
"oxc",
"oxc_allocator",
"oxc_ecmascript",
@@ -780,9 +828,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_common"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3412bb06f9eef1d34ad8d8decd55f7625db7852d440e3fececafdaddac367b0"
checksum = "80d4461576c24766fdea280ce888e6d8dc36f50161e2615fd6a698511d623f36"
dependencies = [
"anyhow",
"arcstr",
@@ -805,15 +853,16 @@ dependencies = [
"rustc-hash",
"serde",
"serde_json",
"simdutf8",
"sugar_path",
"tokio",
]
[[package]]
name = "brk_rolldown_debug"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e28020dcca285e50003eab2faed661a3f147e5c3b7b103ac7fa46f3d9811656"
checksum = "e6d03984d81260c4d9d068431eda178b59a3eaf539d67d1cc6cd2b0dc28140d5"
dependencies = [
"blake3",
"brk_rolldown_debug_action",
@@ -827,9 +876,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_debug_action"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b55010d6b5a8dcf3524ca8b504680a9387dd5709c555fe6e1c87fca3f77b5b89"
checksum = "e03dc81df86ed78c962fb675bc4d3ecf5988ec8813dddc41701b3c496e29514b"
dependencies = [
"serde",
"ts-rs",
@@ -837,9 +886,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_ecmascript"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5f4324e457d930dc61bc2fa1ec6ca006ab8f1b25b3a7d4e89e64b009a92244"
checksum = "4c5f433cfd8f7d5b9a054422770e7477a24c398493e8cd42e15f712dbda9d280"
dependencies = [
"arcstr",
"brk_rolldown_error",
@@ -850,9 +899,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_ecmascript_utils"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4e67014dd9afcc8982f3e03d0f6f0389e8f8e38aed8130368678f2599d18630"
checksum = "4358a13b70a7a647f61ba95caae66e6c747b10d5cba784e6c38636b2011267a0"
dependencies = [
"brk_rolldown_common",
"oxc",
@@ -861,9 +910,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_error"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7b1666952fcfc93fb494638c26be72aae73cca2267834fa3fd9657e32fdbb8f"
checksum = "fd9a2e23e1e5dfbfacfaa01fd6adbb05511233ca7c128dde3f4b38d74de0a3b9"
dependencies = [
"anyhow",
"arcstr",
@@ -881,9 +930,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_fs"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "364160f3619b61db2dba73539ca9df72326bcf6516eedb84479f9aec7ff916a3"
checksum = "c9ef43d8e0f263b04febb3972ddbb95792abf510c74b4df9a7849786bd557acb"
dependencies = [
"oxc_resolver",
"vfs",
@@ -891,9 +940,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_plugin"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57211c1b798955a934c68c3d5288df64c5215f9bf8117371aa229eb8284048d8"
checksum = "79b87d794281878edb320543a514a6d25b47d4f78a2744b674a19db01e10c0d2"
dependencies = [
"anyhow",
"arcstr",
@@ -921,9 +970,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_plugin_chunk_import_map"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e312f5953e7dcfb1d7bdb02cf996e0c83fc0bb27601681836b53973755bad18e"
checksum = "17b70821f39dc678e05d16e75e7549b90acdd6f87d408b42120e586850ee6014"
dependencies = [
"arcstr",
"brk_rolldown_common",
@@ -936,23 +985,24 @@ dependencies = [
[[package]]
name = "brk_rolldown_plugin_data_uri"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75d9bfa5cda344f58deff64c9da579edfa51d78f340b92faac08c201cc642ee9"
checksum = "d1012b5c731c4c1e21169997a115d6273f6cc10d01726eb58509fa58dec39aa7"
dependencies = [
"arcstr",
"base64-simd",
"brk_rolldown_common",
"brk_rolldown_plugin",
"brk_rolldown_utils",
"simdutf8",
"urlencoding",
]
[[package]]
name = "brk_rolldown_plugin_hmr"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed08c47846e429ffe87a047206ac3a2251659d01e28b4fecb0a5fc1881624a7b"
checksum = "94bf2c1f5735ad763df8805d47fbb04af7bd622be89abac7339e04415b3a69a9"
dependencies = [
"arcstr",
"brk_rolldown_common",
@@ -961,10 +1011,22 @@ dependencies = [
]
[[package]]
name = "brk_rolldown_resolver"
version = "0.1.5"
name = "brk_rolldown_plugin_oxc_runtime"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d99246fc977891718c909a99330f58d80ea4fa079cab4acf37bf58055e0bbeb4"
checksum = "7631bc3c34d8c95ed2fdcc10fd53e761fec6509b2f7804cbde800ca813e8c32d"
dependencies = [
"arcstr",
"brk_rolldown_plugin",
"brk_rolldown_utils",
"phf",
]
[[package]]
name = "brk_rolldown_resolver"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c08ca0eac64956b1b81af47f360a7c2107292475efe4e04605a20257753fde5"
dependencies = [
"arcstr",
"brk_rolldown_common",
@@ -978,9 +1040,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_sourcemap"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0e238138ca5395313ca4376d3b412450653cf701935e6c05ad32e1c317598ca"
checksum = "63859586276da70f2f8239ca558a0fc6f047fdea2c6856cca9c5056cd6a8963a"
dependencies = [
"brk_rolldown_utils",
"memchr",
@@ -991,18 +1053,18 @@ dependencies = [
[[package]]
name = "brk_rolldown_std_utils"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9672fb5d256a9c944b4050cbf69f06f68274264aaa97d45d25b2f226a05ed269"
checksum = "754a91681b732fdc7e0118f8f356e1f7428b66ce00339688a1c2e8591b98edb2"
dependencies = [
"regex",
]
[[package]]
name = "brk_rolldown_tracing"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b33f1e5d84a5f6a065dc35db551ebedb20501d95955c76b110439965d2e1c14d"
checksum = "da33c2b40ddb7390f299fa7ff7bd74d2ecd80dd57ad2a4cdef131412605090c4"
dependencies = [
"tracing",
"tracing-chrome",
@@ -1011,9 +1073,9 @@ dependencies = [
[[package]]
name = "brk_rolldown_utils"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f39314bf9875e0b461aadc293b3156063ecc2e4fcdb76decb5d051b1c32f0449"
checksum = "aeb807d38d854c3f71c7640b31961da59de3bff3f9498b79e31570debaf74a4f"
dependencies = [
"anyhow",
"arcstr",
@@ -1049,13 +1111,13 @@ dependencies = [
[[package]]
name = "brk_rolldown_watcher"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53159dd01ed61374892e101ea5afe34862fade82ae8aedc17a36c1664923a2ac"
checksum = "cac059d6804c44336f882a87d568bc866cb6fbf8ecd5a083aaf0a310230a2909"
dependencies = [
"brk-notify",
"brk-notify-debouncer-full",
"brk_rolldown_error",
"notify",
"notify-debouncer-full",
]
[[package]]
@@ -1100,10 +1162,11 @@ dependencies = [
[[package]]
name = "brk_string_wizard"
version = "0.1.5"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c40057b36de33ed24a8b78e81e190e134f4cb6f85e25d5a133536c40ab4ddb6d"
checksum = "b7117e64fd4da49fe64dcebbbd8f4e490b1c07fdf99e4c22e2cefa0e130da480"
dependencies = [
"memchr",
"oxc_index",
"oxc_sourcemap",
"rustc-hash",
@@ -1810,15 +1873,6 @@ dependencies = [
"simdutf8",
]
[[package]]
name = "file-id"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1fc6a637b6dc58414714eddd9170ff187ecb0933d4c7024d1abbd23a3cc26e9"
dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "filetime"
version = "0.2.26"
@@ -2768,19 +2822,6 @@ dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "notify-debouncer-full"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375bd3a138be7bfeff3480e4a623df4cbfb55b79df617c055cd810ba466fa078"
dependencies = [
"file-id",
"log",
"notify",
"notify-types",
"walkdir",
]
[[package]]
name = "notify-types"
version = "2.0.0"
@@ -2903,9 +2944,9 @@ checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
[[package]]
name = "oxc"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1273a1f856d670d49d62ac0e362a6989ea3be208f6846aab85f34383a04b0fae"
checksum = "514174b0464005dd95e873f5236089949ab77c79cc8a8e9352721f06d45a0b8d"
dependencies = [
"oxc_allocator",
"oxc_ast",
@@ -2969,9 +3010,9 @@ dependencies = [
[[package]]
name = "oxc_allocator"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90237f36cf0cd3ea2dcf9682b48fa0c1762a4b407fdcc630f60a72c277877c9f"
checksum = "79d9ac4e239df6f418d86176aa4af85f850f60823a8708fd50a6f7d6f475a07d"
dependencies = [
"allocator-api2",
"bumpalo",
@@ -2984,9 +3025,9 @@ dependencies = [
[[package]]
name = "oxc_ast"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a73ff824d44e51ac6c20381b644d48db4326935e811eeab29d52ca45e4d19670"
checksum = "013500b777b89130b5f79b545d252d9a147db7ef91f07954da394400ae7f14c9"
dependencies = [
"bitflags 2.9.4",
"oxc_allocator",
@@ -3001,9 +3042,9 @@ dependencies = [
[[package]]
name = "oxc_ast_macros"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f6af164ffae11248f32c449dad6a15f85d2154fe398bfec75502e0e2af5767a"
checksum = "9711ea5f01691277822413f0bb56085ac1b867f9cb2090387f634a94a2d4f64c"
dependencies = [
"phf",
"proc-macro2",
@@ -3013,9 +3054,9 @@ dependencies = [
[[package]]
name = "oxc_ast_visit"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0ff52052e2cfb72fff062d4b7a393f9e9bded601dc16df796e3e460e17a9031"
checksum = "95f0e1f45a19d14d9e4660f426fb8abe31c86b43a43c426a6d182e786994b0bb"
dependencies = [
"oxc_allocator",
"oxc_ast",
@@ -3025,9 +3066,9 @@ dependencies = [
[[package]]
name = "oxc_cfg"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859f43d20760f159a0b94264bd4d1d0b3c062b69c074d894e80e65295117719b"
checksum = "a32fdc832b6ed9b007f44022e3b273e5b2cc6d798a91ea5b46e150858b17be40"
dependencies = [
"bitflags 2.9.4",
"itertools",
@@ -3040,9 +3081,9 @@ dependencies = [
[[package]]
name = "oxc_codegen"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08e84ab41c9f848471f206674c94781bdc0364699fb14574a3d26dd2a2985844"
checksum = "b9e9e29e30d2252903c4c5e1104fb7542365d57ceba83e16d4f52b436f7ffa5d"
dependencies = [
"bitflags 2.9.4",
"cow-utils",
@@ -3061,19 +3102,32 @@ dependencies = [
]
[[package]]
name = "oxc_data_structures"
version = "0.87.0"
name = "oxc_compat"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f048c4ae3569bcc9dbbed29730b5c5f6dd3a35e9f5c3750cd4b3ed72381fbd0"
checksum = "42631ddd366f3a6b829d346a5d8ceb4fb3a3796293916f437b244c4e60fa4dd9"
dependencies = [
"cow-utils",
"oxc-browserslist",
"oxc_syntax",
"rustc-hash",
"serde",
]
[[package]]
name = "oxc_data_structures"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bccdfe08b75babe4944aefcc84f8d795d48a0155fcb20c4855c46eabf6e5d49"
dependencies = [
"ropey",
]
[[package]]
name = "oxc_diagnostics"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d96c95294deec2f038e8c7749a751f929c263da34cc68a621472c57c916c14e"
checksum = "e710dd26a2946f906ccd449a2d34f195b0461e5a8776db067ed207189f0213f3"
dependencies = [
"cow-utils",
"oxc-miette",
@@ -3082,9 +3136,9 @@ dependencies = [
[[package]]
name = "oxc_ecmascript"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa7b86782020722b3190c083dfc3de59cb73425d1fa275ff6f91b5b4ee509550"
checksum = "80c03f1a2246f422197c317585b056dbc283a4cfb10c8058cb3296b87cb835da"
dependencies = [
"cow-utils",
"num-bigint",
@@ -3097,9 +3151,9 @@ dependencies = [
[[package]]
name = "oxc_estree"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97f7078ef0c6da21657f5dcade4540c65a460d2a26a42e4418d12ecac860143a"
checksum = "36ee39a2fc76ae96ccb5dcfea6c430e09e93e4fbcd9ec7f35fe787ea3fb6873a"
dependencies = [
"dragonbox_ecma",
"itoa",
@@ -3118,9 +3172,9 @@ dependencies = [
[[package]]
name = "oxc_isolated_declarations"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75e6efdb4f6d09772773cc254caed257270b2b32ee4df21dac196dfb0d966c1e"
checksum = "132bb2006e95e63c0b07cc45c30e6d0de6bb643036d7b6316f7c1398a72c1c42"
dependencies = [
"bitflags 2.9.4",
"oxc_allocator",
@@ -3135,9 +3189,9 @@ dependencies = [
[[package]]
name = "oxc_mangler"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "401c8ff0fc5e60c94a5821b768bf019a42a0d058469dd26e604dda57723bc404"
checksum = "cb797e995b53f0e112b0a1359f967de7cb3a702b46fa2492d6025be4de175a65"
dependencies = [
"itertools",
"oxc_allocator",
@@ -3151,15 +3205,17 @@ dependencies = [
[[package]]
name = "oxc_minifier"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd50617ac26b8cd1e6788dbb527ce16704f47fd5e8e6d87fee4a5e63224a71e8"
checksum = "61dfdcff432cacd8257093842d1494225f72cbea8286610b86abfbad59a16003"
dependencies = [
"cow-utils",
"oxc_allocator",
"oxc_ast",
"oxc_ast_visit",
"oxc_codegen",
"oxc_compat",
"oxc_data_structures",
"oxc_ecmascript",
"oxc_mangler",
"oxc_parser",
@@ -3173,9 +3229,9 @@ dependencies = [
[[package]]
name = "oxc_parser"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef71ea1e9bde8ff15f89b60874363359fc7e9796de7bf6cdff69fa54f6869bba"
checksum = "86612cd26f817679d522b7ed33e525537ec5c0a7165d4d23138b8cbaf896d0d5"
dependencies = [
"bitflags 2.9.4",
"cow-utils",
@@ -3196,9 +3252,9 @@ dependencies = [
[[package]]
name = "oxc_regular_expression"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a4df17b1c47c7fe749208f3a32158dfe90dca5ce630ce86cb9415521f87eb3"
checksum = "e7dc07d4e5d8337f5b6bbadadf1787d2a320f99969c9602ed03c823babd0084a"
dependencies = [
"bitflags 2.9.4",
"oxc_allocator",
@@ -3212,9 +3268,9 @@ dependencies = [
[[package]]
name = "oxc_resolver"
version = "11.8.3"
version = "11.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c553f3d6a88eb57513b4bb6b8387ab71c7701721ecd242b673ffeb3dc99cfd08"
checksum = "743c415f2237308d3a50d15d5ab5e432fd44c3b2c77042b01bbbd4e5e7d1ca0f"
dependencies = [
"cfg-if",
"indexmap 2.11.4",
@@ -3235,9 +3291,9 @@ dependencies = [
[[package]]
name = "oxc_semantic"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8239fa4e6eaee7a16039a3292a3adbaa645ba3013bf2f801517d8fadc4396557"
checksum = "f9ce8984f6054d3deafebff4e318fea5a38d281905be8bf555e625a7d7c63220"
dependencies = [
"itertools",
"oxc_allocator",
@@ -3257,9 +3313,9 @@ dependencies = [
[[package]]
name = "oxc_sourcemap"
version = "4.2.1"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ff280f25901ac054ad8552395ecd6a455e4b9352a94debbc34c433760586ef"
checksum = "d3e5d53a1bdb071d10a83cc0b4c69ca6ebb55d55fc6333897aef72c057830b95"
dependencies = [
"base64-simd",
"json-escape-simd",
@@ -3270,9 +3326,9 @@ dependencies = [
[[package]]
name = "oxc_span"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d88265af3fb8fc2a2317144dfc40b5e120e0ebe21693cfbf7508d4d3ec6d74f"
checksum = "be7ea89d6e858be16ef14f9a9be81ee210c17cb29bb95d5c86881251075071af"
dependencies = [
"compact_str",
"oxc-miette",
@@ -3284,9 +3340,9 @@ dependencies = [
[[package]]
name = "oxc_syntax"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2596e7891b08899f7b74a1fb87b5f5c14153918bb2966648c84581f0a7e6795"
checksum = "a6477f14f0e380033455f0e3e6cdc33fd19932fe5f627a17b38e4666649336cb"
dependencies = [
"bitflags 2.9.4",
"cow-utils",
@@ -3306,20 +3362,19 @@ dependencies = [
[[package]]
name = "oxc_transformer"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd3cadde4466d8b059bd5032e248a172dfd1dfdcdf82388d3d87bc36b023e895"
checksum = "7c10b7504559c08191c3881ef53fb671619c62c9cc26bd5e66274c68057e6ad3"
dependencies = [
"base64 0.22.1",
"compact_str",
"cow-utils",
"indexmap 2.11.4",
"itoa",
"memchr",
"oxc-browserslist",
"oxc_allocator",
"oxc_ast",
"oxc_ast_visit",
"oxc_compat",
"oxc_data_structures",
"oxc_diagnostics",
"oxc_ecmascript",
@@ -3337,9 +3392,9 @@ dependencies = [
[[package]]
name = "oxc_transformer_plugins"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633645296d62b4550dcf3a28ef08a21055b09b6966feae36043c367b1f511345"
checksum = "1592bc6214448a4986e72e1f7a71ca52e5b7135e831e806eb09bb9a29343dbaf"
dependencies = [
"cow-utils",
"itoa",
@@ -3359,9 +3414,9 @@ dependencies = [
[[package]]
name = "oxc_traverse"
version = "0.87.0"
version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d4dfe9de6b462cb2b2e8e1040b912233781dbb4032c8266f30297a9e2cf4155"
checksum = "8bc2faa1b10f9044f0ef34cb3959684836733d0168ce98504e47010e000ee62e"
dependencies = [
"itoa",
"oxc_allocator",

View File

@@ -26,7 +26,7 @@ impl Bridge for Interface<'static> {
return Ok(());
}
let path = packages_path.join("generated");
let path = path.join("generated");
fs::create_dir_all(&path)?;
generate_version_file(&path)?;
@@ -101,7 +101,10 @@ fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::R
contents += &format!(
"
* @typedef {{{}}} Index",
* @typedef {{{}}} Index
*/
",
indexes
.iter()
.map(|i| i.to_string())
@@ -111,14 +114,6 @@ fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::R
let mut unique_index_groups = BTreeMap::new();
contents += "
*
* @typedef {typeof COMPRESSED_METRIC_TO_INDEXES} MetricToIndexes
* @typedef {string} Metric
*/
";
let mut word_to_freq: BTreeMap<_, usize> = BTreeMap::new();
interface
.metric_to_index_to_vec()
@@ -136,9 +131,10 @@ fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::R
.collect::<Vec<_>>();
contents += &format!(
"const INDEX_TO_WORD = [
"export const INDEX_TO_WORD = [
{}
];
",
words
.iter()
@@ -147,55 +143,6 @@ fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::R
.join(",\n ")
);
contents += "
const WORD_TO_INDEX = {};
INDEX_TO_WORD.forEach((word, index) => {
WORD_TO_INDEX[word] = index;
});
function lettersToIndex(s) {
let result = 0;
for (let i = 0; i < s.length; i++) {
const value = charToIndex(s.charCodeAt(i));
result = result * 52 + value + 1;
}
return result - 1;
}
function charToIndex(c) {
const A = 65, Z = 90, a = 97, z = 122;
if (c >= A && c <= Z) {
return c - A;
} else if (c >= a && c <= z) {
return c - a + 26;
} else {
return 255; // Invalid
}
}
function compressMetric(metric) {
return metric
.split('_')
.map((word) => {
const index = WORD_TO_INDEX[word];
if (index === undefined) throw \"bad word\";
return indexToLetters(index);
})
.join('_');
}
function decompressMetric(compressedMetric) {
return compressedMetric
.split('_')
.map((code) => {
const index = lettersToIndex(code);
return WORDS[index] || code; // Fallback to original if not found
})
.join('_');
}
";
let word_to_base62 = words
.into_iter()
.enumerate()
@@ -204,7 +151,7 @@ function decompressMetric(compressedMetric) {
let mut ser_metric_to_indexes = "
/** @type {Record<string, Index[]>} */
const COMPRESSED_METRIC_TO_INDEXES = {
export const COMPRESSED_METRIC_TO_INDEXES = {
"
.to_string();

View File

@@ -12,7 +12,7 @@ build = "build.rs"
[dependencies]
log = { workspace = true }
notify = "8.2.0"
brk_rolldown = "0.1.5"
brk_rolldown = "0.2.3"
# brk_rolldown = { path = "../../../rolldown/crates/rolldown"}
sugar_path = "1.2.0"
tokio = { workspace = true }

View File

@@ -14,15 +14,20 @@ use tokio::sync::Mutex;
const VERSION: &str = env!("CARGO_PKG_VERSION");
pub async fn bundle(websites_path: &Path, source_folder: &str, watch: bool) -> io::Result<PathBuf> {
pub async fn bundle(
packages_path: &Path,
websites_path: &Path,
source_folder: &str,
watch: bool,
) -> io::Result<PathBuf> {
let relative_packages_path = packages_path;
let relative_source_path = websites_path.join(source_folder);
let relative_dist_path = websites_path.join("dist");
let relative_packages_path = websites_path.join("packages");
let absolute_websites_path = websites_path.absolutize();
let absolute_websites_path_clone = absolute_websites_path.clone();
let absolute_packages_path = relative_packages_path.absolutize();
let absolute_packages_path_clone = absolute_packages_path.clone();
let absolute_websites_path = websites_path.absolutize();
let absolute_websites_path_clone = absolute_websites_path.clone();
let absolute_source_path = relative_source_path.absolutize();
let absolute_source_index_path = absolute_source_path.join("index.html");
@@ -53,7 +58,8 @@ pub async fn bundle(websites_path: &Path, source_folder: &str, watch: bool) -> i
minify: Some(RawMinifyOptions::Bool(true)),
sourcemap: Some(SourceMapType::File),
..Default::default()
});
})
.unwrap();
if let Err(error) = bundler.write().await {
error!("{error:?}");
@@ -135,6 +141,9 @@ pub async fn bundle(websites_path: &Path, source_folder: &str, watch: bool) -> i
event_watcher
.watch(&absolute_websites_path_clone, RecursiveMode::Recursive)
.unwrap();
event_watcher
.watch(&absolute_packages_path_clone, RecursiveMode::Recursive)
.unwrap();
let watcher =
brk_rolldown::Watcher::new(vec![Arc::new(Mutex::new(bundler))], None).unwrap();

View File

@@ -14,13 +14,13 @@ bitcoincore-rpc = { workspace = true }
brk_bridge = { workspace = true }
brk_bundler = { workspace = true }
brk_computer = { workspace = true }
brk_error = { workspace = true }
brk_fetcher = { workspace = true }
brk_indexer = { workspace = true }
brk_interface = { workspace = true }
brk_logger = { workspace = true }
brk_parser = { workspace = true }
brk_server = { workspace = true }
brk_structs = { workspace = true }
vecdb = { workspace = true }
clap = { version = "4.5.48", features = ["derive", "string"] }
color-eyre = "0.6.5"

View File

@@ -12,6 +12,7 @@ use bitcoincore_rpc::{self, RpcApi};
use brk_bridge::Bridge;
use brk_bundler::bundle;
use brk_computer::Computer;
use brk_error::Result;
use brk_indexer::Indexer;
use brk_interface::Interface;
use brk_parser::Parser;
@@ -59,7 +60,7 @@ pub fn run() -> color_eyre::Result<()> {
let downloads_path = config.downloads_dir();
let future = async {
let future = async move {
let bundle_path = if website.is_some() {
let websites_dev_path = Path::new("../../websites");
let packages_dev_path = Path::new("../../packages");
@@ -67,7 +68,7 @@ pub fn run() -> color_eyre::Result<()> {
let websites_path;
let packages_path;
if fs::exists(websites_dev_path)? {
if fs::exists(websites_dev_path)? && fs::exists(packages_dev_path)? {
websites_path = websites_dev_path.to_path_buf();
packages_path = packages_dev_path.to_path_buf();
} else {
@@ -98,7 +99,15 @@ pub fn run() -> color_eyre::Result<()> {
interface.generate_js_files(&packages_path)?;
Some(bundle(&websites_path, website.to_folder_name(), true).await?)
Some(
bundle(
&packages_path,
&websites_path,
website.to_folder_name(),
true,
)
.await?,
)
} else {
None
};
@@ -109,35 +118,35 @@ pub fn run() -> color_eyre::Result<()> {
server.serve(true).await.unwrap();
});
sleep(Duration::from_secs(1));
loop {
wait_for_synced_node(rpc)?;
let block_count = rpc.get_block_count()?;
info!("{} blocks found.", block_count + 1);
let starting_indexes = indexer
.index(&parser, rpc, &exit, config.check_collisions())
.unwrap();
computer
.compute(&indexer, starting_indexes, &parser, &exit)
.unwrap();
info!("Waiting for new blocks...");
while block_count == rpc.get_block_count()? {
sleep(Duration::from_secs(1))
}
}
Ok(()) as Result<()>
};
tokio::runtime::Builder::new_multi_thread()
let _handle = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?
.block_on(future)
.spawn(future);
loop {
wait_for_synced_node(rpc)?;
let block_count = rpc.get_block_count()?;
info!("{} blocks found.", block_count + 1);
let starting_indexes = indexer
.index(&parser, rpc, &exit, config.check_collisions())
.unwrap();
computer
.compute(&indexer, starting_indexes, &parser, &exit)
.unwrap();
info!("Waiting for new blocks...");
while block_count == rpc.get_block_count()? {
sleep(Duration::from_secs(1))
}
}
}
fn wait_for_synced_node(rpc_client: &bitcoincore_rpc::Client) -> color_eyre::Result<()> {
@@ -147,7 +156,7 @@ fn wait_for_synced_node(rpc_client: &bitcoincore_rpc::Client) -> color_eyre::Res
};
if !is_synced()? {
info!("Waiting for node to be synced...");
info!("Waiting for node to sync...");
while !is_synced()? {
sleep(Duration::from_secs(1))
}

View File

@@ -34,7 +34,7 @@ pub struct Indexes {
}
impl Indexes {
pub fn typeindex(&self, outputtype: OutputType) -> TypeIndex {
pub fn to_typeindex(&self, outputtype: OutputType) -> TypeIndex {
match outputtype {
OutputType::Empty => *self.emptyoutputindex,
OutputType::OpReturn => *self.opreturnindex,

View File

@@ -1,10 +1,9 @@
#![doc = include_str!("../README.md")]
use std::{collections::BTreeMap, path::Path, str::FromStr, thread, time::Instant};
use std::{collections::BTreeMap, path::Path, str::FromStr, time::Instant};
use bitcoin::{Transaction, TxIn, TxOut};
use brk_error::{Error, Result};
use brk_parser::Parser;
use brk_store::AnyStore;
use brk_structs::{
@@ -24,9 +23,8 @@ pub use stores::*;
pub use vecs::*;
// One version for all data sources
// Increment on change OR addition
// Increment on **change _OR_ addition**
const VERSION: Version = Version::new(21);
const SNAPSHOT_BLOCK_RANGE: usize = 1_000;
const COLLISIONS_CHECKED_UP_TO: Height = Height::new(909_150);
@@ -92,6 +90,7 @@ impl Indexer {
let export =
|stores: &mut Stores, vecs: &mut Vecs, height: Height, exit: &Exit| -> Result<()> {
info!("Exporting...");
// std::process::exit(0);
let _lock = exit.lock();
let i = Instant::now();
stores.commit(height).unwrap();
@@ -184,7 +183,7 @@ impl Indexer {
let p2aaddressindex_to_p2abytes_reader = p2aaddressindex_to_p2abytes_reader_opt.as_ref().unwrap();
// Used to check rapidhash collisions
let check_collisions = check_collisions && height > COLLISIONS_CHECKED_UP_TO ;
let check_collisions = check_collisions && height > COLLISIONS_CHECKED_UP_TO;
let blockhash_prefix = BlockHashPrefix::from(blockhash);
@@ -215,275 +214,241 @@ impl Indexer {
vecs.height_to_total_size.push_if_needed(height, block.total_size().into())?;
vecs.height_to_weight.push_if_needed(height, block.weight().into())?;
let (
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_join_handle,
input_source_vec_handle,
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle,
) = thread::scope(|scope| {
let txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle =
scope.spawn(|| -> Result<_> {
block
.txdata
.iter()
.enumerate()
.map(|(index, tx)| {
let txid = Txid::from(tx.compute_txid());
let txid_prefix_to_txid_and_block_txindex_and_prev_txindex = block
.txdata
.par_iter()
.enumerate()
.map(|(index, tx)| {
let txid = Txid::from(tx.compute_txid());
let txid_prefix = TxidPrefix::from(&txid);
let txid_prefix = TxidPrefix::from(&txid);
let prev_txindex_opt =
if check_collisions && stores.txidprefix_to_txindex.needs(height) {
// Should only find collisions for two txids (duplicates), see below
stores.txidprefix_to_txindex.get(&txid_prefix)?.map(|v| *v)
} else {
None
};
let prev_txindex_opt =
if check_collisions && stores.txidprefix_to_txindex.needs(height) {
// Should only find collisions for two txids (duplicates), see below
stores.txidprefix_to_txindex.get(&txid_prefix)?.map(|v| *v)
} else {
None
};
Ok((txid_prefix, (tx, txid, TxIndex::from(index), prev_txindex_opt)))
})
.collect::<Result<BTreeMap<_, _>>>()
});
Ok((txid_prefix, (tx, txid, TxIndex::from(index), prev_txindex_opt)))
})
.collect::<Result<BTreeMap<_, _>>>()?;
let input_source_vec_handle = scope.spawn(|| {
let inputs = block
.txdata
let inputs = block
.txdata
.iter()
.enumerate()
.flat_map(|(index, tx)| {
tx.input
.iter()
.enumerate()
.flat_map(|(index, tx)| {
tx.input
.iter()
.enumerate()
.map(move |(vin, txin)| (TxIndex::from(index), Vin::from(vin), txin, tx))
})
.collect::<Vec<_>>();
.map(move |(vin, txin)| (TxIndex::from(index), Vin::from(vin), txin, tx))
})
.collect::<Vec<_>>();
inputs
.into_par_iter()
let input_source_vec = inputs
.into_par_iter()
.enumerate()
.map(|(block_inputindex, (block_txindex, vin, txin, tx))| -> Result<(InputIndex, InputSource)> {
let txindex = idxs.txindex + block_txindex;
let inputindex = idxs.inputindex + InputIndex::from(block_inputindex);
let outpoint = txin.previous_output;
let txid = Txid::from(outpoint.txid);
if tx.is_coinbase() {
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
}
let prev_txindex = if let Some(txindex) = stores
.txidprefix_to_txindex
.get(&TxidPrefix::from(&txid))?
.map(|v| *v)
.and_then(|txindex| {
// Checking if not finding txindex from the future
(txindex < idxs.txindex).then_some(txindex)
}) {
txindex
} else {
// dbg!(indexes.txindex + block_txindex, txindex, txin, vin);
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
};
let vout = Vout::from(outpoint.vout);
let outputindex = vecs.txindex_to_first_outputindex.get_or_read(prev_txindex, txindex_to_first_outputindex_reader)?
.ok_or(Error::Str("Expect outputindex to not be none"))
.inspect_err(|_| {
dbg!(outpoint.txid, prev_txindex, vout);
})?.into_owned()
+ vout;
Ok((inputindex, InputSource::PreviousBlock((
vin,
txindex,
outputindex,
))))
})
.try_fold(BTreeMap::new, |mut map, tuple| -> Result<_> {
let (key, value) = tuple?;
map.insert(key, value);
Ok(map)
})
.try_reduce(BTreeMap::new, |mut map, mut map2| {
if map.len() > map2.len() {
map.append(&mut map2);
Ok(map)
} else {
map2.append(&mut map);
Ok(map2)
}
})?;
let outputs = block
.txdata
.iter()
.enumerate()
.flat_map(|(index, tx)| {
tx.output
.iter()
.enumerate()
.map(|(block_inputindex, (block_txindex, vin, txin, tx))| -> Result<(InputIndex, InputSource)> {
let txindex = idxs.txindex + block_txindex;
let inputindex = idxs.inputindex + InputIndex::from(block_inputindex);
.map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx))
}).collect::<Vec<_>>();
let outpoint = txin.previous_output;
let txid = Txid::from(outpoint.txid);
let outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt = outputs.into_par_iter()
.enumerate()
.map(
#[allow(clippy::type_complexity)]
|(block_outputindex, (block_txindex, vout, txout, tx))| -> Result<(
OutputIndex,
(
&TxOut,
TxIndex,
Vout,
OutputType,
Result<AddressBytes>,
Option<TypeIndex>,
&Transaction,
),
)> {
let txindex = idxs.txindex + block_txindex;
let outputindex = idxs.outputindex + OutputIndex::from(block_outputindex);
if tx.is_coinbase() {
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
}
let script = &txout.script_pubkey;
let prev_txindex = if let Some(txindex) = stores
.txidprefix_to_txindex
.get(&TxidPrefix::from(&txid))?
.map(|v| *v)
.and_then(|txindex| {
// Checking if not finding txindex from the future
(txindex < idxs.txindex).then_some(txindex)
}) {
txindex
} else {
// dbg!(indexes.txindex + block_txindex, txindex, txin, vin);
return Ok((inputindex, InputSource::SameBlock((tx, txindex, txin, vin))));
};
let outputtype = OutputType::from(script);
let vout = Vout::from(outpoint.vout);
let outputindex = vecs.txindex_to_first_outputindex.get_or_read(prev_txindex, txindex_to_first_outputindex_reader)?
.ok_or(Error::Str("Expect outputindex to not be none"))
.inspect_err(|_| {
dbg!(outpoint.txid, prev_txindex, vout);
})?.into_owned()
+ vout;
Ok((inputindex, InputSource::PreviousBlock((
vin,
txindex,
outputindex,
))))
})
.try_fold(BTreeMap::new, |mut map, tuple| -> Result<_> {
let (key, value) = tuple?;
map.insert(key, value);
Ok(map)
})
.try_reduce(BTreeMap::new, |mut map, mut map2| {
if map.len() > map2.len() {
map.append(&mut map2);
Ok(map)
} else {
map2.append(&mut map);
Ok(map2)
}
})
});
let outputs = block
.txdata
.iter()
.enumerate()
.flat_map(|(index, tx)| {
tx.output
.iter()
.enumerate()
.map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx))
}).collect::<Vec<_>>();
let outputindex_to_txout_outputtype_addressbytes_res_addressindex = outputs.into_par_iter()
.enumerate()
.map(
#[allow(clippy::type_complexity)]
|(block_outputindex, (block_txindex, vout, txout, tx))| -> Result<(
OutputIndex,
(
&TxOut,
TxIndex,
Vout,
OutputType,
Result<AddressBytes>,
Option<TypeIndex>,
&Transaction,
),
)> {
let txindex = idxs.txindex + block_txindex;
let outputindex = idxs.outputindex + OutputIndex::from(block_outputindex);
let script = &txout.script_pubkey;
let outputtype = OutputType::from(script);
let address_bytes_res =
AddressBytes::try_from((script, outputtype)).inspect_err(|_| {
// dbg!(&txout, height, txi, &tx.compute_txid());
});
let typeindex_opt = address_bytes_res.as_ref().ok().and_then(|addressbytes| {
stores
.addressbyteshash_to_typeindex
.get(&AddressBytesHash::from((addressbytes, outputtype)))
.unwrap()
.map(|v| *v)
// Checking if not in the future
.and_then(|typeindex_local| {
(typeindex_local < idxs.typeindex(outputtype)).then_some(typeindex_local)
})
let address_bytes_res =
AddressBytes::try_from((script, outputtype)).inspect_err(|_| {
// dbg!(&txout, height, txi, &tx.compute_txid());
});
if let Some(Some(typeindex)) = check_collisions.then_some(typeindex_opt) {
let addressbytes = address_bytes_res.as_ref().unwrap();
let typeindex_opt = address_bytes_res.as_ref().ok().and_then(|addressbytes| {
stores
.addressbyteshash_to_typeindex
.get(&AddressBytesHash::from((addressbytes, outputtype)))
.unwrap()
.map(|v| *v)
// Checking if not in the future
.and_then(|typeindex_local| {
(typeindex_local < idxs.to_typeindex(outputtype)).then_some(typeindex_local)
})
});
let prev_addressbytes_opt = match outputtype {
OutputType::P2PK65 => vecs
.p2pk65addressindex_to_p2pk65bytes
.get_or_read(typeindex.into(), p2pk65addressindex_to_p2pk65bytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2PK33 => vecs
.p2pk33addressindex_to_p2pk33bytes
.get_or_read(typeindex.into(), p2pk33addressindex_to_p2pk33bytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2PKH => vecs
.p2pkhaddressindex_to_p2pkhbytes
.get_or_read(typeindex.into(), p2pkhaddressindex_to_p2pkhbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2SH => vecs
.p2shaddressindex_to_p2shbytes
.get_or_read(typeindex.into(), p2shaddressindex_to_p2shbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2WPKH => vecs
.p2wpkhaddressindex_to_p2wpkhbytes
.get_or_read(typeindex.into(), p2wpkhaddressindex_to_p2wpkhbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2WSH => vecs
.p2wshaddressindex_to_p2wshbytes
.get_or_read(typeindex.into(), p2wshaddressindex_to_p2wshbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2TR => vecs
.p2traddressindex_to_p2trbytes
.get_or_read(typeindex.into(), p2traddressindex_to_p2trbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2A => vecs
.p2aaddressindex_to_p2abytes
.get_or_read(typeindex.into(), p2aaddressindex_to_p2abytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
_ => {
unreachable!()
}
};
let prev_addressbytes =
prev_addressbytes_opt.as_ref().ok_or(Error::Str("Expect to have addressbytes"))?;
if let Some(Some(typeindex)) = check_collisions.then_some(typeindex_opt) {
let addressbytes = address_bytes_res.as_ref().unwrap();
if stores.addressbyteshash_to_typeindex.needs(height)
&& prev_addressbytes != addressbytes
{
let txid = tx.compute_txid();
dbg!(
height,
txid,
vout,
block_txindex,
outputtype,
prev_addressbytes,
addressbytes,
&idxs,
typeindex,
typeindex,
txout,
AddressBytesHash::from((addressbytes, outputtype)),
);
panic!()
let prev_addressbytes_opt = match outputtype {
OutputType::P2PK65 => vecs
.p2pk65addressindex_to_p2pk65bytes
.get_or_read(typeindex.into(), p2pk65addressindex_to_p2pk65bytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2PK33 => vecs
.p2pk33addressindex_to_p2pk33bytes
.get_or_read(typeindex.into(), p2pk33addressindex_to_p2pk33bytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2PKH => vecs
.p2pkhaddressindex_to_p2pkhbytes
.get_or_read(typeindex.into(), p2pkhaddressindex_to_p2pkhbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2SH => vecs
.p2shaddressindex_to_p2shbytes
.get_or_read(typeindex.into(), p2shaddressindex_to_p2shbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2WPKH => vecs
.p2wpkhaddressindex_to_p2wpkhbytes
.get_or_read(typeindex.into(), p2wpkhaddressindex_to_p2wpkhbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2WSH => vecs
.p2wshaddressindex_to_p2wshbytes
.get_or_read(typeindex.into(), p2wshaddressindex_to_p2wshbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2TR => vecs
.p2traddressindex_to_p2trbytes
.get_or_read(typeindex.into(), p2traddressindex_to_p2trbytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
OutputType::P2A => vecs
.p2aaddressindex_to_p2abytes
.get_or_read(typeindex.into(), p2aaddressindex_to_p2abytes_reader)?
.map(|v| AddressBytes::from(v.into_owned())),
_ => {
unreachable!()
}
}
};
let prev_addressbytes =
prev_addressbytes_opt.as_ref().ok_or(Error::Str("Expect to have addressbytes"))?;
Ok((
outputindex,
(
txout,
txindex,
if stores.addressbyteshash_to_typeindex.needs(height)
&& prev_addressbytes != addressbytes
{
let txid = tx.compute_txid();
dbg!(
height,
txid,
vout,
block_txindex,
outputtype,
address_bytes_res,
typeindex_opt,
tx,
),
))
},
)
.try_fold(BTreeMap::new, |mut map, tuple| -> Result<_> {
let (key, value) = tuple?;
map.insert(key, value);
Ok(map)
})
.try_reduce(BTreeMap::new, |mut map, mut map2| {
if map.len() > map2.len() {
map.append(&mut map2);
Ok(map)
} else {
map2.append(&mut map);
Ok(map2)
prev_addressbytes,
addressbytes,
&idxs,
typeindex,
typeindex,
txout,
AddressBytesHash::from((addressbytes, outputtype)),
);
panic!()
}
}
});
(
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_handle.join(),
input_source_vec_handle.join(),
outputindex_to_txout_outputtype_addressbytes_res_addressindex,
Ok((
outputindex,
(
txout,
txindex,
vout,
outputtype,
address_bytes_res,
typeindex_opt,
tx,
),
))
},
)
});
let txid_prefix_to_txid_and_block_txindex_and_prev_txindex =
txid_prefix_to_txid_and_block_txindex_and_prev_txindex_join_handle
.map_err(|_|
Error::Str("Expect txid_prefix_to_txid_and_block_txindex_and_prev_txindex_join_handle to join")
)??;
let input_source_vec = input_source_vec_handle
.map_err(|_|
Error::Str("Export input_source_vec_handle to join")
)??;
let outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt =
outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle
.map_err(|_|
Error::Str("Expect outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt_handle to join")
)?;
.try_fold(BTreeMap::new, |mut map, tuple| -> Result<_> {
let (key, value) = tuple?;
map.insert(key, value);
Ok(map)
})
.try_reduce(BTreeMap::new, |mut map, mut map2| {
if map.len() > map2.len() {
map.append(&mut map2);
Ok(map)
} else {
map2.append(&mut map);
Ok(map2)
}
})?;
let outputs_len = outputindex_to_txout_outputtype_addressbytes_res_addressindex_opt.len();
let inputs_len = input_source_vec.len();
@@ -747,7 +712,6 @@ impl Indexer {
idxs.inputindex += InputIndex::from(inputs_len);
idxs.outputindex += OutputIndex::from(outputs_len);
if should_export(height, false) {
txindex_to_first_outputindex_reader_opt.take();
p2pk65addressindex_to_p2pk65bytes_reader_opt.take();

View File

@@ -18,3 +18,6 @@ brk_rmcp = { version = "0.7.1", features = [
] }
log = { workspace = true }
serde_json = { workspace = true }
[package.metadata.cargo-machete]
ignored = ["serde_json"]

View File

@@ -20,17 +20,18 @@ fn main() -> Result<()> {
let parser = Parser::new(bitcoin_dir.join("blocks"), rpc);
let start = Some(915_138_u32.into());
let start = None;
// let start = Some(916037_u32.into());
let end = None;
let mut blk_index = 0;
let mut diff = BTreeMap::new();
// let mut blk_index = 0;
// let mut diff = BTreeMap::new();
parser.parse(start, end).iter().for_each(|block| {
println!("{}: {}", block.height(), block.hash());
let new_blk_index = block.metadata().blk_index();
if new_blk_index < blk_index {
diff.insert(blk_index - new_blk_index, block.height());
}
blk_index = new_blk_index;
// let new_blk_index = block.metadata().blk_index();
// if new_blk_index < blk_index {
// diff.insert(blk_index - new_blk_index, block.height());
// }
// blk_index = new_blk_index;
});
// let v = diff.iter().rev().take(10).collect::<Vec<_>>();

View File

@@ -16,7 +16,7 @@ use bitcoincore_rpc::RpcApi;
use blk_index_to_blk_path::*;
use brk_error::Result;
use brk_structs::{BlkMetadata, BlkPosition, Block, Height, ParsedBlock};
use crossbeam::channel::{bounded, Receiver};
use crossbeam::channel::{Receiver, bounded};
use parking_lot::{RwLock, RwLockReadGuard};
use rayon::prelude::*;
@@ -157,30 +157,36 @@ impl Parser {
let mut bulk = vec![];
let drain_and_send = |bulk: &mut Vec<(BlkMetadata, AnyBlock, XORIndex)>| {
// Using a vec and sending after to not end up with stuck threads in par iter
mem::take(bulk)
.into_par_iter()
.try_for_each(|(metdata, any_block, xor_i)| {
if let Ok(AnyBlock::Decoded(block)) =
any_block.decode(metdata, rpc, xor_i, xor_bytes, start, end)
&& send_block.send(block).is_err()
{
return ControlFlow::Break(());
}
// Private pool to prevent collision with the global pool
// Without it there can be hanging
let parser_pool = rayon::ThreadPoolBuilder::new()
.num_threads(thread::available_parallelism().unwrap().get() / 2)
.build()
.expect("Failed to create parser thread pool");
ControlFlow::Continue(())
})
let drain_and_send = |bulk: &mut Vec<(BlkMetadata, AnyBlock, XORIndex)>| {
parser_pool.install(|| {
mem::take(bulk)
.into_par_iter()
.try_for_each(|(metdata, any_block, xor_i)| {
if let Ok(AnyBlock::Decoded(block)) =
any_block.decode(metdata, rpc, xor_i, xor_bytes, start, end)
&& send_block.send(block).is_err()
{
return ControlFlow::Break(());
}
ControlFlow::Continue(())
})
})
};
recv_bytes.iter().try_for_each(|tuple| {
bulk.push(tuple);
if bulk.len() < BOUND_CAP / 2 {
if bulk.len() < BOUND_CAP {
return ControlFlow::Continue(());
}
// Sending in bulk to not lock threads in standby
drain_and_send(&mut bulk)
})?;

View File

@@ -151,3 +151,4 @@
- __GLOBAL__
- check `TODO`s in codebase
- rename `output` to `txout` or `vout`, `input` to `txin` or `vin`
- https://マリウス.com/thoughts-on-cloudflare/

View File

@@ -1,6 +1,5 @@
import { serdeIndex } from "./serde";
import { runWhenIdle } from "./idle";
import { createPools } from "./pools";
import { POOL_ID_TO_POOL_NAME } from "./generated/pools";
import { createMetricToIndexes } from "./metrics";
const localhost = window.location.hostname === "localhost";
@@ -11,7 +10,7 @@ const localhost = window.location.hostname === "localhost";
export default function (signals) {
const owner = signals.getOwner();
const pools = createPools();
const pools = POOL_ID_TO_POOL_NAME;
const metricToIndexes = createMetricToIndexes();
const defaultFrom = -10_000;

View File

@@ -0,0 +1,89 @@
import { INDEX_TO_WORD } from "./generated/metrics";
/** @type {Record<string, number>} */
const WORD_TO_INDEX = {};
INDEX_TO_WORD.forEach((word, index) => {
WORD_TO_INDEX[word] = index;
});
/**
* @param {string} metric
*/
function compressMetric(metric) {
return metric
.split("_")
.map((word) => {
const index = WORD_TO_INDEX[word];
return index !== undefined ? indexToLetters(index) : word;
})
.join("_");
}
/**
* @param {string} compressedMetric
*/
function decompressMetric(compressedMetric) {
return compressedMetric
.split("_")
.map((code) => {
const index = lettersToIndex(code);
return INDEX_TO_WORD[index] || code; // Fallback to original if not found
})
.join("_");
}
/**
* @param {string} letters
*/
function lettersToIndex(letters) {
let result = 0;
for (let i = 0; i < letters.length; i++) {
const value = charToIndex(letters.charCodeAt(i));
result = result * 52 + value + 1;
}
return result - 1;
}
/**
* @param {number} byte
*/
function charToIndex(byte) {
if (byte >= 65 && byte <= 90) {
// 'A' to 'Z'
return byte - 65;
} else if (byte >= 97 && byte <= 122) {
// 'a' to 'z'
return byte - 97 + 26;
} else {
return 255; // Invalid
}
}
/**
* @param {number} index
*/
function indexToLetters(index) {
if (index < 52) {
return indexToChar(index);
}
let result = [];
while (true) {
result.push(indexToChar(index % 52));
index = Math.floor(index / 52);
if (index === 0) break;
index -= 1;
}
return result.reverse().join("");
}
/**
* @param {number} index
*/
function indexToChar(index) {
if (index <= 25) {
return String.fromCharCode(65 + index); // A-Z
} else {
return String.fromCharCode(97 + index - 26); // a-z
}
}

View File

View File

@@ -1,7 +1,10 @@
/**
* @import { Signal, Signals, Accessor } from "../solidjs-signals/index";
*
* @import { Index } from "./metrics"
* @import { Index } from "./generated/metrics"
*
* @typedef {[number, number, number, number]} OHLCTuple
*
* @typedef {typeof import("./generated/metrics")["COMPRESSED_METRIC_TO_INDEXES"]} MetricToIndexes
* @typedef {string} Metric
*/