mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
208
Cargo.lock
generated
208
Cargo.lock
generated
@@ -73,7 +73,7 @@ checksum = "fe233a377643e0fc1a56421d7c90acdec45c291b30345eb9f08e8d0ddce5a4ab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -212,7 +212,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -506,14 +506,14 @@ dependencies = [
|
||||
"brk_fetcher",
|
||||
"brk_grouper",
|
||||
"brk_indexer",
|
||||
"brk_interface",
|
||||
"brk_logger",
|
||||
"brk_mcp",
|
||||
"brk_query",
|
||||
"brk_reader",
|
||||
"brk_server",
|
||||
"brk_store",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -587,8 +587,8 @@ checksum = "91ff3e445e42475fba5e0cfaed51345f491e479b9f2069f29875f434a5327913"
|
||||
name = "brk_binder"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_interface",
|
||||
"brk_structs",
|
||||
"brk_query",
|
||||
"brk_types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -612,8 +612,8 @@ dependencies = [
|
||||
"brk_error",
|
||||
"brk_fetcher",
|
||||
"brk_indexer",
|
||||
"brk_interface",
|
||||
"brk_logger",
|
||||
"brk_query",
|
||||
"brk_reader",
|
||||
"brk_server",
|
||||
"clap",
|
||||
@@ -640,8 +640,8 @@ dependencies = [
|
||||
"brk_logger",
|
||||
"brk_reader",
|
||||
"brk_store",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
"derive_deref",
|
||||
"log",
|
||||
"pco",
|
||||
@@ -671,7 +671,7 @@ version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_error",
|
||||
"brk_logger",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
"log",
|
||||
"minreq",
|
||||
"sonic-rs",
|
||||
@@ -699,8 +699,8 @@ name = "brk_grouper"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_error",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
"rayon",
|
||||
"vecdb",
|
||||
]
|
||||
@@ -713,36 +713,19 @@ dependencies = [
|
||||
"brk_error",
|
||||
"brk_fjall",
|
||||
"brk_grouper",
|
||||
"brk_iterator",
|
||||
"brk_logger",
|
||||
"brk_reader",
|
||||
"brk_rpc",
|
||||
"brk_store",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
"log",
|
||||
"rayon",
|
||||
"rustc-hash",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_interface"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"bitcoin",
|
||||
"brk_computer",
|
||||
"brk_error",
|
||||
"brk_indexer",
|
||||
"brk_reader",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"derive_deref",
|
||||
"quickmatch",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_iterator"
|
||||
version = "0.0.111"
|
||||
@@ -751,7 +734,7 @@ dependencies = [
|
||||
"brk_error",
|
||||
"brk_reader",
|
||||
"brk_rpc",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -769,7 +752,7 @@ name = "brk_mcp"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk-aide",
|
||||
"brk_interface",
|
||||
"brk_query",
|
||||
"brk_rmcp",
|
||||
"log",
|
||||
"schemars",
|
||||
@@ -784,13 +767,32 @@ dependencies = [
|
||||
"bitcoin",
|
||||
"brk_error",
|
||||
"brk_rpc",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
"derive_deref",
|
||||
"log",
|
||||
"parking_lot 0.12.5",
|
||||
"rustc-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_query"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"bitcoin",
|
||||
"brk_computer",
|
||||
"brk_error",
|
||||
"brk_indexer",
|
||||
"brk_reader",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
"derive_deref",
|
||||
"quickmatch",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_reader"
|
||||
version = "0.0.111"
|
||||
@@ -798,7 +800,7 @@ dependencies = [
|
||||
"bitcoin",
|
||||
"brk_error",
|
||||
"brk_rpc",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
"crossbeam",
|
||||
"derive_deref",
|
||||
"log",
|
||||
@@ -846,7 +848,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_json",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1206,7 +1208,7 @@ dependencies = [
|
||||
"bitcoincore-rpc",
|
||||
"brk_error",
|
||||
"brk_logger",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
"log",
|
||||
"parking_lot 0.12.5",
|
||||
]
|
||||
@@ -1222,12 +1224,12 @@ dependencies = [
|
||||
"brk_error",
|
||||
"brk_fetcher",
|
||||
"brk_indexer",
|
||||
"brk_interface",
|
||||
"brk_logger",
|
||||
"brk_mcp",
|
||||
"brk_query",
|
||||
"brk_reader",
|
||||
"brk_structs",
|
||||
"brk_traversable",
|
||||
"brk_types",
|
||||
"jiff",
|
||||
"log",
|
||||
"quick_cache",
|
||||
@@ -1246,7 +1248,7 @@ version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_error",
|
||||
"brk_fjall",
|
||||
"brk_structs",
|
||||
"brk_types",
|
||||
"byteview 0.6.1",
|
||||
"byteview 0.8.0",
|
||||
"log",
|
||||
@@ -1268,7 +1270,25 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_structs"
|
||||
name = "brk_traversable"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_traversable_derive",
|
||||
"brk_types",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_traversable_derive"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_types"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"allocative",
|
||||
@@ -1290,24 +1310,6 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_traversable"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"brk_structs",
|
||||
"brk_traversable_derive",
|
||||
"vecdb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brk_traversable_derive"
|
||||
version = "0.0.111"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli"
|
||||
version = "8.0.2"
|
||||
@@ -1451,7 +1453,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1721,7 +1723,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1732,7 +1734,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1766,7 +1768,7 @@ checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1797,7 +1799,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
@@ -1846,7 +1848,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1900,7 +1902,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2111,7 +2113,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2534,9 +2536,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
@@ -2576,7 +2578,7 @@ checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2832,7 +2834,7 @@ checksum = "4568f25ccbd45ab5d5603dc34318c1ec56b117531781260002151b8530a9f931"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2957,7 +2959,7 @@ dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3062,7 +3064,7 @@ checksum = "05bbaa5b6b98826bb62b164406f703bee72c5287af9986f9c863fa8ea992b476"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3106,7 +3108,7 @@ dependencies = [
|
||||
"phf",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3636,7 +3638,7 @@ dependencies = [
|
||||
"phf_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3665,7 +3667,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3755,9 +3757,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
version = "1.0.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
checksum = "8e0f6df8eaa422d97d72edcd152e1451618fed47fabbdbd5a8864167b1d4aff7"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -3779,7 +3781,7 @@ checksum = "7347867d0a7e1208d93b46767be83e2b8f978c3dad35f775ac8d8847551d6fe1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3980,7 +3982,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4068,7 +4070,7 @@ checksum = "bd83f5f173ff41e00337d97f6572e416d022ef8a19f371817259ae960324c482"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4183,7 +4185,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_derive_internals",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4235,9 +4237,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "self_cell"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
|
||||
checksum = "16c2f82143577edb4921b71ede051dac62ca3c16084e918bf7b40c96ae10eb33"
|
||||
|
||||
[[package]]
|
||||
name = "seq-macro"
|
||||
@@ -4295,7 +4297,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4306,7 +4308,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4540,7 +4542,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4565,9 +4567,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.107"
|
||||
version = "2.0.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
|
||||
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -4588,7 +4590,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4650,7 +4652,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4661,7 +4663,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4740,7 +4742,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4886,7 +4888,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4976,7 +4978,7 @@ checksum = "ee6ff59666c9cbaec3533964505d39154dc4e0a56151fdea30a09ed0301f62e2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
@@ -5136,7 +5138,7 @@ name = "vecdb_derive"
|
||||
version = "0.2.17"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5214,7 +5216,7 @@ dependencies = [
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@@ -5236,7 +5238,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
@@ -5340,7 +5342,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5351,7 +5353,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5615,7 +5617,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@@ -5636,7 +5638,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5656,7 +5658,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@@ -5690,7 +5692,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.107",
|
||||
"syn 2.0.108",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -40,7 +40,7 @@ brk_error = { version = "0.0.111", path = "crates/brk_error" }
|
||||
brk_fetcher = { version = "0.0.111", path = "crates/brk_fetcher" }
|
||||
brk_grouper = { version = "0.0.111", path = "crates/brk_grouper" }
|
||||
brk_indexer = { version = "0.0.111", path = "crates/brk_indexer" }
|
||||
brk_interface = { version = "0.0.111", path = "crates/brk_interface" }
|
||||
brk_query = { version = "0.0.111", path = "crates/brk_query" }
|
||||
brk_iterator = { version = "0.0.111", path = "crates/brk_iterator" }
|
||||
brk_logger = { version = "0.0.111", path = "crates/brk_logger" }
|
||||
brk_mcp = { version = "0.0.111", path = "crates/brk_mcp" }
|
||||
@@ -49,7 +49,7 @@ brk_reader = { version = "0.0.111", path = "crates/brk_reader" }
|
||||
brk_rpc = { version = "0.0.111", path = "crates/brk_rpc" }
|
||||
brk_server = { version = "0.0.111", path = "crates/brk_server" }
|
||||
brk_store = { version = "0.0.111", path = "crates/brk_store" }
|
||||
brk_structs = { version = "0.0.111", path = "crates/brk_structs" }
|
||||
brk_types = { version = "0.0.111", path = "crates/brk_types" }
|
||||
brk_traversable = { version = "0.0.111", path = "crates/brk_traversable", features = ["derive"] }
|
||||
brk_traversable_derive = { version = "0.0.111", path = "crates/brk_traversable_derive" }
|
||||
byteview = "=0.6.1"
|
||||
|
||||
@@ -26,7 +26,7 @@ full = [
|
||||
"parser",
|
||||
"server",
|
||||
"store",
|
||||
"structs",
|
||||
"types",
|
||||
"traversable",
|
||||
]
|
||||
binder = ["brk_binder"]
|
||||
@@ -37,13 +37,13 @@ error = ["brk_error"]
|
||||
fetcher = ["brk_fetcher"]
|
||||
grouper = ["brk_grouper"]
|
||||
indexer = ["brk_indexer"]
|
||||
interface = ["brk_interface"]
|
||||
interface = ["brk_query"]
|
||||
logger = ["brk_logger"]
|
||||
mcp = ["brk_mcp"]
|
||||
parser = ["brk_reader"]
|
||||
server = ["brk_server"]
|
||||
store = ["brk_store"]
|
||||
structs = ["brk_structs"]
|
||||
types = ["brk_types"]
|
||||
traversable = ["brk_traversable"]
|
||||
|
||||
[dependencies]
|
||||
@@ -55,13 +55,13 @@ brk_error = { workspace = true, optional = true }
|
||||
brk_fetcher = { workspace = true, optional = true }
|
||||
brk_grouper = { workspace = true, optional = true }
|
||||
brk_indexer = { workspace = true, optional = true }
|
||||
brk_interface = { workspace = true, optional = true }
|
||||
brk_query = { workspace = true, optional = true }
|
||||
brk_logger = { workspace = true, optional = true }
|
||||
brk_mcp = { workspace = true, optional = true }
|
||||
brk_reader = { workspace = true, optional = true }
|
||||
brk_server = { workspace = true, optional = true }
|
||||
brk_store = { workspace = true, optional = true }
|
||||
brk_structs = { workspace = true, optional = true }
|
||||
brk_types = { workspace = true, optional = true }
|
||||
brk_traversable = { workspace = true, optional = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
||||
@@ -245,13 +245,13 @@ This pattern ensures:
|
||||
| `error` | `brk_error` | Error handling |
|
||||
| `fetcher` | `brk_fetcher` | Price data fetching |
|
||||
| `indexer` | `brk_indexer` | Blockchain indexing |
|
||||
| `interface` | `brk_interface` | Data query interface |
|
||||
| `interface` | `brk_query` | Data query interface |
|
||||
| `logger` | `brk_logger` | Enhanced logging |
|
||||
| `mcp` | `brk_mcp` | Model Context Protocol |
|
||||
| `parser` | `brk_reader` | Block parsing |
|
||||
| `server` | `brk_server` | HTTP server |
|
||||
| `store` | `brk_store` | Key-value storage |
|
||||
| `structs` | `brk_structs` | Data structures |
|
||||
| `structs` | `brk_types` | Data structures |
|
||||
| `full` | All components | Complete functionality |
|
||||
|
||||
### Documentation
|
||||
|
||||
@@ -34,7 +34,7 @@ pub use brk_indexer as indexer;
|
||||
|
||||
#[cfg(feature = "interface")]
|
||||
#[doc(inline)]
|
||||
pub use brk_interface as interface;
|
||||
pub use brk_query as interface;
|
||||
|
||||
#[cfg(feature = "logger")]
|
||||
#[doc(inline)]
|
||||
@@ -56,9 +56,9 @@ pub use brk_server as server;
|
||||
#[doc(inline)]
|
||||
pub use brk_store as store;
|
||||
|
||||
#[cfg(feature = "structs")]
|
||||
#[cfg(feature = "types")]
|
||||
#[doc(inline)]
|
||||
pub use brk_structs as structs;
|
||||
pub use brk_types as types;
|
||||
|
||||
#[cfg(feature = "traversable")]
|
||||
#[doc(inline)]
|
||||
|
||||
@@ -10,5 +10,5 @@ rust-version.workspace = true
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
brk_interface = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_query = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use brk_interface::Interface;
|
||||
use brk_structs::{Index, pools};
|
||||
use brk_query::Query;
|
||||
use brk_types::{Index, pools};
|
||||
|
||||
use super::VERSION;
|
||||
|
||||
@@ -18,7 +18,7 @@ pub trait Bridge {
|
||||
fn generate_js_files(&self, modules_path: &Path) -> io::Result<()>;
|
||||
}
|
||||
|
||||
impl Bridge for Interface<'static> {
|
||||
impl Bridge for Query<'static> {
|
||||
fn generate_js_files(&self, modules_path: &Path) -> io::Result<()> {
|
||||
let path = modules_path.join("brk-client");
|
||||
|
||||
@@ -81,7 +81,7 @@ export const POOL_ID_TO_POOL_NAME = /** @type {const} */ ({
|
||||
fs::write(path, contents)
|
||||
}
|
||||
|
||||
fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::Result<()> {
|
||||
fn generate_metrics_file(query: &Query<'static>, parent: &Path) -> io::Result<()> {
|
||||
let path = parent.join(Path::new("metrics.js"));
|
||||
|
||||
let indexes = Index::all();
|
||||
@@ -125,14 +125,11 @@ export const INDEXES = /** @type {{const}} */ ([
|
||||
let mut unique_index_groups = BTreeMap::new();
|
||||
|
||||
let mut word_to_freq: BTreeMap<_, usize> = BTreeMap::new();
|
||||
interface
|
||||
.metric_to_index_to_vec()
|
||||
.keys()
|
||||
.for_each(|metric| {
|
||||
metric.split("_").for_each(|word| {
|
||||
*word_to_freq.entry(word).or_default() += 1;
|
||||
});
|
||||
query.metric_to_index_to_vec().keys().for_each(|metric| {
|
||||
metric.split("_").for_each(|word| {
|
||||
*word_to_freq.entry(word).or_default() += 1;
|
||||
});
|
||||
});
|
||||
let mut word_to_freq = word_to_freq.into_iter().collect::<Vec<_>>();
|
||||
word_to_freq.sort_unstable_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(b.0)));
|
||||
let words = word_to_freq
|
||||
@@ -167,7 +164,7 @@ export const COMPRESSED_METRIC_TO_INDEXES = {
|
||||
"
|
||||
.to_string();
|
||||
|
||||
interface
|
||||
query
|
||||
.metric_to_index_to_vec()
|
||||
.iter()
|
||||
.for_each(|(metric, index_to_vec)| {
|
||||
|
||||
@@ -16,7 +16,7 @@ brk_computer = { workspace = true }
|
||||
brk_error = { workspace = true }
|
||||
brk_fetcher = { workspace = true }
|
||||
brk_indexer = { workspace = true }
|
||||
brk_interface = { workspace = true }
|
||||
brk_query = { workspace = true }
|
||||
brk_logger = { workspace = true }
|
||||
brk_reader = { workspace = true }
|
||||
brk_server = { workspace = true }
|
||||
|
||||
@@ -14,7 +14,7 @@ use brk_bundler::bundle;
|
||||
use brk_computer::Computer;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_interface::Interface;
|
||||
use brk_query::Query;
|
||||
use brk_reader::Reader;
|
||||
use brk_server::{Server, VERSION};
|
||||
use log::info;
|
||||
@@ -54,7 +54,7 @@ pub fn run() -> color_eyre::Result<()> {
|
||||
|
||||
let mut computer = Computer::forced_import(&config.brkdir(), &indexer, config.fetcher())?;
|
||||
|
||||
let interface = Interface::build(&reader, &indexer, &computer);
|
||||
let query = Query::build(&reader, &indexer, &computer);
|
||||
|
||||
let website = config.website();
|
||||
|
||||
@@ -97,7 +97,7 @@ pub fn run() -> color_eyre::Result<()> {
|
||||
modules_path = downloaded_modules_path;
|
||||
}
|
||||
|
||||
interface.generate_js_files(&modules_path)?;
|
||||
query.generate_js_files(&modules_path)?;
|
||||
|
||||
Some(
|
||||
bundle(
|
||||
@@ -112,7 +112,7 @@ pub fn run() -> color_eyre::Result<()> {
|
||||
None
|
||||
};
|
||||
|
||||
let server = Server::new(interface, bundle_path);
|
||||
let server = Server::new(query, bundle_path);
|
||||
|
||||
tokio::spawn(async move {
|
||||
server.serve(true).await.unwrap();
|
||||
|
||||
@@ -19,7 +19,7 @@ brk_indexer = { workspace = true }
|
||||
brk_logger = { workspace = true }
|
||||
brk_reader = { workspace = true }
|
||||
brk_store = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
brk_traversable = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
log = { workspace = true }
|
||||
|
||||
@@ -131,7 +131,7 @@ println!("Stateful analysis completed: {}", computer.stateful.len());
|
||||
|
||||
```rust
|
||||
use brk_computer::Computer;
|
||||
use brk_structs::{DateIndex, Height};
|
||||
use brk_types::{DateIndex, Height};
|
||||
|
||||
let computer = Computer::forced_import(/* ... */)?;
|
||||
|
||||
@@ -160,7 +160,7 @@ if let Some(difficulty) = computer.chain.height_to_difficulty.get(height)? {
|
||||
|
||||
```rust
|
||||
use brk_computer::Computer;
|
||||
use brk_structs::{DateIndex, CohortId};
|
||||
use brk_types::{DateIndex, CohortId};
|
||||
|
||||
let computer = Computer::forced_import(/* ... */)?;
|
||||
|
||||
@@ -190,7 +190,7 @@ if let Some(utxo_cohorts) = &computer.stateful.utxo_cohorts {
|
||||
|
||||
```rust
|
||||
use brk_computer::Computer;
|
||||
use brk_structs::{Height, DateIndex};
|
||||
use brk_types::{Height, DateIndex};
|
||||
|
||||
let computer = Computer::forced_import(/* ... */)?;
|
||||
|
||||
@@ -267,7 +267,7 @@ Each computation module operates independently:
|
||||
**Required Dependencies:**
|
||||
|
||||
- `brk_indexer`: Raw blockchain data access
|
||||
- `brk_structs`: Type definitions and conversions
|
||||
- `brk_types`: Type definitions and conversions
|
||||
|
||||
**Optional Dependencies:**
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use brk_computer::Computer;
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{Address, AddressBytes, TxOutIndex, OutputType, pools};
|
||||
use brk_types::{Address, AddressBytes, OutputType, TxOutIndex, pools};
|
||||
use vecdb::{AnyIterableVec, Exit, VecIterator};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::path::Path;
|
||||
|
||||
use brk_computer::PriceToAmount;
|
||||
use brk_error::Result;
|
||||
use brk_structs::Height;
|
||||
use brk_types::Height;
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
let path = Path::new(&std::env::var("HOME").unwrap())
|
||||
|
||||
@@ -3,14 +3,13 @@ use std::path::Path;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_reader::Reader;
|
||||
use brk_structs::{BlkPosition, Height, TxIndex, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BlkPosition, Height, TxIndex, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, CompressedVec, Database, Exit, GenericStoredVec,
|
||||
PAGE_SIZE, VecIterator,
|
||||
AnyStoredVec, AnyVec, CompressedVec, Database, Exit, GenericStoredVec, PAGE_SIZE, VecIterator,
|
||||
};
|
||||
|
||||
use super::{Indexes, indexes};
|
||||
use super::Indexes;
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
@@ -54,12 +53,11 @@ impl Vecs {
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
reader: &Reader,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.compute_(indexer, indexes, starting_indexes, reader, exit)?;
|
||||
self.compute_(indexer, starting_indexes, reader, exit)?;
|
||||
self.db.flush_then_punch()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -67,7 +65,6 @@ impl Vecs {
|
||||
fn compute_(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
parser: &Reader,
|
||||
exit: &Exit,
|
||||
@@ -75,7 +72,8 @@ impl Vecs {
|
||||
let min_txindex =
|
||||
TxIndex::from(self.txindex_to_position.len()).min(starting_indexes.txindex);
|
||||
|
||||
let Some(min_height) = indexes
|
||||
let Some(min_height) = indexer
|
||||
.vecs
|
||||
.txindex_to_height
|
||||
.iter()
|
||||
.get_inner(min_txindex)
|
||||
|
||||
@@ -3,13 +3,13 @@ use std::path::Path;
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Bitcoin, CheckedSub, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, FeeRate, HalvingEpoch,
|
||||
Height, MonthIndex, ONE_DAY_IN_SEC_F64, QuarterIndex, Sats, SemesterIndex, StoredBool,
|
||||
StoredF32, StoredF64, StoredU32, StoredU64, Timestamp, TxInIndex, TxIndex, TxOutIndex,
|
||||
TxVersion, Version, WeekIndex, Weight, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, AnyIterableVec, Database, EagerVec, Exit, LazyVecFrom1, LazyVecFrom2,
|
||||
LazyVecFrom3, PAGE_SIZE, StoredIndex, VecIterator,
|
||||
@@ -627,6 +627,7 @@ impl Vecs {
|
||||
indexes_to_fee: ComputedValueVecsFromTxindex::forced_import(
|
||||
&db,
|
||||
"fee",
|
||||
indexer,
|
||||
indexes,
|
||||
Source::Vec(txindex_to_fee.boxed_clone()),
|
||||
version + Version::ZERO,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, CheckedSub, Dollars, StoredF32, StoredF64, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, CheckedSub, Dollars, StoredF32, StoredF64, Version};
|
||||
use vecdb::{Database, Exit, PAGE_SIZE, VecIterator};
|
||||
|
||||
use crate::grouped::ComputedVecsFromDateIndex;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{StoredF32, StoredI16, StoredU16, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{AnyVec, Database, Exit};
|
||||
use brk_types::{StoredF32, StoredI16, StoredU16, Version};
|
||||
use vecdb::{AnyVec, Database, Exit, PAGE_SIZE};
|
||||
|
||||
use crate::grouped::Source;
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
let db = Database::open(&parent_path.join("constants"))?;
|
||||
db.set_min_len(PAGE_SIZE * 10_000_000)?;
|
||||
db.set_min_len(PAGE_SIZE * 1_000_000)?;
|
||||
|
||||
let version = parent_version + Version::ZERO;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ use std::path::Path;
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{DateIndex, Height, OHLCCents, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, Height, OHLCCents, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, RawVec, StoredIndex,
|
||||
VecIterator,
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, PAGE_SIZE, RawVec,
|
||||
StoredIndex, VecIterator,
|
||||
};
|
||||
|
||||
use super::{Indexes, indexes};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{CheckedSub, StoredU64, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{CheckedSub, StoredU64, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec,
|
||||
StoredIndex, StoredRaw,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use allocative::Allocative;
|
||||
use brk_structs::Version;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Version;
|
||||
use vecdb::{
|
||||
AnyBoxedIterableVec, AnyCloneableIterableVec, FromCoarserIndex, LazyVecFrom2, StoredIndex,
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
DateIndex, DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{AnyCloneableIterableVec, AnyIterableVec, Database, EagerVec, Exit};
|
||||
|
||||
use crate::{Indexes, grouped::LazyVecsBuilder, indexes};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, SemesterIndex,
|
||||
Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{AnyCloneableIterableVec, AnyIterableVec, Database, EagerVec, Exit};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
|
||||
use brk_structs::{DifficultyEpoch, Height, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DifficultyEpoch, Height, Version};
|
||||
use vecdb::{Database, EagerVec, Exit};
|
||||
|
||||
use crate::{Indexes, indexes};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Bitcoin, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, MonthIndex, QuarterIndex,
|
||||
Sats, SemesterIndex, TxIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, AnyVec, CollectableVec, Database, EagerVec, Exit, GenericStoredVec,
|
||||
StoredIndex, VecIterator,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit,
|
||||
GenericStoredVec, StoredIndex, VecIterator,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{CheckedSub, Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{CheckedSub, Date, DateIndex, Dollars, StoredF32, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, BoxedVecIterator, CollectableVec, Database, EagerVec,
|
||||
Exit, GenericStoredVec, StoredIndex,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, DateIndex, Dollars, Sats, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, StoredVec};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version};
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, CollectableVec, Database, Exit, LazyVecFrom1, LazyVecFrom3,
|
||||
StoredIndex, StoredVec,
|
||||
@@ -31,6 +31,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
pub fn forced_import(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
source: Source<TxIndex, Sats>,
|
||||
version: Version,
|
||||
@@ -79,7 +80,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
&name_usd,
|
||||
version + VERSION,
|
||||
bitcoin_txindex.boxed_clone(),
|
||||
indexes.txindex_to_height.boxed_clone(),
|
||||
indexer.vecs.txindex_to_height.boxed_clone(),
|
||||
price.chainindexes_to_price_close.height.boxed_clone(),
|
||||
|txindex: TxIndex,
|
||||
txindex_to_btc_iter,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Dollars, Height, Sats, Version};
|
||||
use vecdb::{CollectableVec, Database, EagerVec, Exit, Format, StoredVec};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -2,15 +2,16 @@ use std::{ops::Deref, path::Path};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
Date, DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height,
|
||||
MonthIndex, OpReturnIndex, P2AAddressIndex, P2ABytes, P2MSOutputIndex, P2PK33AddressIndex,
|
||||
P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex,
|
||||
P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex, P2WPKHBytes, P2WSHAddressIndex,
|
||||
P2WSHBytes, QuarterIndex, Sats, SemesterIndex, StoredU64, Timestamp, TxInIndex, TxIndex,
|
||||
TxOutIndex, Txid, UnknownOutputIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Date, DateIndex, DecadeIndex, DifficultyEpoch, EmptyOutputIndex, HalvingEpoch, Height,
|
||||
MonthIndex, OpReturnIndex, OutPoint, P2AAddressIndex, P2ABytes, P2MSOutputIndex,
|
||||
P2PK33AddressIndex, P2PK33Bytes, P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex,
|
||||
P2PKHBytes, P2SHAddressIndex, P2SHBytes, P2TRAddressIndex, P2TRBytes, P2WPKHAddressIndex,
|
||||
P2WPKHBytes, P2WSHAddressIndex, P2WSHBytes, QuarterIndex, Sats, SemesterIndex, StoredU64,
|
||||
Timestamp, TxInIndex, TxIndex, TxOutIndex, Txid, UnknownOutputIndex, Version, WeekIndex,
|
||||
YearIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, Database, EagerVec, Exit, LazyVecFrom1, LazyVecFrom2, PAGE_SIZE,
|
||||
StoredIndex, VecIterator,
|
||||
@@ -46,7 +47,6 @@ pub struct Vecs {
|
||||
pub height_to_height: EagerVec<Height, Height>,
|
||||
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||
pub height_to_txindex_count: EagerVec<Height, StoredU64>,
|
||||
pub txinindex_to_txinindex: LazyVecFrom1<TxInIndex, TxInIndex, TxInIndex, TxOutIndex>,
|
||||
pub monthindex_to_dateindex_count: EagerVec<MonthIndex, StoredU64>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||
pub monthindex_to_monthindex: EagerVec<MonthIndex, MonthIndex>,
|
||||
@@ -55,7 +55,6 @@ pub struct Vecs {
|
||||
pub monthindex_to_yearindex: EagerVec<MonthIndex, YearIndex>,
|
||||
pub opreturnindex_to_opreturnindex:
|
||||
LazyVecFrom1<OpReturnIndex, OpReturnIndex, OpReturnIndex, TxIndex>,
|
||||
pub txoutindex_to_txoutindex: LazyVecFrom1<TxOutIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub p2aaddressindex_to_p2aaddressindex:
|
||||
LazyVecFrom1<P2AAddressIndex, P2AAddressIndex, P2AAddressIndex, P2ABytes>,
|
||||
pub p2msoutputindex_to_p2msoutputindex:
|
||||
@@ -85,6 +84,10 @@ pub struct Vecs {
|
||||
pub txindex_to_output_count:
|
||||
LazyVecFrom2<TxIndex, StoredU64, TxIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub txindex_to_txindex: LazyVecFrom1<TxIndex, TxIndex, TxIndex, Txid>,
|
||||
pub txinindex_to_txinindex: LazyVecFrom1<TxInIndex, TxInIndex, TxInIndex, OutPoint>,
|
||||
pub txinindex_to_txoutindex:
|
||||
LazyVecFrom2<TxInIndex, TxOutIndex, TxInIndex, OutPoint, TxIndex, TxOutIndex>,
|
||||
pub txoutindex_to_txoutindex: LazyVecFrom1<TxOutIndex, TxOutIndex, TxOutIndex, Sats>,
|
||||
pub unknownoutputindex_to_unknownoutputindex:
|
||||
LazyVecFrom1<UnknownOutputIndex, UnknownOutputIndex, UnknownOutputIndex, TxIndex>,
|
||||
pub weekindex_to_dateindex_count: EagerVec<WeekIndex, StoredU64>,
|
||||
@@ -97,36 +100,62 @@ pub struct Vecs {
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(parent: &Path, version: Version, indexer: &Indexer) -> Result<Self> {
|
||||
pub fn forced_import(
|
||||
parent: &Path,
|
||||
parent_version: Version,
|
||||
indexer: &Indexer,
|
||||
) -> Result<Self> {
|
||||
let db = Database::open(&parent.join("indexes"))?;
|
||||
db.set_min_len(PAGE_SIZE * 10_000_000)?;
|
||||
|
||||
let version = parent_version + VERSION;
|
||||
|
||||
let txinindex_to_txoutindex = LazyVecFrom2::init(
|
||||
"txoutindex",
|
||||
version,
|
||||
indexer.vecs.txinindex_to_outpoint.boxed_clone(),
|
||||
indexer.vecs.txindex_to_first_txoutindex.boxed_clone(),
|
||||
|index: TxInIndex, txinindex_to_outpoint_iter, txindex_to_first_txoutindex_iter| {
|
||||
txinindex_to_outpoint_iter
|
||||
.next_at(index.to_usize())
|
||||
.map(|(_, outpoint)| {
|
||||
let outpoint = outpoint.into_owned();
|
||||
txindex_to_first_txoutindex_iter
|
||||
.next_at(outpoint.txindex().to_usize())
|
||||
.unwrap()
|
||||
.1
|
||||
.into_owned()
|
||||
+ outpoint.vout()
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
let txoutindex_to_txoutindex = LazyVecFrom1::init(
|
||||
"txoutindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
let txinindex_to_txinindex = LazyVecFrom1::init(
|
||||
"txinindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
indexer.vecs.txinindex_to_txoutindex.boxed_clone(),
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txinindex_to_outpoint.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
let txindex_to_txindex = LazyVecFrom1::init(
|
||||
"txindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_txid.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
let txindex_to_input_count = LazyVecFrom2::init(
|
||||
"input_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_txinindex.boxed_clone(),
|
||||
indexer.vecs.txinindex_to_txoutindex.boxed_clone(),
|
||||
txinindex_to_txoutindex.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_txinindex_iter, txinindex_to_txoutindex_iter| {
|
||||
let txindex = index.to_usize();
|
||||
txindex_to_first_txinindex_iter
|
||||
@@ -144,7 +173,7 @@ impl Vecs {
|
||||
|
||||
let txindex_to_output_count = LazyVecFrom2::init(
|
||||
"output_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.txindex_to_first_txoutindex.boxed_clone(),
|
||||
indexer.vecs.txoutindex_to_value.boxed_clone(),
|
||||
|index: TxIndex, txindex_to_first_txoutindex_iter, txoutindex_to_value_iter| {
|
||||
@@ -164,78 +193,79 @@ impl Vecs {
|
||||
|
||||
let p2pk33addressindex_to_p2pk33addressindex = LazyVecFrom1::init(
|
||||
"p2pk33addressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pk33addressindex_to_p2pk33bytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2pk65addressindex_to_p2pk65addressindex = LazyVecFrom1::init(
|
||||
"p2pk65addressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pk65addressindex_to_p2pk65bytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2pkhaddressindex_to_p2pkhaddressindex = LazyVecFrom1::init(
|
||||
"p2pkhaddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2pkhaddressindex_to_p2pkhbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2shaddressindex_to_p2shaddressindex = LazyVecFrom1::init(
|
||||
"p2shaddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2shaddressindex_to_p2shbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2traddressindex_to_p2traddressindex = LazyVecFrom1::init(
|
||||
"p2traddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2traddressindex_to_p2trbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2wpkhaddressindex_to_p2wpkhaddressindex = LazyVecFrom1::init(
|
||||
"p2wpkhaddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2wshaddressindex_to_p2wshaddressindex = LazyVecFrom1::init(
|
||||
"p2wshaddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2wshaddressindex_to_p2wshbytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2aaddressindex_to_p2aaddressindex = LazyVecFrom1::init(
|
||||
"p2aaddressindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2aaddressindex_to_p2abytes.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let p2msoutputindex_to_p2msoutputindex = LazyVecFrom1::init(
|
||||
"p2msoutputindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.p2msoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let emptyoutputindex_to_emptyoutputindex = LazyVecFrom1::init(
|
||||
"emptyoutputindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.emptyoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let unknownoutputindex_to_unknownoutputindex = LazyVecFrom1::init(
|
||||
"unknownoutputindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.unknownoutputindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
let opreturnindex_to_opreturnindex = LazyVecFrom1::init(
|
||||
"opreturnindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
indexer.vecs.opreturnindex_to_txindex.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
);
|
||||
|
||||
let this = Self {
|
||||
txinindex_to_txoutindex,
|
||||
emptyoutputindex_to_emptyoutputindex,
|
||||
txinindex_to_txinindex,
|
||||
opreturnindex_to_opreturnindex,
|
||||
@@ -257,207 +287,207 @@ impl Vecs {
|
||||
dateindex_to_date: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"date",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_dateindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_first_height: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_monthindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_weekindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_decadeindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_first_yearindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_difficultyepoch: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_first_height: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_first_height: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_height",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
halvingepoch_to_halvingepoch: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"date",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_difficultyepoch: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"difficultyepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_halvingepoch: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"halvingepoch",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_height: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"height",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_first_dateindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_monthindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_quarterindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_semesterindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_yearindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_first_dateindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_first_monthindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"first_monthindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_quarterindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"quarterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_semesterindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"semesterindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_weekindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"weekindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_decadeindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"decadeindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_yearindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"yearindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_date_fixed: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"date_fixed",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_dateindex: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"dateindex",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_timestamp_fixed: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"timestamp_fixed",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
height_to_txindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"txindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
dateindex_to_height_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"height_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
weekindex_to_dateindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
difficultyepoch_to_height_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"height_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
monthindex_to_dateindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"dateindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
quarterindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
semesterindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
yearindex_to_monthindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"monthindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
decadeindex_to_yearindex_count: EagerVec::forced_import_compressed(
|
||||
&db,
|
||||
"yearindex_count",
|
||||
version + VERSION + Version::ZERO,
|
||||
version + Version::ZERO,
|
||||
)?,
|
||||
db,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use std::path::Path;
|
||||
use std::{path::Path, thread};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_reader::Reader;
|
||||
use brk_structs::Version;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Version;
|
||||
use log::info;
|
||||
use vecdb::{Exit, Format};
|
||||
|
||||
@@ -59,53 +59,78 @@ impl Computer {
|
||||
|
||||
let computed_path = outputs_path.join("computed");
|
||||
|
||||
let indexes =
|
||||
indexes::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, indexer)?;
|
||||
let (indexes, fetched, blks) = thread::scope(|s| -> Result<_> {
|
||||
let fetched_handle = fetcher.map(|fetcher| {
|
||||
s.spawn(move || fetched::Vecs::forced_import(outputs_path, fetcher, VERSION))
|
||||
});
|
||||
|
||||
let fetched = fetcher.map(|fetcher| {
|
||||
fetched::Vecs::forced_import(outputs_path, fetcher, VERSION + Version::ZERO).unwrap()
|
||||
});
|
||||
let blks_handle = s.spawn(|| blks::Vecs::forced_import(&computed_path, VERSION));
|
||||
|
||||
let price = fetched.is_some().then(|| {
|
||||
price::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, &indexes).unwrap()
|
||||
});
|
||||
let indexes = indexes::Vecs::forced_import(&computed_path, VERSION, indexer)?;
|
||||
let fetched = fetched_handle.map(|h| h.join().unwrap()).transpose()?;
|
||||
let blks = blks_handle.join().unwrap()?;
|
||||
|
||||
import in theads
|
||||
Ok((indexes, fetched, blks))
|
||||
})?;
|
||||
|
||||
let (price, constants, market) = thread::scope(|s| -> Result<_> {
|
||||
let constants_handle =
|
||||
s.spawn(|| constants::Vecs::forced_import(&computed_path, VERSION, &indexes));
|
||||
|
||||
let market_handle =
|
||||
s.spawn(|| market::Vecs::forced_import(&computed_path, VERSION, &indexes));
|
||||
|
||||
let price = fetched
|
||||
.is_some()
|
||||
.then(|| price::Vecs::forced_import(&computed_path, VERSION, &indexes).unwrap());
|
||||
|
||||
let constants = constants_handle.join().unwrap()?;
|
||||
let market = market_handle.join().unwrap()?;
|
||||
|
||||
Ok((price, constants, market))
|
||||
})?;
|
||||
|
||||
let (chain, pools, cointime) = thread::scope(|s| -> Result<_> {
|
||||
let chain_handle = s.spawn(|| {
|
||||
chain::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION,
|
||||
indexer,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)
|
||||
});
|
||||
|
||||
let pools_handle = s.spawn(|| {
|
||||
pools::Vecs::forced_import(&computed_path, VERSION, &indexes, price.as_ref())
|
||||
});
|
||||
|
||||
let cointime =
|
||||
cointime::Vecs::forced_import(&computed_path, VERSION, &indexes, price.as_ref())?;
|
||||
|
||||
let chain = chain_handle.join().unwrap()?;
|
||||
let pools = pools_handle.join().unwrap()?;
|
||||
|
||||
Ok((chain, pools, cointime))
|
||||
})?;
|
||||
|
||||
// Threads inside
|
||||
let stateful = stateful::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION,
|
||||
Format::Compressed,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?;
|
||||
|
||||
Ok(Self {
|
||||
constants: constants::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION + Version::ZERO,
|
||||
&indexes,
|
||||
)?,
|
||||
market: market::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, &indexes)?,
|
||||
stateful: stateful::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION + Version::ZERO,
|
||||
Format::Compressed,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?,
|
||||
chain: chain::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION + Version::ZERO,
|
||||
indexer,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?,
|
||||
blks: blks::Vecs::forced_import(&computed_path, VERSION + Version::ZERO)?,
|
||||
pools: pools::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION + Version::ZERO,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?,
|
||||
cointime: cointime::Vecs::forced_import(
|
||||
&computed_path,
|
||||
VERSION + Version::ZERO,
|
||||
&indexes,
|
||||
price.as_ref(),
|
||||
)?,
|
||||
constants,
|
||||
market,
|
||||
stateful,
|
||||
chain,
|
||||
blks,
|
||||
pools,
|
||||
cointime,
|
||||
indexes,
|
||||
fetched,
|
||||
price,
|
||||
@@ -137,7 +162,7 @@ impl Computer {
|
||||
|
||||
info!("Computing BLKs metadata...");
|
||||
self.blks
|
||||
.compute(indexer, &self.indexes, &starting_indexes, parser, exit)?;
|
||||
.compute(indexer, &starting_indexes, parser, exit)?;
|
||||
|
||||
std::thread::scope(|scope| -> Result<()> {
|
||||
let constants = scope.spawn(|| -> Result<()> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{path::Path, thread};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Date, DateIndex, Dollars, Height, Sats, StoredF32, StoredU16, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Date, DateIndex, Dollars, Height, Sats, StoredF32, StoredU16, Version};
|
||||
use vecdb::{Database, EagerVec, Exit, PAGE_SIZE, StoredIndex, VecIterator};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -4,8 +4,8 @@ use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_store::AnyStore;
|
||||
use brk_structs::{Address, AddressBytes, Height, OutputType, PoolId, Pools, TxOutIndex, pools};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Address, AddressBytes, Height, OutputType, PoolId, Pools, TxOutIndex, pools};
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, Exit, GenericStoredVec, PAGE_SIZE, RawVec,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use allocative::Allocative;
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Height, PoolId, Pools, Sats, StoredF32, StoredU16, StoredU32};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, PoolId, Pools, Sats, StoredF32, StoredU16, StoredU32};
|
||||
use vecdb::{AnyIterableVec, Database, Exit, StoredIndex, VecIterator, Version};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Cents, Close, DateIndex, DecadeIndex, DifficultyEpoch, Dollars, Height, High, Low, MonthIndex,
|
||||
OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, SemesterIndex, Version, WeekIndex, YearIndex,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit, GenericStoredVec, PAGE_SIZE,
|
||||
RawVec,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, DateIndex, Dollars, Height, StoredU64, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, StoredU64, Version};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, GenericStoredVec,
|
||||
VecIterator,
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_grouper::{AddressGroups, ByAmountRange, ByGreatEqualAmount, ByLowerThanAmount, Filtered};
|
||||
use brk_structs::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::{AnyIterableVec, Database, Exit, Format};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_structs::Height;
|
||||
use brk_types::Height;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::VecIterator;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_structs::{Height, StoredU64};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, StoredU64};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::{EagerVec, Exit, GenericStoredVec};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use brk_structs::Height;
|
||||
use brk_types::Height;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
|
||||
use crate::stateful::AddressTypeToVec;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_structs::StoredU64;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::StoredU64;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::Exit;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{collections::BTreeMap, mem};
|
||||
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_structs::TypeIndex;
|
||||
use brk_types::TypeIndex;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
|
||||
#[derive(Debug, Deref, DerefMut)]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Bitcoin, DateIndex, Dollars, Height, Sats, StoredF32, StoredF64, StoredU64, Version,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{
|
||||
AnyCloneableIterableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit,
|
||||
Format, GenericStoredVec, VecIterator,
|
||||
|
||||
@@ -9,14 +9,14 @@ use std::{
|
||||
use brk_error::Result;
|
||||
use brk_grouper::{ByAddressType, ByAnyAddress, Filtered};
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
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,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use log::info;
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{
|
||||
@@ -544,9 +544,9 @@ impl Vecs {
|
||||
let height_to_input_count = chain.indexes_to_input_count.height.unwrap_sum();
|
||||
let txinindex_to_txoutindex = &indexer.vecs.txinindex_to_txoutindex;
|
||||
let txoutindex_to_value = &indexer.vecs.txoutindex_to_value;
|
||||
let txindex_to_height = &indexes.txindex_to_height;
|
||||
let txindex_to_height = &indexer.vecs.txindex_to_height;
|
||||
let height_to_timestamp_fixed = &indexes.height_to_timestamp_fixed;
|
||||
let txoutindex_to_txindex = &indexes.txoutindex_to_txindex;
|
||||
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_unclaimed_rewards = chain
|
||||
@@ -1506,28 +1506,28 @@ impl Vecs {
|
||||
|
||||
let anyaddressindex = match address_type {
|
||||
OutputType::P2PK33 => {
|
||||
p2pk33addressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2pk33addressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2PK65 => {
|
||||
p2pk65addressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2pk65addressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2PKH => {
|
||||
p2pkhaddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2pkhaddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2SH => {
|
||||
p2shaddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2shaddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2TR => {
|
||||
p2traddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2traddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2WPKH => {
|
||||
p2wpkhaddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2wpkhaddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2WSH => {
|
||||
p2wshaddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2wshaddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
OutputType::P2A => {
|
||||
p2aaddressindex_to_anyaddressindex.get_or_read(typeindex.into(), reader)
|
||||
p2aaddressindex_to_anyaddressindex.get_any_or_read(typeindex.into(), reader)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@@ -1543,7 +1543,7 @@ impl Vecs {
|
||||
.unwrap();
|
||||
|
||||
let loadedaddressdata = loadedaddressindex_to_loadedaddressdata
|
||||
.get_or_read(loadedaddressindex, mmap)
|
||||
.get_any_or_read(loadedaddressindex, mmap)
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
@@ -1560,7 +1560,7 @@ impl Vecs {
|
||||
.unwrap();
|
||||
|
||||
let emptyaddressdata = emptyaddressindex_to_emptyaddressdata
|
||||
.get_or_read(emtpyaddressindex, mmap)
|
||||
.get_any_or_read(emtpyaddressindex, mmap)
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_owned();
|
||||
@@ -1956,7 +1956,7 @@ impl HeightToAddressTypeToVec<(TypeIndex, Sats)> {
|
||||
price: Option<Dollars>,
|
||||
addresstype_to_addr_count: &mut ByAddressType<u64>,
|
||||
addresstype_to_empty_addr_count: &mut ByAddressType<u64>,
|
||||
height_to_price_close_vec: Option<&Vec<brk_structs::Close<Dollars>>>,
|
||||
height_to_price_close_vec: Option<&Vec<brk_types::Close<Dollars>>>,
|
||||
height_to_timestamp_fixed_vec: &[Timestamp],
|
||||
height: Height,
|
||||
timestamp: Timestamp,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use vecdb::{AnyIterableVec, Exit};
|
||||
|
||||
use crate::{Indexes, indexes, price};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{ops::Deref, path::Path};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, DateIndex, Dollars, Height, Version};
|
||||
use vecdb::{AnyIterableVec, Database, Exit, Format};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -5,10 +5,10 @@ use brk_grouper::{
|
||||
ByAgeRange, ByAmountRange, ByEpoch, ByGreatEqualAmount, ByLowerThanAmount, ByMaxAge, ByMinAge,
|
||||
BySpendableType, ByTerm, Filter, Filtered, UTXOGroups,
|
||||
};
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Bitcoin, CheckedSub, DateIndex, Dollars, HalvingEpoch, Height, Timestamp, Version,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use vecdb::{AnyIterableVec, Database, Exit, Format, StoredIndex};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_structs::{EmptyAddressData, EmptyAddressIndex, LoadedAddressData, LoadedAddressIndex};
|
||||
use brk_types::{EmptyAddressData, EmptyAddressIndex, LoadedAddressData, LoadedAddressIndex};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WithAddressDataSource<T> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::ops::{Add, AddAssign, SubAssign};
|
||||
|
||||
use brk_structs::{Dollars, Timestamp};
|
||||
use brk_types::{Dollars, Timestamp};
|
||||
use serde::Serialize;
|
||||
|
||||
use super::SupplyState;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Dollars, Height, LoadedAddressData, Sats};
|
||||
use brk_types::{Dollars, Height, LoadedAddressData, Sats};
|
||||
|
||||
use crate::SupplyState;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{cmp::Ordering, path::Path};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{CheckedSub, Dollars, Height, Sats};
|
||||
use brk_types::{CheckedSub, Dollars, Height, Sats};
|
||||
|
||||
use crate::{PriceToAmount, RealizedState, SupplyState, UnrealizedState};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{Dollars, Height, Sats};
|
||||
use brk_types::{Dollars, Height, Sats};
|
||||
use derive_deref::{Deref, DerefMut};
|
||||
use pco::standalone::{simple_decompress, simpler_compress};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use brk_structs::{CheckedSub, Dollars};
|
||||
use brk_types::{CheckedSub, Dollars};
|
||||
|
||||
use super::SupplyState;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::ops::{Add, AddAssign, SubAssign};
|
||||
|
||||
use brk_structs::{CheckedSub, LoadedAddressData, Sats};
|
||||
use brk_types::{CheckedSub, LoadedAddressData, Sats};
|
||||
use serde::Serialize;
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_grouper::{ByAmountRange, GroupedByType};
|
||||
use brk_structs::{OutputType, Sats};
|
||||
use brk_types::{OutputType, Sats};
|
||||
|
||||
use super::SupplyState;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_structs::{Dollars, Sats};
|
||||
use brk_types::{Dollars, Sats};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct UnrealizedState {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_structs::{Bitcoin, CheckedSub, Close, Date, DateIndex, Dollars, Sats, StoredF32};
|
||||
use brk_types::{Bitcoin, CheckedSub, Close, Date, DateIndex, Dollars, Sats, StoredF32};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredVec, AnyVec, EagerVec, Exit, GenericStoredVec, StoredIndex,
|
||||
VecIterator, Version,
|
||||
|
||||
@@ -12,7 +12,7 @@ build = "build.rs"
|
||||
[dependencies]
|
||||
brk_error = { workspace = true }
|
||||
brk_logger = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
log = { workspace = true }
|
||||
minreq = { workspace = true }
|
||||
sonic-rs = { workspace = true }
|
||||
|
||||
@@ -34,7 +34,7 @@ cargo add brk_fetcher
|
||||
|
||||
```rust
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_structs::{Date, Height, Timestamp};
|
||||
use brk_types::{Date, Height, Timestamp};
|
||||
|
||||
// Initialize fetcher with exchange APIs enabled
|
||||
let mut fetcher = Fetcher::import(true, None)?;
|
||||
@@ -88,7 +88,7 @@ The fetcher implements aggressive retry logic with exponential backoff, attempti
|
||||
|
||||
```rust
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_structs::Date;
|
||||
use brk_types::Date;
|
||||
|
||||
let mut fetcher = Fetcher::import(true, None)?;
|
||||
|
||||
@@ -162,7 +162,7 @@ Binance integration supports HTTP Archive (HAR) files for extended historical da
|
||||
**Caching**: BTreeMap-based caching for both timestamp and date-indexed price data \
|
||||
**Network Layer**: Built on `minreq` HTTP client with automatic JSON parsing \
|
||||
**Error Handling**: Comprehensive retry logic with source rotation and cache management \
|
||||
**Dependencies**: Integrates `brk_structs` for type definitions and `brk_error` for unified error handling \
|
||||
**Dependencies**: Integrates `brk_types` for type definitions and `brk_error` for unified error handling \
|
||||
**Architecture**: Multi-source aggregation pattern with hierarchical fallback and intelligent caching
|
||||
|
||||
---
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_fetcher::{BRK, Binance, Fetcher, Kraken};
|
||||
use brk_structs::{Date, Height};
|
||||
use brk_types::{Date, Height};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
brk_logger::init(None)?;
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::{
|
||||
};
|
||||
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{Cents, OHLCCents, Timestamp};
|
||||
use brk_types::{Cents, OHLCCents, Timestamp};
|
||||
use log::info;
|
||||
use sonic_rs::{JsonContainerTrait, JsonValueTrait, Value};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{Cents, CheckedSub, Date, DateIndex, Height, OHLCCents};
|
||||
use brk_types::{Cents, CheckedSub, Date, DateIndex, Height, OHLCCents};
|
||||
use log::info;
|
||||
use sonic_rs::{JsonContainerTrait, JsonValueTrait, Value};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{Cents, Close, Date, Dollars, High, Low, OHLCCents, Open, Timestamp};
|
||||
use brk_types::{Cents, Close, Date, Dollars, High, Low, OHLCCents, Open, Timestamp};
|
||||
use log::info;
|
||||
use sonic_rs::{JsonContainerTrait, JsonValueTrait, Value};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::{collections::BTreeMap, path::Path, thread::sleep, time::Duration};
|
||||
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{Close, Date, Dollars, Height, High, Low, OHLCCents, Open, Timestamp};
|
||||
use brk_types::{Close, Date, Dollars, Height, High, Low, OHLCCents, Open, Timestamp};
|
||||
use log::info;
|
||||
|
||||
mod binance;
|
||||
|
||||
@@ -11,7 +11,7 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
brk_error = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
brk_traversable = { workspace = true }
|
||||
vecdb = { workspace = true }
|
||||
rayon = { workspace = true }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::OutputType;
|
||||
use brk_traversable::{Traversable, TreeNode};
|
||||
use brk_types::OutputType;
|
||||
use rayon::prelude::*;
|
||||
use vecdb::AnyCollectableVec;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_structs::Sats;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Sats;
|
||||
|
||||
use super::{Filter, Filtered};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_structs::{HalvingEpoch, Height};
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{HalvingEpoch, Height};
|
||||
|
||||
use super::{Filter, Filtered};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_structs::Sats;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Sats;
|
||||
|
||||
use super::{Filter, Filtered};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_structs::Sats;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Sats;
|
||||
|
||||
use super::{Filter, Filtered};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_structs::OutputType;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::OutputType;
|
||||
|
||||
use super::{Filter, Filtered};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use brk_structs::OutputType;
|
||||
use brk_types::OutputType;
|
||||
|
||||
use super::{BySpendableType, ByUnspendableType};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::Range;
|
||||
|
||||
use brk_structs::{HalvingEpoch, OutputType};
|
||||
use brk_traversable::{Traversable, TreeNode};
|
||||
use brk_types::{HalvingEpoch, OutputType};
|
||||
use vecdb::AnyCollectableVec;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
||||
@@ -13,10 +13,12 @@ build = "build.rs"
|
||||
bitcoin = { workspace = true }
|
||||
brk_error = { workspace = true }
|
||||
brk_grouper = { workspace = true }
|
||||
brk_iterator = { workspace = true }
|
||||
brk_logger = { workspace = true }
|
||||
brk_reader = { workspace = true }
|
||||
brk_rpc = { workspace = true }
|
||||
brk_store = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
brk_traversable = { workspace = true }
|
||||
fjall2 = { workspace = true }
|
||||
# fjall3 = { workspace = true }
|
||||
|
||||
@@ -137,7 +137,7 @@ println!("Total addresses: {}", final_indexes.total_address_count());
|
||||
|
||||
```rust
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::{Height, TxidPrefix, AddressBytesHash};
|
||||
use brk_types::{Height, TxidPrefix, AddressBytesHash};
|
||||
|
||||
let indexer = Indexer::forced_import("./blockchain_index")?;
|
||||
|
||||
@@ -183,7 +183,7 @@ println!("Processed {} new blocks",
|
||||
|
||||
```rust
|
||||
use brk_indexer::Indexer;
|
||||
use brk_structs::OutputType;
|
||||
use brk_types::OutputType;
|
||||
|
||||
let indexer = Indexer::forced_import("./blockchain_index")?;
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ use std::{
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_iterator::Blocks;
|
||||
use brk_reader::Reader;
|
||||
use brk_rpc::{Auth, Client};
|
||||
use vecdb::Exit;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -19,21 +21,18 @@ fn main() -> Result<()> {
|
||||
.join("Bitcoin");
|
||||
// let bitcoin_dir = Path::new("/Volumes/WD_BLACK1/bitcoin");
|
||||
|
||||
let blocks_dir = bitcoin_dir.join("blocks");
|
||||
|
||||
let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
|
||||
fs::create_dir_all(&outputs_dir)?;
|
||||
// let outputs_dir = Path::new("/Volumes/WD_BLACK1/brk");
|
||||
|
||||
let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
|
||||
let client = Client::new(
|
||||
"http://localhost:8332",
|
||||
bitcoincore_rpc::Auth::CookieFile(bitcoin_dir.join(".cookie")),
|
||||
)?));
|
||||
Auth::CookieFile(bitcoin_dir.join(".cookie")),
|
||||
)?;
|
||||
|
||||
let exit = Exit::new();
|
||||
exit.set_ctrlc_handler();
|
||||
let reader = Reader::new(bitcoin_dir.join("blocks"), client.clone());
|
||||
|
||||
let reader = Reader::new(blocks_dir, rpc);
|
||||
let blocks = Blocks::new(client.clone(), reader);
|
||||
|
||||
fs::create_dir_all(&outputs_dir)?;
|
||||
|
||||
@@ -45,9 +44,12 @@ fn main() -> Result<()> {
|
||||
// dbg!(vecs.len());
|
||||
// std::process::exit(0);
|
||||
|
||||
let exit = Exit::new();
|
||||
exit.set_ctrlc_handler();
|
||||
|
||||
loop {
|
||||
let i = Instant::now();
|
||||
indexer.index(&reader, rpc, &exit, true)?;
|
||||
indexer.checked_index(&blocks, &client, &exit)?;
|
||||
dbg!(i.elapsed());
|
||||
|
||||
sleep(Duration::from_secs(60));
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
use bitcoincore_rpc::Client;
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{
|
||||
BlockHash, CheckedSub, EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddressIndex,
|
||||
P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex,
|
||||
P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, TxInIndex, TxIndex, TxOutIndex,
|
||||
TypeIndex, UnknownOutputIndex,
|
||||
};
|
||||
use vecdb::{
|
||||
AnyIterableVec, AnyStoredIterableVec, GenericStoredVec, StoredIndex, StoredRaw, VecIterator,
|
||||
use brk_error::Result;
|
||||
use brk_types::{
|
||||
EmptyOutputIndex, Height, OpReturnIndex, OutputType, P2AAddressIndex, P2MSOutputIndex,
|
||||
P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex,
|
||||
P2WPKHAddressIndex, P2WSHAddressIndex, TxInIndex, TxIndex, TxOutIndex, TypeIndex,
|
||||
UnknownOutputIndex,
|
||||
};
|
||||
use vecdb::{AnyIterableVec, AnyStoredIterableVec, GenericStoredVec, StoredIndex, StoredRaw};
|
||||
|
||||
use crate::{Stores, Vecs};
|
||||
|
||||
const NUMBER_OF_UNSAFE_BLOCKS: usize = 100;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Indexes {
|
||||
pub emptyoutputindex: EmptyOutputIndex,
|
||||
@@ -90,176 +85,118 @@ impl Indexes {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
||||
type Error = Error;
|
||||
fn try_from((vecs, stores, rpc): (&mut Vecs, &Stores, &Client)) -> Result<Self> {
|
||||
impl From<(Height, &mut Vecs, &Stores)> for Indexes {
|
||||
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();
|
||||
let stores_starting_height = stores.starting_height();
|
||||
let starting_height = vecs_starting_height.min(stores_starting_height);
|
||||
|
||||
// dbg!(
|
||||
// vecs_starting_height,
|
||||
// stores_starting_height,
|
||||
// starting_height
|
||||
// );
|
||||
|
||||
let range = u32::from(
|
||||
starting_height
|
||||
.checked_sub(NUMBER_OF_UNSAFE_BLOCKS as u32)
|
||||
.unwrap_or_default(),
|
||||
)..u32::from(starting_height);
|
||||
|
||||
let mut height_to_blockhash_iter = vecs.height_to_blockhash.iter();
|
||||
|
||||
// But we also need to check the chain and start earlier in case of a reorg
|
||||
let height = range // ..= because of last saved + 1
|
||||
.map(Height::from)
|
||||
.find(|height| {
|
||||
let rpc_blockhash = BlockHash::try_from((rpc, *height))
|
||||
.inspect_err(|e| {
|
||||
dbg!(e, height);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
height_to_blockhash_iter
|
||||
.get(*height)
|
||||
.is_none_or(|saved_blockhash| &rpc_blockhash != saved_blockhash.as_ref())
|
||||
})
|
||||
.unwrap_or(starting_height);
|
||||
let height = vecs_starting_height.min(stores_starting_height);
|
||||
if height < min_height {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
let emptyoutputindex = starting_index(
|
||||
&vecs.height_to_first_emptyoutputindex,
|
||||
&vecs.emptyoutputindex_to_txindex,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(emptyoutputindex);
|
||||
.unwrap();
|
||||
|
||||
let p2msoutputindex = starting_index(
|
||||
&vecs.height_to_first_p2msoutputindex,
|
||||
&vecs.p2msoutputindex_to_txindex,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2msoutputindex);
|
||||
.unwrap();
|
||||
|
||||
let opreturnindex = starting_index(
|
||||
&vecs.height_to_first_opreturnindex,
|
||||
&vecs.opreturnindex_to_txindex,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(opreturnindex);
|
||||
.unwrap();
|
||||
|
||||
let p2pk33addressindex = starting_index(
|
||||
&vecs.height_to_first_p2pk33addressindex,
|
||||
&vecs.p2pk33addressindex_to_p2pk33bytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2pk33addressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2pk65addressindex = starting_index(
|
||||
&vecs.height_to_first_p2pk65addressindex,
|
||||
&vecs.p2pk65addressindex_to_p2pk65bytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2pk65addressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2pkhaddressindex = starting_index(
|
||||
&vecs.height_to_first_p2pkhaddressindex,
|
||||
&vecs.p2pkhaddressindex_to_p2pkhbytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2pkhaddressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2shaddressindex = starting_index(
|
||||
&vecs.height_to_first_p2shaddressindex,
|
||||
&vecs.p2shaddressindex_to_p2shbytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2shaddressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2traddressindex = starting_index(
|
||||
&vecs.height_to_first_p2traddressindex,
|
||||
&vecs.p2traddressindex_to_p2trbytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2traddressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2wpkhaddressindex = starting_index(
|
||||
&vecs.height_to_first_p2wpkhaddressindex,
|
||||
&vecs.p2wpkhaddressindex_to_p2wpkhbytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2wpkhaddressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2wshaddressindex = starting_index(
|
||||
&vecs.height_to_first_p2wshaddressindex,
|
||||
&vecs.p2wshaddressindex_to_p2wshbytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(p2wshaddressindex);
|
||||
.unwrap();
|
||||
|
||||
let p2aaddressindex = starting_index(
|
||||
&vecs.height_to_first_p2aaddressindex,
|
||||
&vecs.p2aaddressindex_to_p2abytes,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
.unwrap();
|
||||
|
||||
// dbg!(p2aaddressindex);
|
||||
|
||||
let txindex = starting_index(&vecs.height_to_first_txindex, &vecs.txindex_to_txid, height)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(txindex);
|
||||
let txindex =
|
||||
starting_index(&vecs.height_to_first_txindex, &vecs.txindex_to_txid, height).unwrap();
|
||||
|
||||
let txinindex = starting_index(
|
||||
&vecs.height_to_first_txinindex,
|
||||
&vecs.txinindex_to_outpoint,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(txinindex);
|
||||
.unwrap();
|
||||
|
||||
let txoutindex = starting_index(
|
||||
&vecs.height_to_first_txoutindex,
|
||||
&vecs.txoutindex_to_value,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
|
||||
// dbg!(txoutindex);
|
||||
.unwrap();
|
||||
|
||||
let unknownoutputindex = starting_index(
|
||||
&vecs.height_to_first_unknownoutputindex,
|
||||
&vecs.unknownoutputindex_to_txindex,
|
||||
height,
|
||||
)
|
||||
.ok_or(Error::Str(""))?;
|
||||
.unwrap();
|
||||
|
||||
// dbg!(unknownoutputindex);
|
||||
|
||||
Ok(Self {
|
||||
Self {
|
||||
emptyoutputindex,
|
||||
height,
|
||||
p2msoutputindex,
|
||||
@@ -276,7 +213,7 @@ impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
||||
txinindex,
|
||||
txoutindex,
|
||||
unknownoutputindex,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ use std::{path::Path, str::FromStr, thread, time::Instant};
|
||||
|
||||
use bitcoin::{TxIn, TxOut};
|
||||
use brk_error::{Error, Result};
|
||||
use brk_iterator::Blocks;
|
||||
use brk_rpc::Client;
|
||||
use brk_store::AnyStore;
|
||||
use brk_structs::{
|
||||
use brk_types::{
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutPoint, OutputType, Sats,
|
||||
StoredBool, Timestamp, TxInIndex, TxIndex, TxOutIndex, Txid, TxidPrefix, TypeIndex,
|
||||
TypeIndexAndOutPoint, TypeIndexAndTxIndex, Unit, Version, Vin, Vout,
|
||||
@@ -58,15 +60,40 @@ impl Indexer {
|
||||
Ok(Self { vecs, stores })
|
||||
}
|
||||
|
||||
pub fn index(
|
||||
pub fn index(&mut self, blocks: &Blocks, client: &Client, exit: &Exit) -> Result<Indexes> {
|
||||
self.index_(blocks, client, exit, false)
|
||||
}
|
||||
|
||||
pub fn checked_index(
|
||||
&mut self,
|
||||
reader: &brk_reader::Reader,
|
||||
rpc: &'static bitcoincore_rpc::Client,
|
||||
blocks: &Blocks,
|
||||
client: &Client,
|
||||
exit: &Exit,
|
||||
) -> Result<Indexes> {
|
||||
self.index_(blocks, client, exit, true)
|
||||
}
|
||||
|
||||
fn index_(
|
||||
&mut self,
|
||||
blocks: &Blocks,
|
||||
client: &Client,
|
||||
exit: &Exit,
|
||||
check_collisions: bool,
|
||||
) -> Result<Indexes> {
|
||||
let starting_indexes = Indexes::try_from((&mut self.vecs, &self.stores, rpc))
|
||||
.unwrap_or_else(|_report| Indexes::default());
|
||||
let (starting_indexes, prev_hash) = if let Some(hash) =
|
||||
VecIterator::last(self.vecs.height_to_blockhash.iter()).map(|(_, v)| v.into_owned())
|
||||
{
|
||||
let (height, hash) = client.get_closest_valid_height(hash)?;
|
||||
let starting_indexes =
|
||||
Indexes::from((height.incremented(), &mut self.vecs, &self.stores));
|
||||
if starting_indexes.height > client.get_last_height()? {
|
||||
info!("Up to date, nothing to index.");
|
||||
return Ok(starting_indexes);
|
||||
}
|
||||
(starting_indexes, Some(hash))
|
||||
} else {
|
||||
(Indexes::default(), None)
|
||||
};
|
||||
|
||||
let lock = exit.lock();
|
||||
self.stores
|
||||
@@ -74,54 +101,39 @@ impl Indexer {
|
||||
self.vecs.rollback_if_needed(&starting_indexes)?;
|
||||
drop(lock);
|
||||
|
||||
let vecs = &mut self.vecs;
|
||||
let stores = &mut self.stores;
|
||||
|
||||
// Cloned because we want to return starting indexes for the computer
|
||||
let mut idxs = starting_indexes.clone();
|
||||
|
||||
let start = Some(idxs.height);
|
||||
let end = None;
|
||||
|
||||
if starting_indexes.height > Height::try_from(rpc)?
|
||||
|| end.is_some_and(|end| starting_indexes.height > end)
|
||||
{
|
||||
info!("Up to date, nothing to index.");
|
||||
return Ok(starting_indexes);
|
||||
}
|
||||
|
||||
info!("Started indexing...");
|
||||
let mut indexes = starting_indexes.clone();
|
||||
|
||||
let should_export = |height: Height, rem: bool| -> bool {
|
||||
height != 0 && (height % SNAPSHOT_BLOCK_RANGE == 0) != rem
|
||||
};
|
||||
|
||||
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();
|
||||
info!("Commited stores in {}s", i.elapsed().as_secs());
|
||||
let i = Instant::now();
|
||||
vecs.flush(height)?;
|
||||
info!("Flushed vecs in {}s", i.elapsed().as_secs());
|
||||
let i = Instant::now();
|
||||
info!("Flushed db in {}s", i.elapsed().as_secs());
|
||||
Ok(())
|
||||
};
|
||||
let export = move |stores: &mut Stores, vecs: &mut Vecs, height: Height| -> Result<()> {
|
||||
info!("Exporting...");
|
||||
// std::process::exit(0);
|
||||
let _lock = exit.lock();
|
||||
let i = Instant::now();
|
||||
stores.commit(height).unwrap();
|
||||
info!("Commited stores in {}s", i.elapsed().as_secs());
|
||||
let i = Instant::now();
|
||||
vecs.flush(height)?;
|
||||
info!("Flushed vecs in {}s", i.elapsed().as_secs());
|
||||
let i = Instant::now();
|
||||
info!("Flushed db in {}s", i.elapsed().as_secs());
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let mut readers = Readers::new(vecs);
|
||||
let mut readers = Readers::new(&self.vecs);
|
||||
let mut already_added_addressbyteshash: FxHashMap<AddressBytesHash, TypeIndex> =
|
||||
FxHashMap::default();
|
||||
let mut same_block_spent_outpoints: FxHashSet<OutPoint> = FxHashSet::default();
|
||||
let mut same_block_output_info: FxHashMap<OutPoint, (OutputType, TypeIndex)> =
|
||||
FxHashMap::default();
|
||||
|
||||
// TODO: CHECK PREV HASH
|
||||
let vecs = &mut self.vecs;
|
||||
let stores = &mut self.stores;
|
||||
|
||||
for block in reader.read(start, end).iter() {
|
||||
for block in blocks.after(prev_hash)? {
|
||||
// let i_tot = Instant::now();
|
||||
already_added_addressbyteshash.clear();
|
||||
same_block_spent_outpoints.clear();
|
||||
@@ -132,7 +144,7 @@ impl Indexer {
|
||||
|
||||
info!("Indexing block {height}...");
|
||||
|
||||
idxs.height = height;
|
||||
indexes.height = height;
|
||||
|
||||
// Used to check rapidhash collisions
|
||||
let check_collisions = check_collisions && height > COLLISIONS_CHECKED_UP_TO;
|
||||
@@ -148,7 +160,7 @@ impl Indexer {
|
||||
return Err(Error::Str("Collision, expect prefix to need be set yet"));
|
||||
}
|
||||
|
||||
idxs.push_if_needed(vecs)?;
|
||||
indexes.push_if_needed(vecs)?;
|
||||
|
||||
stores
|
||||
.blockhashprefix_to_height
|
||||
@@ -191,7 +203,7 @@ impl Indexer {
|
||||
};
|
||||
|
||||
Ok((
|
||||
idxs.txindex + TxIndex::from(index),
|
||||
indexes.txindex + TxIndex::from(index),
|
||||
tx,
|
||||
txid,
|
||||
txid_prefix,
|
||||
@@ -220,8 +232,8 @@ impl Indexer {
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.map(|(block_txinindex, (block_txindex, vin, txin, tx))| -> Result<(TxInIndex, InputSource)> {
|
||||
let txindex = idxs.txindex + block_txindex;
|
||||
let txinindex = idxs.txinindex + TxInIndex::from(block_txinindex);
|
||||
let txindex = indexes.txindex + block_txindex;
|
||||
let txinindex = indexes.txinindex + TxInIndex::from(block_txinindex);
|
||||
|
||||
if tx.is_coinbase() {
|
||||
return Ok((txinindex, InputSource::SameBlock((txindex, txin, vin, OutPoint::COINBASE))));
|
||||
@@ -237,7 +249,7 @@ impl Indexer {
|
||||
.map(|v| *v)
|
||||
.and_then(|txindex| {
|
||||
// Checking if not finding txindex from the future
|
||||
(txindex < idxs.txindex).then_some(txindex)
|
||||
(txindex < indexes.txindex).then_some(txindex)
|
||||
}) {
|
||||
txindex
|
||||
} else {
|
||||
@@ -329,8 +341,8 @@ impl Indexer {
|
||||
Option<(AddressBytes, AddressBytesHash)>,
|
||||
Option<TypeIndex>,
|
||||
)> {
|
||||
let txindex = idxs.txindex + block_txindex;
|
||||
let txoutindex = idxs.txoutindex + TxOutIndex::from(block_txoutindex);
|
||||
let txindex = indexes.txindex + block_txindex;
|
||||
let txoutindex = indexes.txoutindex + TxOutIndex::from(block_txoutindex);
|
||||
|
||||
let script = &txout.script_pubkey;
|
||||
|
||||
@@ -353,7 +365,7 @@ impl Indexer {
|
||||
.map(|v| *v)
|
||||
// Checking if not in the future (in case we started before the last processed block)
|
||||
.and_then(|typeindex_local| {
|
||||
(typeindex_local < idxs.to_typeindex(outputtype))
|
||||
(typeindex_local < indexes.to_typeindex(outputtype))
|
||||
.then_some(typeindex_local)
|
||||
});
|
||||
|
||||
@@ -442,7 +454,7 @@ impl Indexer {
|
||||
outputtype,
|
||||
prev_addressbytes,
|
||||
address_bytes,
|
||||
&idxs,
|
||||
&indexes,
|
||||
typeindex,
|
||||
typeindex,
|
||||
txout,
|
||||
@@ -498,33 +510,33 @@ impl Indexer {
|
||||
ti
|
||||
} else {
|
||||
let ti = match outputtype {
|
||||
OutputType::P2PK65 => idxs.p2pk65addressindex.copy_then_increment(),
|
||||
OutputType::P2PK33 => idxs.p2pk33addressindex.copy_then_increment(),
|
||||
OutputType::P2PKH => idxs.p2pkhaddressindex.copy_then_increment(),
|
||||
OutputType::P2PK65 => indexes.p2pk65addressindex.copy_then_increment(),
|
||||
OutputType::P2PK33 => indexes.p2pk33addressindex.copy_then_increment(),
|
||||
OutputType::P2PKH => indexes.p2pkhaddressindex.copy_then_increment(),
|
||||
OutputType::P2MS => {
|
||||
vecs.p2msoutputindex_to_txindex
|
||||
.push_if_needed(idxs.p2msoutputindex, txindex)?;
|
||||
idxs.p2msoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.p2msoutputindex, txindex)?;
|
||||
indexes.p2msoutputindex.copy_then_increment()
|
||||
}
|
||||
OutputType::P2SH => idxs.p2shaddressindex.copy_then_increment(),
|
||||
OutputType::P2SH => indexes.p2shaddressindex.copy_then_increment(),
|
||||
OutputType::OpReturn => {
|
||||
vecs.opreturnindex_to_txindex
|
||||
.push_if_needed(idxs.opreturnindex, txindex)?;
|
||||
idxs.opreturnindex.copy_then_increment()
|
||||
.push_if_needed(indexes.opreturnindex, txindex)?;
|
||||
indexes.opreturnindex.copy_then_increment()
|
||||
}
|
||||
OutputType::P2WPKH => idxs.p2wpkhaddressindex.copy_then_increment(),
|
||||
OutputType::P2WSH => idxs.p2wshaddressindex.copy_then_increment(),
|
||||
OutputType::P2TR => idxs.p2traddressindex.copy_then_increment(),
|
||||
OutputType::P2A => idxs.p2aaddressindex.copy_then_increment(),
|
||||
OutputType::P2WPKH => indexes.p2wpkhaddressindex.copy_then_increment(),
|
||||
OutputType::P2WSH => indexes.p2wshaddressindex.copy_then_increment(),
|
||||
OutputType::P2TR => indexes.p2traddressindex.copy_then_increment(),
|
||||
OutputType::P2A => indexes.p2aaddressindex.copy_then_increment(),
|
||||
OutputType::Empty => {
|
||||
vecs.emptyoutputindex_to_txindex
|
||||
.push_if_needed(idxs.emptyoutputindex, txindex)?;
|
||||
idxs.emptyoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.emptyoutputindex, txindex)?;
|
||||
indexes.emptyoutputindex.copy_then_increment()
|
||||
}
|
||||
OutputType::Unknown => {
|
||||
vecs.unknownoutputindex_to_txindex
|
||||
.push_if_needed(idxs.unknownoutputindex, txindex)?;
|
||||
idxs.unknownoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.unknownoutputindex, txindex)?;
|
||||
indexes.unknownoutputindex.copy_then_increment()
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@@ -543,23 +555,23 @@ impl Indexer {
|
||||
match outputtype {
|
||||
OutputType::P2MS => {
|
||||
vecs.p2msoutputindex_to_txindex
|
||||
.push_if_needed(idxs.p2msoutputindex, txindex)?;
|
||||
idxs.p2msoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.p2msoutputindex, txindex)?;
|
||||
indexes.p2msoutputindex.copy_then_increment()
|
||||
}
|
||||
OutputType::OpReturn => {
|
||||
vecs.opreturnindex_to_txindex
|
||||
.push_if_needed(idxs.opreturnindex, txindex)?;
|
||||
idxs.opreturnindex.copy_then_increment()
|
||||
.push_if_needed(indexes.opreturnindex, txindex)?;
|
||||
indexes.opreturnindex.copy_then_increment()
|
||||
}
|
||||
OutputType::Empty => {
|
||||
vecs.emptyoutputindex_to_txindex
|
||||
.push_if_needed(idxs.emptyoutputindex, txindex)?;
|
||||
idxs.emptyoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.emptyoutputindex, txindex)?;
|
||||
indexes.emptyoutputindex.copy_then_increment()
|
||||
}
|
||||
OutputType::Unknown => {
|
||||
vecs.unknownoutputindex_to_txindex
|
||||
.push_if_needed(idxs.unknownoutputindex, txindex)?;
|
||||
idxs.unknownoutputindex.copy_then_increment()
|
||||
.push_if_needed(indexes.unknownoutputindex, txindex)?;
|
||||
indexes.unknownoutputindex.copy_then_increment()
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@@ -775,23 +787,23 @@ impl Indexer {
|
||||
)?;
|
||||
// println!("txindex_to_tx_and_txid.into_iter(): {:?}", i.elapsed());
|
||||
|
||||
idxs.txindex += TxIndex::from(tx_len);
|
||||
idxs.txinindex += TxInIndex::from(inputs_len);
|
||||
idxs.txoutindex += TxOutIndex::from(outputs_len);
|
||||
indexes.txindex += TxIndex::from(tx_len);
|
||||
indexes.txinindex += TxInIndex::from(inputs_len);
|
||||
indexes.txoutindex += TxOutIndex::from(outputs_len);
|
||||
|
||||
// println!("full block: {:?}", i_tot.elapsed());
|
||||
|
||||
if should_export(height, false) {
|
||||
drop(readers);
|
||||
export(stores, vecs, height, exit)?;
|
||||
export(stores, vecs, height)?;
|
||||
readers = Readers::new(vecs);
|
||||
}
|
||||
}
|
||||
|
||||
drop(readers);
|
||||
|
||||
if should_export(idxs.height, true) {
|
||||
export(stores, vecs, idxs.height, exit)?;
|
||||
if should_export(indexes.height, true) {
|
||||
export(stores, vecs, indexes.height)?;
|
||||
}
|
||||
|
||||
// let i = Instant::now();
|
||||
@@ -827,7 +839,7 @@ struct Readers {
|
||||
}
|
||||
|
||||
impl Readers {
|
||||
fn new(vecs: &mut Vecs) -> Self {
|
||||
fn new(vecs: &Vecs) -> Self {
|
||||
Self {
|
||||
txindex_to_first_txoutindex: vecs.txindex_to_first_txoutindex.create_static_reader(),
|
||||
txoutindex_to_outputtype: vecs.txoutindex_to_outputtype.create_static_reader(),
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{borrow::Cow, fs, path::Path};
|
||||
use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_store::{AnyStore, StoreV2 as Store};
|
||||
use brk_structs::{
|
||||
use brk_types::{
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutPoint, StoredString, TxIndex,
|
||||
TxOutIndex, TxidPrefix, TypeIndex, TypeIndexAndOutPoint, TypeIndexAndTxIndex, Unit, Version,
|
||||
Vout,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{borrow::Cow, fs, path::Path};
|
||||
use brk_error::Result;
|
||||
use brk_grouper::ByAddressType;
|
||||
use brk_store::{AnyStore, StoreV3 as Store};
|
||||
use brk_structs::{
|
||||
use brk_types::{
|
||||
AddressBytes, AddressBytesHash, BlockHashPrefix, Height, StoredString, TxIndex, TxOutIndex,
|
||||
TxidPrefix, TypeIndex, TypeIndexAndOutPoint, TypeIndexAndTxIndex, Unit, Version,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_structs::{
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
AddressBytes, BlockHash, EmptyOutputIndex, Height, OpReturnIndex, OutPoint, OutputType,
|
||||
P2AAddressIndex, P2ABytes, P2MSOutputIndex, P2PK33AddressIndex, P2PK33Bytes,
|
||||
P2PK65AddressIndex, P2PK65Bytes, P2PKHAddressIndex, P2PKHBytes, P2SHAddressIndex, P2SHBytes,
|
||||
@@ -9,7 +10,6 @@ use brk_structs::{
|
||||
RawLockTime, Sats, StoredBool, StoredF64, StoredU32, StoredU64, Timestamp, TxInIndex, TxIndex,
|
||||
TxOutIndex, TxVersion, Txid, TypeIndex, UnknownOutputIndex, Version, Weight,
|
||||
};
|
||||
use brk_traversable::Traversable;
|
||||
use rayon::prelude::*;
|
||||
use vecdb::{AnyStoredVec, CompressedVec, Database, GenericStoredVec, PAGE_SIZE, RawVec, Stamp};
|
||||
|
||||
|
||||
@@ -14,4 +14,4 @@ bitcoin = { workspace = true }
|
||||
brk_error = { workspace = true }
|
||||
brk_reader = { workspace = true }
|
||||
brk_rpc = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
|
||||
@@ -4,7 +4,7 @@ use brk_error::Result;
|
||||
use brk_iterator::Blocks;
|
||||
use brk_reader::Reader;
|
||||
use brk_rpc::{Auth, Client};
|
||||
use brk_structs::Height;
|
||||
use brk_types::Height;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
|
||||
@@ -26,7 +26,7 @@ fn main() -> Result<()> {
|
||||
.range(Height::new(920040), Height::new(920041))?
|
||||
// .start(Height::new(920040))?
|
||||
// .end(Height::new(10))?
|
||||
// .after(brk_structs::BlockHash::try_from(
|
||||
// .after(brk_types::BlockHash::try_from(
|
||||
// "00000000000000000000840d205cac2728740e0e7c5dc92a04c52503017c6241",
|
||||
// )?)?
|
||||
.for_each(|b| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_structs::Block;
|
||||
use brk_types::Block;
|
||||
|
||||
use crate::State;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use brk_error::Result;
|
||||
use brk_reader::Reader;
|
||||
use brk_rpc::Client;
|
||||
use brk_structs::{BlockHash, Height};
|
||||
use brk_types::{BlockHash, Height};
|
||||
|
||||
mod iterator;
|
||||
mod range;
|
||||
@@ -67,7 +67,7 @@ impl Blocks {
|
||||
}
|
||||
|
||||
/// Iterate after hash
|
||||
pub fn after(&self, hash: BlockHash) -> Result<BlockIterator> {
|
||||
pub fn after(&self, hash: Option<BlockHash>) -> Result<BlockIterator> {
|
||||
self.iter(BlockRange::After { hash })
|
||||
}
|
||||
|
||||
@@ -109,10 +109,14 @@ impl Blocks {
|
||||
Ok((start, end, None))
|
||||
}
|
||||
BlockRange::After { hash } => {
|
||||
let block_info = client.get_block_header_info(&hash)?;
|
||||
let start = (block_info.height + 1).into();
|
||||
let start = if let Some(hash) = hash.as_ref() {
|
||||
let block_info = client.get_block_header_info(hash)?;
|
||||
(block_info.height + 1).into()
|
||||
} else {
|
||||
Height::ZERO
|
||||
};
|
||||
let end = client.get_last_height()?;
|
||||
Ok((start, end, Some(hash)))
|
||||
Ok((start, end, hash))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use brk_structs::{BlockHash, Height};
|
||||
use brk_types::{BlockHash, Height};
|
||||
|
||||
pub enum BlockRange {
|
||||
Span { start: Height, end: Height },
|
||||
Start { start: Height },
|
||||
End { end: Height },
|
||||
Last { n: u32 },
|
||||
After { hash: BlockHash },
|
||||
After { hash: Option<BlockHash> },
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::vec;
|
||||
|
||||
use brk_reader::{Reader, Receiver};
|
||||
use brk_rpc::Client;
|
||||
use brk_structs::{BlockHash, Height, ReadBlock};
|
||||
use brk_types::{BlockHash, Height, ReadBlock};
|
||||
|
||||
pub enum State {
|
||||
Rpc {
|
||||
|
||||
@@ -11,7 +11,7 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
aide = { workspace = true }
|
||||
brk_interface = { workspace = true }
|
||||
brk_query = { workspace = true }
|
||||
brk_rmcp = { version = "0.8.0", features = [
|
||||
"transport-worker",
|
||||
"transport-streamable-http-server",
|
||||
|
||||
@@ -46,7 +46,7 @@ cargo add brk_mcp
|
||||
|
||||
```rust
|
||||
use brk_mcp::MCP;
|
||||
use brk_interface::Interface;
|
||||
use brk_query::Interface;
|
||||
use brk_rmcp::{ServerHandler, RoleServer};
|
||||
|
||||
// Initialize with static interface reference
|
||||
@@ -112,7 +112,7 @@ let version = mcp.get_version().await?;
|
||||
|
||||
```rust
|
||||
use brk_mcp::MCP;
|
||||
use brk_interface::{Params, PaginationParam};
|
||||
use brk_query::{Params, PaginationParam};
|
||||
|
||||
let mcp = MCP::new(interface);
|
||||
|
||||
@@ -133,7 +133,7 @@ let vecids = mcp.get_vecids(pagination).await?;
|
||||
|
||||
```rust
|
||||
use brk_mcp::MCP;
|
||||
use brk_interface::Params;
|
||||
use brk_query::Params;
|
||||
|
||||
// Query latest Bitcoin price
|
||||
let params = Params {
|
||||
@@ -155,7 +155,7 @@ match result {
|
||||
### Multi-Vector Analysis
|
||||
|
||||
```rust
|
||||
use brk_interface::Params;
|
||||
use brk_query::Params;
|
||||
|
||||
// Get OHLC data for last 30 days
|
||||
let params = Params {
|
||||
@@ -177,7 +177,7 @@ let ohlc_data = mcp.get_vecs(params).await?;
|
||||
### Vector Discovery Workflow
|
||||
|
||||
```rust
|
||||
use brk_interface::{PaginatedIndexParam, IdParam};
|
||||
use brk_query::{PaginatedIndexParam, IdParam};
|
||||
|
||||
// 1. Get available indexes
|
||||
let indexes = mcp.get_indexes().await?;
|
||||
@@ -232,7 +232,7 @@ let supported_indexes = mcp.get_vecid_to_indexes(id_param).await?;
|
||||
|
||||
**Interface Layer Access:**
|
||||
|
||||
- Direct access to `brk_interface::Interface` for data queries
|
||||
- Direct access to `brk_query::Interface` for data queries
|
||||
- Static lifetime requirements for server operation
|
||||
- Unified access to indexer and computer data sources
|
||||
- Consistent parameter types across tool boundaries
|
||||
@@ -273,7 +273,7 @@ Built-in instructions explain Bitcoin data concepts:
|
||||
**Main Structure**: `MCP` struct implementing `ServerHandler` with embedded `ToolRouter` for automatic tool discovery \
|
||||
**Tool Implementation**: 10 specialized tools using `#[tool]` attribute with structured parameters and JSON responses \
|
||||
**HTTP Integration**: `MCPRoutes` trait extending Axum routers with conditional MCP endpoint mounting \
|
||||
**Parameter Types**: Type-safe parameter structs from `brk_interface` with automatic validation \
|
||||
**Parameter Types**: Type-safe parameter structs from `brk_query` with automatic validation \
|
||||
**Error Handling**: Consistent `McpError` responses with proper MCP protocol compliance \
|
||||
**Transport Layer**: `StreamableHttpService` with stateless configuration for scalable deployment \
|
||||
**Architecture**: Standards-compliant MCP bridge providing LLM access to comprehensive Bitcoin analytics
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use brk_interface::{Interface, PaginatedIndexParam, PaginationParam, Params};
|
||||
use brk_query::{PaginatedIndexParam, PaginationParam, Params, Query};
|
||||
use brk_rmcp::{
|
||||
ErrorData as McpError, RoleServer, ServerHandler,
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
@@ -16,7 +16,7 @@ pub mod route;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MCP {
|
||||
interface: &'static Interface<'static>,
|
||||
query: &'static Query<'static>,
|
||||
tool_router: ToolRouter<MCP>,
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[tool_router]
|
||||
impl MCP {
|
||||
pub fn new(interface: &'static Interface<'static>) -> Self {
|
||||
pub fn new(query: &'static Query<'static>) -> Self {
|
||||
Self {
|
||||
interface,
|
||||
query,
|
||||
tool_router: Self::tool_router(),
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ Get the count of unique metrics.
|
||||
async fn get_metric_count(&self) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: distinct_metric_count");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.distinct_metric_count()).unwrap(),
|
||||
Content::json(self.query.distinct_metric_count()).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ Get the count of all metrics. (distinct metrics multiplied by the number of inde
|
||||
async fn get_vec_count(&self) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: total_metric_count");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.total_metric_count()).unwrap(),
|
||||
Content::json(self.query.total_metric_count()).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ Get the list of all existing indexes and their accepted variants.
|
||||
async fn get_indexes(&self) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_indexes");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.get_indexes()).unwrap(),
|
||||
Content::json(self.query.get_indexes()).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ If the `page` param is omitted, it will default to the first page.
|
||||
) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_metrics");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.get_metrics(pagination)).unwrap(),
|
||||
Content::json(self.query.get_metrics(pagination)).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ If the `page` param is omitted, it will default to the first page.
|
||||
) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_index_to_vecids");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.get_index_to_vecids(paginated_index)).unwrap(),
|
||||
Content::json(self.query.get_index_to_vecids(paginated_index)).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ The list will be empty if the vec id isn't correct.
|
||||
) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_vecid_to_indexes");
|
||||
Ok(CallToolResult::success(vec![
|
||||
Content::json(self.interface.metric_to_indexes(param.id)).unwrap(),
|
||||
Content::json(self.query.metric_to_indexes(param.id)).unwrap(),
|
||||
]))
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ The response's format will depend on the given parameters, it will be:
|
||||
fn get_vecs(&self, Parameters(params): Parameters<Params>) -> Result<CallToolResult, McpError> {
|
||||
info!("mcp: get_vecs");
|
||||
Ok(CallToolResult::success(vec![Content::text(
|
||||
match self.interface.search_and_format(params) {
|
||||
match self.query.search_and_format(params) {
|
||||
Ok(output) => output.to_string(),
|
||||
Err(e) => format!("Error:\n{e}"),
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use aide::axum::ApiRouter;
|
||||
use brk_interface::Interface;
|
||||
use brk_query::Query;
|
||||
use brk_rmcp::transport::{
|
||||
StreamableHttpServerConfig,
|
||||
streamable_http_server::{StreamableHttpService, session::local::LocalSessionManager},
|
||||
@@ -10,20 +10,20 @@ use log::info;
|
||||
use crate::MCP;
|
||||
|
||||
pub trait MCPRoutes {
|
||||
fn add_mcp_routes(self, interface: &'static Interface<'static>, mcp: bool) -> Self;
|
||||
fn add_mcp_routes(self, query: &'static Query<'static>, mcp: bool) -> Self;
|
||||
}
|
||||
|
||||
impl<T> MCPRoutes for ApiRouter<T>
|
||||
where
|
||||
T: Clone + Send + Sync + 'static,
|
||||
{
|
||||
fn add_mcp_routes(self, interface: &'static Interface<'static>, mcp: bool) -> Self {
|
||||
fn add_mcp_routes(self, query: &'static Query<'static>, mcp: bool) -> Self {
|
||||
if !mcp {
|
||||
return self;
|
||||
}
|
||||
|
||||
let service = StreamableHttpService::new(
|
||||
move || Ok(MCP::new(interface)),
|
||||
move || Ok(MCP::new(query)),
|
||||
LocalSessionManager::default().into(),
|
||||
StreamableHttpServerConfig {
|
||||
stateful_mode: false,
|
||||
|
||||
@@ -13,7 +13,7 @@ build = "build.rs"
|
||||
bitcoin = { workspace = true }
|
||||
brk_error = { workspace = true }
|
||||
brk_rpc = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
log = { workspace = true }
|
||||
parking_lot = { workspace = true }
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{sync::Arc, thread, time::Duration};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_rpc::Client;
|
||||
use brk_structs::{AddressBytes, AddressMempoolStats, Transaction, Txid};
|
||||
use brk_types::{AddressBytes, AddressMempoolStats, Transaction, Txid};
|
||||
use derive_deref::Deref;
|
||||
use log::error;
|
||||
use parking_lot::{RwLock, RwLockReadGuard};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "brk_interface"
|
||||
name = "brk_query"
|
||||
description = "An interface to find and format data from BRK"
|
||||
license.workspace = true
|
||||
edition.workspace = true
|
||||
@@ -15,7 +15,7 @@ brk_computer = { workspace = true }
|
||||
brk_error = { workspace = true }
|
||||
brk_indexer = { workspace = true }
|
||||
brk_reader = { workspace = true }
|
||||
brk_structs = { workspace = true }
|
||||
brk_types = { workspace = true }
|
||||
brk_traversable = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
# quickmatch = { path = "../../../quickmatch" }
|
||||
@@ -1,9 +1,9 @@
|
||||
# brk_interface
|
||||
# brk_query
|
||||
|
||||
Unified data query and formatting interface for Bitcoin datasets with intelligent search and multi-format output.
|
||||
|
||||
[](https://crates.io/crates/brk_interface)
|
||||
[](https://docs.rs/brk_interface)
|
||||
[](https://crates.io/crates/brk_query)
|
||||
[](https://docs.rs/brk_query)
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -29,13 +29,13 @@ This crate provides a high-level interface for querying and formatting data from
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
cargo add brk_interface
|
||||
cargo add brk_query
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```rust
|
||||
use brk_interface::{Interface, Params, Index};
|
||||
use brk_query::{Interface, Params, Index};
|
||||
use brk_indexer::Indexer;
|
||||
use brk_computer::Computer;
|
||||
|
||||
@@ -102,7 +102,7 @@ Combined search and formatting operation for single-call data retrieval.
|
||||
### Basic Data Query
|
||||
|
||||
```rust
|
||||
use brk_interface::{Interface, Params, Index, Format};
|
||||
use brk_query::{Interface, Params, Index, Format};
|
||||
|
||||
let interface = Interface::build(&indexer, &computer);
|
||||
|
||||
@@ -125,7 +125,7 @@ match interface.search_and_format(params)? {
|
||||
### CSV Export with Range Query
|
||||
|
||||
```rust
|
||||
use brk_interface::{Interface, Params, Index, Format};
|
||||
use brk_query::{Interface, Params, Index, Format};
|
||||
|
||||
// Export price data as CSV
|
||||
let params = Params {
|
||||
@@ -149,7 +149,7 @@ match interface.search_and_format(params)? {
|
||||
### Intelligent Error Handling
|
||||
|
||||
```rust
|
||||
use brk_interface::{Interface, Params, Index};
|
||||
use brk_query::{Interface, Params, Index};
|
||||
|
||||
// Query with typo in vector ID
|
||||
let params = Params {
|
||||
@@ -3,9 +3,9 @@ use std::{fs, path::Path};
|
||||
use brk_computer::Computer;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_interface::{Interface, Params, ParamsOpt};
|
||||
use brk_query::{Params, ParamsOpt, Query};
|
||||
use brk_reader::Reader;
|
||||
use brk_structs::Index;
|
||||
use brk_types::Index;
|
||||
use vecdb::Exit;
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
@@ -35,14 +35,14 @@ pub fn main() -> Result<()> {
|
||||
|
||||
let computer = Computer::forced_import(&outputs_dir, &indexer, None)?;
|
||||
|
||||
let interface = Interface::build(&reader, &indexer, &computer);
|
||||
let query = Query::build(&reader, &indexer, &computer);
|
||||
|
||||
dbg!(interface.search_and_format(Params {
|
||||
dbg!(query.search_and_format(Params {
|
||||
index: Index::Height,
|
||||
metrics: vec!["date"].into(),
|
||||
rest: ParamsOpt::default().set_from(-1),
|
||||
})?);
|
||||
dbg!(interface.search_and_format(Params {
|
||||
dbg!(query.search_and_format(Params {
|
||||
index: Index::Height,
|
||||
metrics: vec!["date", "timestamp"].into(),
|
||||
rest: ParamsOpt::default().set_from(-10).set_count(5),
|
||||
@@ -2,17 +2,17 @@ use std::str::FromStr;
|
||||
|
||||
use bitcoin::{Network, PublicKey, ScriptBuf};
|
||||
use brk_error::{Error, Result};
|
||||
use brk_structs::{
|
||||
use brk_types::{
|
||||
Address, AddressBytes, AddressBytesHash, AddressChainStats, AddressMempoolStats, AddressStats,
|
||||
AnyAddressDataIndexEnum, Bitcoin, OutputType,
|
||||
};
|
||||
use vecdb::{AnyIterableVec, VecIterator};
|
||||
|
||||
use crate::Interface;
|
||||
use crate::Query;
|
||||
|
||||
pub fn get_address(Address { address }: Address, interface: &Interface) -> Result<AddressStats> {
|
||||
let indexer = interface.indexer();
|
||||
let computer = interface.computer();
|
||||
pub fn get_address(Address { address }: Address, query: &Query) -> Result<AddressStats> {
|
||||
let indexer = query.indexer();
|
||||
let computer = query.computer();
|
||||
let stores = &indexer.stores;
|
||||
|
||||
let script = if let Ok(address) = bitcoin::Address::from_str(&address) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user