Config setup
This commit is contained in:
parent
ac91e30db7
commit
add69fecfa
323
Cargo.lock
generated
323
Cargo.lock
generated
@ -118,31 +118,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-wsocket"
|
name = "async-wsocket"
|
||||||
version = "0.5.2"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3445f8f330db8e5f3be7912f170f32e43fec90d995c71ced1ec3b8394b4a873c"
|
checksum = "5725a0615e4eb98e82e9cb963529398114e3fccfbf0e8b9111d605e2ac443e46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"js-sys",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tokio-socks",
|
"tokio-socks",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"url",
|
"url",
|
||||||
"wasm-ws",
|
"wasm-bindgen",
|
||||||
"webpki-roots",
|
"web-sys",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async_io_stream"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c"
|
|
||||||
dependencies = [
|
|
||||||
"futures",
|
|
||||||
"pharos",
|
|
||||||
"rustc_version",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -283,6 +274,9 @@ name = "bitflags"
|
|||||||
version = "2.6.0"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
@ -382,6 +376,55 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "config"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"convert_case",
|
||||||
|
"json5",
|
||||||
|
"lazy_static",
|
||||||
|
"nom",
|
||||||
|
"pathdiff",
|
||||||
|
"ron",
|
||||||
|
"rust-ini",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"toml",
|
||||||
|
"yaml-rust",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-random"
|
||||||
|
version = "0.1.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
|
||||||
|
dependencies = [
|
||||||
|
"const-random-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-random-macro"
|
||||||
|
version = "0.1.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"tiny-keccak",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cookie"
|
name = "cookie"
|
||||||
version = "0.18.1"
|
version = "0.18.1"
|
||||||
@ -426,6 +469,12 @@ version = "0.8.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crunchy"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@ -496,6 +545,15 @@ dependencies = [
|
|||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dlv-list"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
|
||||||
|
dependencies = [
|
||||||
|
"const-random",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.13.0"
|
version = "1.13.0"
|
||||||
@ -603,7 +661,6 @@ checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-executor",
|
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
@ -626,34 +683,12 @@ version = "0.3.30"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-executor"
|
|
||||||
version = "0.3.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
"futures-task",
|
|
||||||
"futures-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-macro"
|
|
||||||
version = "0.3.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-sink"
|
name = "futures-sink"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
@ -675,7 +710,6 @@ dependencies = [
|
|||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-macro",
|
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -772,6 +806,12 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.14.5"
|
version = "0.14.5"
|
||||||
@ -981,7 +1021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown 0.14.5",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1045,6 +1085,17 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "json5"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_derive",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@ -1057,6 +1108,12 @@ version = "0.2.155"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linked-hash-map"
|
||||||
|
version = "0.5.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.14"
|
version = "0.4.14"
|
||||||
@ -1112,7 +1169,7 @@ version = "0.12.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc"
|
checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1136,6 +1193,12 @@ version = "0.3.17"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.7.4"
|
version = "0.7.4"
|
||||||
@ -1182,10 +1245,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "e664971378a3987224f7a0e10059782035e89899ae403718ee07de85bec42afe"
|
checksum = "e664971378a3987224f7a0e10059782035e89899ae403718ee07de85bec42afe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr"
|
name = "nom"
|
||||||
version = "0.33.0"
|
version = "7.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f08db214560a34bf7c4c1fea09a8461b9412bae58ba06e99ce3177d89fa1e0a6"
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nostr"
|
||||||
|
version = "0.34.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5897e4142fcc33c4f1d58ad17f665e87dcba70de7e370c0bda1aa0fb73212c2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
@ -1213,9 +1286,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-database"
|
name = "nostr-database"
|
||||||
version = "0.33.0"
|
version = "0.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9f6c72d0d0842de637f7fba6e70764f719257d29dad8fc5f7352810b0f117ad"
|
checksum = "1926ef55392f3eea1bbe4a1358b64bbf12dd6eb554f40f483941a102c6263fc6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
@ -1228,9 +1301,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-relay-pool"
|
name = "nostr-relay-pool"
|
||||||
version = "0.33.0"
|
version = "0.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "afa5502a3df456790ca16d90cc688a677117d57ab56b079dcfa091390ac9f202"
|
checksum = "c6480cf60564957a2a64bd050d047ee0717e08dced7a389e22ef4e9fc104edd2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"async-wsocket",
|
"async-wsocket",
|
||||||
@ -1239,14 +1312,15 @@ dependencies = [
|
|||||||
"nostr-database",
|
"nostr-database",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tokio-stream",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-sdk"
|
name = "nostr-sdk"
|
||||||
version = "0.33.0"
|
version = "0.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b427dceefbbb49a9dd98abb8c4e40d25fdd467e99821aaad88615252bdb915bd"
|
checksum = "ca0c0c5f8ddbdfc064ea71883191ec53de6ed52b5dca10ab07f0810b99e91acc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"atomic-destructor",
|
"atomic-destructor",
|
||||||
@ -1264,9 +1338,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-signer"
|
name = "nostr-signer"
|
||||||
version = "0.33.0"
|
version = "0.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "665268b316f41cd8fa791be54b6c7935c5a239461708c380a699d6677be9af38"
|
checksum = "5c30294a7be7d9d5ac777954812f5c7b4ae2a1e583a62e33537f87d98ab23729"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@ -1278,9 +1352,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-zapper"
|
name = "nostr-zapper"
|
||||||
version = "0.33.0"
|
version = "0.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "69922e74f8eab1f9d287008c0c06acdec87277a2d8f44bd9d38e003422aea0ab"
|
checksum = "dcf3ba30e807145e9cb924faf8fb0719e460f613088e99c753b67c2a9929c5b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"nostr",
|
"nostr",
|
||||||
@ -1292,6 +1366,7 @@ name = "nostr_services_rs"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"config",
|
||||||
"log",
|
"log",
|
||||||
"nostr",
|
"nostr",
|
||||||
"nostr-database",
|
"nostr-database",
|
||||||
@ -1331,9 +1406,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nwc"
|
name = "nwc"
|
||||||
version = "0.33.0"
|
version = "0.34.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb2e04b3edb5e9572e95b62842430625f1718e8a4a3596a30aeb04e6734764ea"
|
checksum = "9a16ac06bc273fcd4ead47c0c5a58b6cc7db2247fc7a64dd9bc11cf18e3efeb4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"nostr",
|
"nostr",
|
||||||
@ -1364,6 +1439,16 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ordered-multimap"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e"
|
||||||
|
dependencies = [
|
||||||
|
"dlv-list",
|
||||||
|
"hashbrown 0.13.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -1429,6 +1514,12 @@ dependencies = [
|
|||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pathdiff"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbkdf2"
|
name = "pbkdf2"
|
||||||
version = "0.12.2"
|
version = "0.12.2"
|
||||||
@ -1469,13 +1560,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pharos"
|
name = "pest"
|
||||||
version = "0.5.3"
|
version = "2.7.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414"
|
checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"memchr",
|
||||||
"rustc_version",
|
"thiserror",
|
||||||
|
"ucd-trie",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_derive"
|
||||||
|
version = "2.7.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_generator",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_generator"
|
||||||
|
version = "2.7.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183"
|
||||||
|
dependencies = [
|
||||||
|
"pest",
|
||||||
|
"pest_meta",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pest_meta"
|
||||||
|
version = "2.7.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"pest",
|
||||||
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1873,6 +1999,28 @@ dependencies = [
|
|||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ron"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.21.7",
|
||||||
|
"bitflags 2.6.0",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-ini"
|
||||||
|
version = "0.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"ordered-multimap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.24"
|
version = "0.1.24"
|
||||||
@ -2020,12 +2168,6 @@ version = "1.0.23"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "send_wrapper"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.204"
|
version = "1.0.204"
|
||||||
@ -2289,6 +2431,15 @@ dependencies = [
|
|||||||
"time-core",
|
"time-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tiny-keccak"
|
||||||
|
version = "2.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
|
||||||
|
dependencies = [
|
||||||
|
"crunchy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
@ -2559,6 +2710,12 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ucd-trie"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uncased"
|
name = "uncased"
|
||||||
version = "0.9.10"
|
version = "0.9.10"
|
||||||
@ -2590,6 +2747,12 @@ dependencies = [
|
|||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
@ -2723,23 +2886,6 @@ version = "0.2.92"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-ws"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "688c5806d1b06b4f3d90d015e23364dc5d3af412ee64abba6dde8fdc01637e33"
|
|
||||||
dependencies = [
|
|
||||||
"async_io_stream",
|
|
||||||
"futures",
|
|
||||||
"js-sys",
|
|
||||||
"pharos",
|
|
||||||
"send_wrapper",
|
|
||||||
"thiserror",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.69"
|
version = "0.3.69"
|
||||||
@ -2957,6 +3103,15 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "yaml-rust"
|
||||||
|
version = "0.4.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
|
||||||
|
dependencies = [
|
||||||
|
"linked-hash-map",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yansi"
|
name = "yansi"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -5,12 +5,13 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.38.1", features = ["rt", "rt-multi-thread", "macros"] }
|
tokio = { version = "1.38.1", features = ["rt", "rt-multi-thread", "macros"] }
|
||||||
nostr = "0.33.0"
|
nostr = { version = "0.34.0" }
|
||||||
nostr-sdk = { version = "0.33.0" }
|
nostr-sdk = { version = "0.34.0" }
|
||||||
rocket = { version = "0.5.1", features = ["json"] }
|
rocket = { version = "0.5.1", features = ["json"] }
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
nostr-database = { version = "0.33.0", features = ["flatbuf"] }
|
nostr-database = { version = "0.34.0", features = ["flatbuf"] }
|
||||||
sled = "0.34.7"
|
sled = "0.34.7"
|
||||||
|
config = { version = "0.14.0", features = ["toml"] }
|
||||||
|
7
config.toml
Normal file
7
config.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
# List of relays to connect to for fetching data
|
||||||
|
relays = [
|
||||||
|
"wss://relay.snort.social",
|
||||||
|
"wss://relay.damus.io",
|
||||||
|
"wss://nos.lol"
|
||||||
|
]
|
@ -1,8 +1,8 @@
|
|||||||
use nostr::{Event, FromBech32, PublicKey};
|
|
||||||
use nostr::prelude::Nip19;
|
use nostr::prelude::Nip19;
|
||||||
use rocket::{Route, State};
|
use nostr::{Event, FromBech32, PublicKey};
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
|
use rocket::{Route, State};
|
||||||
|
|
||||||
use crate::fetch::FetchQueue;
|
use crate::fetch::FetchQueue;
|
||||||
use crate::store::SledDatabase;
|
use crate::store::SledDatabase;
|
||||||
@ -12,17 +12,14 @@ pub fn routes() -> Vec<Route> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::post("/event", data = "<data>")]
|
#[rocket::post("/event", data = "<data>")]
|
||||||
async fn import_event(
|
async fn import_event(db: &State<SledDatabase>, data: Json<Event>) -> Status {
|
||||||
db: &State<SledDatabase>,
|
|
||||||
data: Json<Event>,
|
|
||||||
) -> Status {
|
|
||||||
if data.verify().is_err() {
|
if data.verify().is_err() {
|
||||||
return Status::InternalServerError;
|
return Status::InternalServerError;
|
||||||
}
|
}
|
||||||
if let Ok(v) = db.save_event(&data).await {
|
if let Ok(v) = db.save_event(&data).await {
|
||||||
match v {
|
match v {
|
||||||
true => Status::Ok,
|
true => Status::Ok,
|
||||||
false => Status::Conflict
|
false => Status::Conflict,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Status::InternalServerError
|
Status::InternalServerError
|
||||||
@ -37,7 +34,7 @@ async fn get_event(
|
|||||||
) -> Option<Json<Event>> {
|
) -> Option<Json<Event>> {
|
||||||
let id = match Nip19::from_bech32(id) {
|
let id = match Nip19::from_bech32(id) {
|
||||||
Ok(i) => i,
|
Ok(i) => i,
|
||||||
_ => return None
|
_ => return None,
|
||||||
};
|
};
|
||||||
match db.event_by_id(&id) {
|
match db.event_by_id(&id) {
|
||||||
Ok(ev) => Some(Json::from(ev)),
|
Ok(ev) => Some(Json::from(ev)),
|
||||||
@ -45,24 +42,20 @@ async fn get_event(
|
|||||||
let mut fetch = fetch.inner().clone();
|
let mut fetch = fetch.inner().clone();
|
||||||
match fetch.demand(&id).await.await {
|
match fetch.demand(&id).await.await {
|
||||||
Ok(Some(ev)) => Some(Json::from(ev)),
|
Ok(Some(ev)) => Some(Json::from(ev)),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::get("/event/<kind>/<pubkey>")]
|
#[rocket::get("/event/<kind>/<pubkey>")]
|
||||||
fn get_event_by_kind(
|
fn get_event_by_kind(db: &State<SledDatabase>, kind: u32, pubkey: &str) -> Option<Json<Event>> {
|
||||||
db: &State<SledDatabase>,
|
|
||||||
kind: u32,
|
|
||||||
pubkey: &str,
|
|
||||||
) -> Option<Json<Event>> {
|
|
||||||
let pk = match PublicKey::parse(pubkey) {
|
let pk = match PublicKey::parse(pubkey) {
|
||||||
Ok(i) => i,
|
Ok(i) => i,
|
||||||
_ => return None
|
_ => return None,
|
||||||
};
|
};
|
||||||
match db.event_by_kind_pubkey(kind, &pk) {
|
match db.event_by_kind_pubkey(kind, &pk) {
|
||||||
Ok(ev) => Some(Json::from(ev)),
|
Ok(ev) => Some(Json::from(ev)),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
18
src/fetch.rs
18
src/fetch.rs
@ -2,10 +2,10 @@ use std::collections::VecDeque;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use nostr::{Event, Filter, Url};
|
|
||||||
use nostr::prelude::Nip19;
|
use nostr::prelude::Nip19;
|
||||||
|
use nostr::{Event, Filter, Url};
|
||||||
use nostr_sdk::{FilterOptions, RelayOptions, RelayPool};
|
use nostr_sdk::{FilterOptions, RelayOptions, RelayPool};
|
||||||
use tokio::sync::{Mutex, oneshot};
|
use tokio::sync::{oneshot, Mutex};
|
||||||
|
|
||||||
struct QueueItem {
|
struct QueueItem {
|
||||||
pub handler: oneshot::Sender<Option<Event>>,
|
pub handler: oneshot::Sender<Option<Event>>,
|
||||||
@ -28,7 +28,10 @@ impl FetchQueue {
|
|||||||
|
|
||||||
pub async fn add_relay(&mut self, relay: Url) -> Result<bool, anyhow::Error> {
|
pub async fn add_relay(&mut self, relay: Url) -> Result<bool, anyhow::Error> {
|
||||||
let pool_lock = self.pool.lock().await;
|
let pool_lock = self.pool.lock().await;
|
||||||
pool_lock.add_relay(relay.clone(), RelayOptions::default()).await.unwrap();
|
pool_lock
|
||||||
|
.add_relay(relay.clone(), RelayOptions::default())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
if let Err(e) = pool_lock.connect_relay(relay, None).await {
|
if let Err(e) = pool_lock.connect_relay(relay, None).await {
|
||||||
Err(anyhow::Error::new(e))
|
Err(anyhow::Error::new(e))
|
||||||
} else {
|
} else {
|
||||||
@ -53,7 +56,10 @@ impl FetchQueue {
|
|||||||
let pool_lock = self.pool.lock().await;
|
let pool_lock = self.pool.lock().await;
|
||||||
let filters = vec![Self::nip19_to_filter(&q.request).unwrap()];
|
let filters = vec![Self::nip19_to_filter(&q.request).unwrap()];
|
||||||
//info!("Sending filters: {:?}", filters);
|
//info!("Sending filters: {:?}", filters);
|
||||||
if let Ok(evs) = pool_lock.get_events_of(filters, Duration::from_secs(5), FilterOptions::ExitOnEOSE).await {
|
if let Ok(evs) = pool_lock
|
||||||
|
.get_events_of(filters, Duration::from_secs(5), FilterOptions::ExitOnEOSE)
|
||||||
|
.await
|
||||||
|
{
|
||||||
if let Some(e) = evs.first() {
|
if let Some(e) = evs.first() {
|
||||||
q.handler.send(Some(e.clone())).unwrap();
|
q.handler.send(Some(e.clone())).unwrap();
|
||||||
} else {
|
} else {
|
||||||
@ -68,9 +74,7 @@ impl FetchQueue {
|
|||||||
fn nip19_to_filter(filter: &Nip19) -> Option<Filter> {
|
fn nip19_to_filter(filter: &Nip19) -> Option<Filter> {
|
||||||
match filter {
|
match filter {
|
||||||
Nip19::Coordinate(c) => Some(Filter::from(c)),
|
Nip19::Coordinate(c) => Some(Filter::from(c)),
|
||||||
Nip19::Event(e) => Some(Filter::new()
|
Nip19::Event(e) => Some(Filter::new().id(e.event_id)),
|
||||||
.id(e.event_id)
|
|
||||||
),
|
|
||||||
Nip19::EventId(e) => Some(Filter::new().id(*e)),
|
Nip19::EventId(e) => Some(Filter::new().id(*e)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
18
src/main.rs
18
src/main.rs
@ -4,23 +4,37 @@ extern crate rocket;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
use config::Config;
|
||||||
use rocket::shield::Shield;
|
use rocket::shield::Shield;
|
||||||
|
|
||||||
use crate::fetch::FetchQueue;
|
use crate::fetch::FetchQueue;
|
||||||
|
use crate::settings::Settings;
|
||||||
use crate::store::SledDatabase;
|
use crate::store::SledDatabase;
|
||||||
|
|
||||||
mod events;
|
mod events;
|
||||||
mod store;
|
|
||||||
mod fetch;
|
mod fetch;
|
||||||
|
mod store;
|
||||||
|
mod settings;
|
||||||
|
|
||||||
#[rocket::main]
|
#[rocket::main]
|
||||||
async fn main() -> Result<(), Error> {
|
async fn main() -> Result<(), Error> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
let builder = Config::builder()
|
||||||
|
.add_source(config::File::with_name("config.toml"))
|
||||||
|
.add_source(config::Environment::with_prefix("APP"))
|
||||||
|
.build()?;
|
||||||
|
|
||||||
|
let settings: Settings = builder.try_deserialize()?;
|
||||||
|
|
||||||
let db = SledDatabase::new("nostr.db");
|
let db = SledDatabase::new("nostr.db");
|
||||||
|
|
||||||
let mut fetch = FetchQueue::new();
|
let mut fetch = FetchQueue::new();
|
||||||
fetch.add_relay("wss://relay.snort.social".parse().unwrap()).await.unwrap();
|
for x in settings.relays
|
||||||
|
{
|
||||||
|
fetch.add_relay(x).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let fetch2 = fetch.clone();
|
let fetch2 = fetch.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
8
src/settings.rs
Normal file
8
src/settings.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
use nostr_sdk::Url;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Settings {
|
||||||
|
/// List of relays to connect to for fetching data
|
||||||
|
pub relays: Vec<Url>
|
||||||
|
}
|
40
src/store.rs
40
src/store.rs
@ -1,9 +1,9 @@
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use nostr::{Event, EventId, PublicKey};
|
|
||||||
use nostr::prelude::Nip19;
|
use nostr::prelude::Nip19;
|
||||||
use nostr::util::hex;
|
use nostr::util::hex;
|
||||||
|
use nostr::{Event, EventId, PublicKey};
|
||||||
use nostr_database::{FlatBufferBuilder, FlatBufferDecode, FlatBufferEncode};
|
use nostr_database::{FlatBufferBuilder, FlatBufferDecode, FlatBufferEncode};
|
||||||
use sled::{Db, IVec};
|
use sled::{Db, IVec};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
@ -53,18 +53,20 @@ impl SledDatabase {
|
|||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
Err(e) => Err(anyhow::Error::new(e)),
|
Err(e) => Err(anyhow::Error::new(e)),
|
||||||
Ok(v) => {
|
Ok(v) => match v {
|
||||||
match v {
|
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
info!("Wrote index {} = {}", hex::encode(rpk), hex::encode(v.as_ref()));
|
info!(
|
||||||
|
"Wrote index {} = {}",
|
||||||
|
hex::encode(rpk),
|
||||||
|
hex::encode(v.as_ref())
|
||||||
|
);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
info!("Duplicate or older index {}", hex::encode(rpk));
|
info!("Duplicate or older index {}", hex::encode(rpk));
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,30 +92,32 @@ impl SledDatabase {
|
|||||||
let id_key = match event_id {
|
let id_key = match event_id {
|
||||||
Nip19::EventId(e) => e.as_bytes(),
|
Nip19::EventId(e) => e.as_bytes(),
|
||||||
Nip19::Event(e) => e.event_id.as_bytes(),
|
Nip19::Event(e) => e.event_id.as_bytes(),
|
||||||
_ => return Err(anyhow::Error::msg("Not supported ID format"))
|
_ => return Err(anyhow::Error::msg("Not supported ID format")),
|
||||||
};
|
};
|
||||||
match self.db.get(id_key) {
|
match self.db.get(id_key) {
|
||||||
Ok(v) => match v {
|
Ok(v) => match v {
|
||||||
Some(v) => match Event::decode(&v) {
|
Some(v) => match Event::decode(&v) {
|
||||||
Ok(v) => Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(e) => Err(anyhow::Error::new(e))
|
Err(e) => Err(anyhow::Error::new(e)),
|
||||||
},
|
},
|
||||||
None => Err(anyhow::Error::msg("Not Found"))
|
None => Err(anyhow::Error::msg("Not Found")),
|
||||||
}
|
},
|
||||||
Err(e) => Err(anyhow::Error::new(e))
|
Err(e) => Err(anyhow::Error::new(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn event_by_kind_pubkey(&self, kind: u32, pubkey: &PublicKey) -> Result<Event, anyhow::Error> {
|
pub fn event_by_kind_pubkey(
|
||||||
|
&self,
|
||||||
|
kind: u32,
|
||||||
|
pubkey: &PublicKey,
|
||||||
|
) -> Result<Event, anyhow::Error> {
|
||||||
let rpk = Self::replaceable_index_key(kind, pubkey);
|
let rpk = Self::replaceable_index_key(kind, pubkey);
|
||||||
match self.db.get(rpk) {
|
match self.db.get(rpk) {
|
||||||
Ok(v) => match v {
|
Ok(v) => match v {
|
||||||
Some(v) => {
|
Some(v) => self.event_by_id(&Nip19::EventId(EventId::from_slice(v[8..].as_ref())?)),
|
||||||
self.event_by_id(&Nip19::EventId(EventId::from_slice(v[8..].as_ref())?))
|
None => Err(anyhow::Error::msg("Not Found")),
|
||||||
}
|
},
|
||||||
None => Err(anyhow::Error::msg("Not Found"))
|
Err(e) => Err(anyhow::Error::new(e)),
|
||||||
}
|
|
||||||
Err(e) => Err(anyhow::Error::new(e))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user