feat(swap): Start wallets and tor client in parallel (#198)

CLI + GUI: At startup the wallets and tor client are started in parallel. This will speed up the startup time of the application.
This commit is contained in:
binarybaron 2024-11-21 01:51:19 +01:00 committed by GitHub
parent 6cd228fada
commit 689dd89e72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 386 additions and 289 deletions

View File

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- CLI + GUI: Tor is now bundled with the application. All libp2p connections between peers are routed through Tor, if the `--enable-tor` flag is set. The `--tor-socks5-port` argument has been removed. This feature is powered by [arti](https://tpo.pages.torproject.net/core/arti/), an implementation of the Tor protocol in Rust by the Tor Project.
- CLI + GUI: At startup the wallets and tor client are started in parallel. This will speed up the startup time of the application.
## [1.0.0-rc.5] - 2024-11-19

293
Cargo.lock generated
View File

@ -1081,26 +1081,25 @@ dependencies = [
[[package]]
name = "borsh"
version = "1.3.0"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d4d6dafc1a3bb54687538972158f07b2c948bc57d5890df22c0739098b3028"
checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03"
dependencies = [
"borsh-derive",
"cfg_aliases 0.1.1",
"cfg_aliases",
]
[[package]]
name = "borsh-derive"
version = "1.3.0"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0"
checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244"
dependencies = [
"once_cell",
"proc-macro-crate 2.0.0",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.87",
"syn_derive",
]
[[package]]
@ -1207,9 +1206,9 @@ dependencies = [
[[package]]
name = "bytemuck"
version = "1.19.0"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d"
checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a"
[[package]]
name = "byteorder"
@ -1379,12 +1378,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "cfg_aliases"
version = "0.2.1"
@ -1909,9 +1902,9 @@ dependencies = [
[[package]]
name = "ctor"
version = "0.2.8"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f"
checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501"
dependencies = [
"quote",
"syn 2.0.87",
@ -2161,17 +2154,6 @@ dependencies = [
"serde",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "derive-deftly"
version = "0.14.2"
@ -2191,7 +2173,7 @@ dependencies = [
"heck 0.5.0",
"indexmap 2.6.0",
"itertools",
"proc-macro-crate 2.0.0",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"sha3 0.10.8",
@ -3068,7 +3050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb"
dependencies = [
"futures-io",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pki-types",
]
@ -3507,9 +3489,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.4.6"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205"
checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e"
dependencies = [
"atomic-waker",
"bytes",
@ -3767,7 +3749,7 @@ checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
dependencies = [
"bytes",
"fnv",
"itoa 1.0.11",
"itoa 1.0.13",
]
[[package]]
@ -3778,7 +3760,7 @@ checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
dependencies = [
"bytes",
"fnv",
"itoa 1.0.11",
"itoa 1.0.13",
]
[[package]]
@ -3864,7 +3846,7 @@ dependencies = [
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa 1.0.11",
"itoa 1.0.13",
"pin-project-lite",
"socket2",
"tokio",
@ -3875,19 +3857,19 @@ dependencies = [
[[package]]
name = "hyper"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.6",
"h2 0.4.7",
"http 1.1.0",
"http-body 1.0.1",
"httparse",
"httpdate",
"itoa 1.0.11",
"itoa 1.0.13",
"pin-project-lite",
"smallvec",
"tokio",
@ -3902,9 +3884,9 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333"
dependencies = [
"futures-util",
"http 1.1.0",
"hyper 1.5.0",
"hyper 1.5.1",
"hyper-util",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.26.0",
@ -3923,7 +3905,7 @@ dependencies = [
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"hyper 1.5.0",
"hyper 1.5.1",
"pin-project-lite",
"socket2",
"tokio",
@ -4131,9 +4113,9 @@ dependencies = [
[[package]]
name = "if-watch"
version = "3.2.0"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e"
checksum = "cdf9d64cfcf380606e64f9a0bcf493616b65331199f984151a6fa11a7b3cde38"
dependencies = [
"async-io",
"core-foundation 0.9.4",
@ -4142,10 +4124,14 @@ dependencies = [
"if-addrs",
"ipnet",
"log",
"netlink-packet-core",
"netlink-packet-route",
"netlink-proto",
"netlink-sys",
"rtnetlink",
"system-configuration",
"tokio",
"windows 0.51.1",
"windows 0.53.0",
]
[[package]]
@ -4324,9 +4310,9 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "itoa"
version = "1.0.11"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
[[package]]
name = "javascriptcore-rs"
@ -4659,9 +4645,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.162"
version = "0.2.164"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
[[package]]
name = "libgit2-sys"
@ -4868,9 +4854,9 @@ dependencies = [
[[package]]
name = "libp2p-identity"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8"
checksum = "257b5621d159b32282eac446bed6670c39c7dc68a200a992d8f056afa0066f6d"
dependencies = [
"asn1_der",
"bs58",
@ -5016,7 +5002,7 @@ dependencies = [
"quinn",
"rand 0.8.5",
"ring 0.17.8",
"rustls 0.23.16",
"rustls 0.23.17",
"socket2",
"thiserror 1.0.69",
"tokio",
@ -5154,7 +5140,7 @@ dependencies = [
"libp2p-identity",
"rcgen",
"ring 0.17.8",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-webpki 0.101.7",
"thiserror 1.0.69",
"x509-parser 0.16.0",
@ -5189,7 +5175,7 @@ dependencies = [
"thiserror 1.0.69",
"tracing",
"yamux 0.12.1",
"yamux 0.13.3",
"yamux 0.13.4",
]
[[package]]
@ -5448,7 +5434,7 @@ dependencies = [
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.5.0",
"hyper 1.5.1",
"hyper-util",
"log",
"rand 0.8.5",
@ -5641,21 +5627,20 @@ dependencies = [
[[package]]
name = "netlink-packet-core"
version = "0.4.2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297"
checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4"
dependencies = [
"anyhow",
"byteorder",
"libc",
"netlink-packet-utils",
]
[[package]]
name = "netlink-packet-route"
version = "0.12.0"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab"
checksum = "053998cea5a306971f88580d0829e90f270f940befd7cf928da179d4187a5a66"
dependencies = [
"anyhow",
"bitflags 1.3.2",
@ -5679,9 +5664,9 @@ dependencies = [
[[package]]
name = "netlink-proto"
version = "0.10.0"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6"
checksum = "86b33524dc0968bfad349684447bfce6db937a9ac3332a1fe60c0c5a5ce63f21"
dependencies = [
"bytes",
"futures",
@ -5713,9 +5698,9 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.24.3"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags 1.3.2",
"cfg-if",
@ -5724,12 +5709,13 @@ dependencies = [
[[package]]
name = "nix"
version = "0.27.1"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.6.0",
"cfg-if",
"cfg_aliases",
"libc",
"memoffset",
]
@ -5890,7 +5876,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 2.0.0",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.87",
@ -6796,7 +6782,16 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [
"toml_edit 0.20.2",
"toml_edit 0.20.7",
]
[[package]]
name = "proc-macro-crate"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
dependencies = [
"toml_edit 0.22.22",
]
[[package]]
@ -6845,7 +6840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca"
dependencies = [
"dtoa",
"itoa 1.0.11",
"itoa 1.0.13",
"parking_lot 0.12.3",
"prometheus-client-derive-encode",
]
@ -6984,7 +6979,7 @@ dependencies = [
"quinn-proto",
"quinn-udp",
"rustc-hash 2.0.0",
"rustls 0.23.16",
"rustls 0.23.17",
"socket2",
"thiserror 2.0.3",
"tokio",
@ -7002,7 +6997,7 @@ dependencies = [
"rand 0.8.5",
"ring 0.17.8",
"rustc-hash 2.0.0",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pki-types",
"slab",
"thiserror 2.0.3",
@ -7017,7 +7012,7 @@ version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da"
dependencies = [
"cfg_aliases 0.2.1",
"cfg_aliases",
"libc",
"once_cell",
"socket2",
@ -7269,11 +7264,11 @@ dependencies = [
"bytes",
"futures-core",
"futures-util",
"h2 0.4.6",
"h2 0.4.7",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.5.0",
"hyper 1.5.1",
"hyper-rustls",
"hyper-util",
"ipnet",
@ -7284,7 +7279,7 @@ dependencies = [
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pemfile 2.2.0",
"rustls-pki-types",
"serde",
@ -7413,15 +7408,18 @@ dependencies = [
[[package]]
name = "rtnetlink"
version = "0.10.1"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0"
checksum = "7a552eb82d19f38c3beed3f786bd23aa434ceb9ac43ab44419ca6d67a7e186c0"
dependencies = [
"futures",
"log",
"netlink-packet-core",
"netlink-packet-route",
"netlink-packet-utils",
"netlink-proto",
"nix 0.24.3",
"netlink-sys",
"nix 0.26.4",
"thiserror 1.0.69",
"tokio",
]
@ -7511,9 +7509,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.40"
version = "0.38.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6"
dependencies = [
"bitflags 2.6.0",
"errno",
@ -7561,9 +7559,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.23.16"
version = "0.23.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e"
checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e"
dependencies = [
"log",
"once_cell",
@ -7715,18 +7713,18 @@ dependencies = [
[[package]]
name = "scc"
version = "2.2.4"
version = "2.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8"
checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed"
dependencies = [
"sdd",
]
[[package]]
name = "schannel"
version = "0.1.26"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1"
checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d"
dependencies = [
"windows-sys 0.59.0",
]
@ -8029,11 +8027,11 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.132"
version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
dependencies = [
"itoa 1.0.11",
"itoa 1.0.13",
"memchr",
"ryu",
"serde",
@ -8066,7 +8064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa 1.0.11",
"itoa 1.0.13",
"ryu",
"serde",
]
@ -8446,7 +8444,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08"
dependencies = [
"bytemuck",
"cfg_aliases 0.2.1",
"cfg_aliases",
"core-graphics 0.24.0",
"foreign-types",
"js-sys",
@ -8578,7 +8576,7 @@ dependencies = [
"once_cell",
"paste",
"percent-encoding",
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pemfile 2.2.0",
"serde",
"serde_json",
@ -8655,7 +8653,7 @@ dependencies = [
"hex",
"hkdf",
"hmac 0.12.1",
"itoa 1.0.11",
"itoa 1.0.13",
"log",
"md-5",
"memchr",
@ -8695,7 +8693,7 @@ dependencies = [
"hkdf",
"hmac 0.12.1",
"home",
"itoa 1.0.11",
"itoa 1.0.13",
"log",
"md-5",
"memchr",
@ -9017,23 +9015,11 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn_derive"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"
dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "sync_wrapper"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
dependencies = [
"futures-core",
]
@ -9077,20 +9063,20 @@ dependencies = [
[[package]]
name = "system-configuration"
version = "0.5.1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.6.0",
"core-foundation 0.9.4",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
@ -9662,7 +9648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
dependencies = [
"deranged",
"itoa 1.0.11",
"itoa 1.0.13",
"libc",
"num-conv",
"num_threads",
@ -9778,7 +9764,7 @@ version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
dependencies = [
"rustls 0.23.16",
"rustls 0.23.17",
"rustls-pki-types",
"tokio",
]
@ -9900,9 +9886,9 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.20.2"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [
"indexmap 2.6.0",
"toml_datetime",
@ -11138,9 +11124,9 @@ checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893"
[[package]]
name = "unicode-ident"
version = "1.0.13"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "unicode-normalization"
@ -11764,12 +11750,12 @@ dependencies = [
[[package]]
name = "windows"
version = "0.51.1"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9"
checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538"
dependencies = [
"windows-core 0.51.1",
"windows-targets 0.48.5",
"windows-core 0.53.0",
"windows-targets 0.52.6",
]
[[package]]
@ -11792,15 +11778,6 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-core"
version = "0.52.0"
@ -11810,6 +11787,16 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dcc5b895a6377f1ab9fa55acedab1fd5ac0db66ad1e6c7f47e28a22e446a5dd"
dependencies = [
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-core"
version = "0.57.0"
@ -12193,9 +12180,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "wry"
version = "0.47.0"
version = "0.47.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "553ca1ce149982123962fac2506aa75b8b76288779a77e72b12fa2fc34938647"
checksum = "61ce51277d65170f6379d8cda935c80e3c2d1f0ff712a123c8bddb11b31a4b73"
dependencies = [
"base64 0.22.1",
"block2",
@ -12390,9 +12377,9 @@ dependencies = [
[[package]]
name = "yamux"
version = "0.13.3"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31b5e376a8b012bee9c423acdbb835fc34d45001cfa3106236a624e4b738028"
checksum = "17610762a1207ee816c6fadc29220904753648aba0a9ed61c7b8336e80a559c4"
dependencies = [
"futures",
"log",
@ -12439,9 +12426,9 @@ dependencies = [
[[package]]
name = "zbus"
version = "4.0.1"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b8e3d6ae3342792a6cc2340e4394334c7402f3d793b390d2c5494a4032b3030"
checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"
dependencies = [
"async-broadcast",
"async-executor",
@ -12453,14 +12440,13 @@ dependencies = [
"async-task",
"async-trait",
"blocking",
"derivative",
"enumflags2",
"event-listener 5.3.1",
"futures-core",
"futures-sink",
"futures-util",
"hex",
"nix 0.27.1",
"nix 0.29.0",
"ordered-stream",
"rand 0.8.5",
"serde",
@ -12478,15 +12464,14 @@ dependencies = [
[[package]]
name = "zbus_macros"
version = "4.0.1"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7a3e850ff1e7217a3b7a07eba90d37fe9bb9e89a310f718afcde5885ca9b6d7"
checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"regex",
"syn 1.0.109",
"syn 2.0.87",
"zvariant_utils",
]
@ -12616,9 +12601,9 @@ dependencies = [
[[package]]
name = "zvariant"
version = "4.0.0"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e09e8be97d44eeab994d752f341e67b3b0d80512a8b315a0671d47232ef1b65"
checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"
dependencies = [
"endi",
"enumflags2",
@ -12629,24 +12614,24 @@ dependencies = [
[[package]]
name = "zvariant_derive"
version = "4.0.0"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a5857e2856435331636a9fbb415b09243df4521a267c5bedcd5289b4d5799e"
checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.87",
"zvariant_utils",
]
[[package]]
name = "zvariant_utils"
version = "1.1.0"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00bedb16a193cc12451873fee2a1bc6550225acece0e36f333e68326c73c8172"
checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.87",
]

View File

@ -1,11 +1,11 @@
import { Box, Button, LinearProgress, makeStyles } from "@material-ui/core";
import { Alert } from "@material-ui/lab";
import { TauriContextInitializationProgress } from "models/tauriModel";
import { useNavigate } from "react-router-dom";
import { useAppSelector } from "store/hooks";
import { exhaustiveGuard } from "utils/typescriptUtils";
import { LoadingSpinnerAlert } from "./LoadingSpinnerAlert";
import { bytesToMb } from "utils/conversionUtils";
import { TauriPartialInitProgress } from "models/tauriModel";
const useStyles = makeStyles((theme) => ({
innerAlert: {
@ -15,56 +15,75 @@ const useStyles = makeStyles((theme) => ({
},
}));
function PartialInitStatus({ status, classes }: {
status: TauriPartialInitProgress,
classes: ReturnType<typeof useStyles>
}) {
if (status.progress.type === "Completed") {
return null;
}
switch (status.componentName) {
case "OpeningBitcoinWallet":
return (
<LoadingSpinnerAlert severity="warning">
Syncing internal Bitcoin wallet
</LoadingSpinnerAlert>
);
case "DownloadingMoneroWalletRpc":
return (
<LoadingSpinnerAlert severity="warning">
<Box className={classes.innerAlert}>
<Box>
Downloading and verifying the Monero wallet RPC (
{bytesToMb(status.progress.content.size).toFixed(2)} MB)
</Box>
<LinearProgress variant="determinate" value={status.progress.content.progress} />
</Box>
</LoadingSpinnerAlert>
);
case "OpeningMoneroWallet":
return (
<LoadingSpinnerAlert severity="warning">
Opening the Monero wallet
</LoadingSpinnerAlert>
);
case "OpeningDatabase":
return (
<LoadingSpinnerAlert severity="warning">
Opening the local database
</LoadingSpinnerAlert>
);
case "EstablishingTorCircuits":
return (
<LoadingSpinnerAlert severity="warning">
Establishing Tor circuits
</LoadingSpinnerAlert>
)
default:
return null;
}
}
export default function DaemonStatusAlert() {
const classes = useStyles();
const contextStatus = useAppSelector((s) => s.rpc.status);
const navigate = useNavigate();
if (contextStatus === null) {
if (contextStatus === null || contextStatus.type === "NotInitialized") {
return <LoadingSpinnerAlert severity="warning">Checking for available remote nodes</LoadingSpinnerAlert>;
}
switch (contextStatus.type) {
case "Initializing":
switch (contextStatus.content.type) {
case "OpeningBitcoinWallet":
return (
<LoadingSpinnerAlert severity="warning">
Connecting to the Bitcoin network
</LoadingSpinnerAlert>
);
case "DownloadingMoneroWalletRpc":
return (
<LoadingSpinnerAlert severity="warning">
<Box className={classes.innerAlert}>
<Box>
Downloading and verifying the Monero wallet RPC (
{bytesToMb(contextStatus.content.content.size).toFixed(2)} MB)
</Box>
<LinearProgress variant="determinate" value={contextStatus.content.content.progress} />
</Box>
</LoadingSpinnerAlert >
);
case "OpeningMoneroWallet":
return (
<LoadingSpinnerAlert severity="warning">
Connecting to the Monero network
</LoadingSpinnerAlert>
);
case "OpeningDatabase":
return (
<LoadingSpinnerAlert severity="warning">
Opening the local database
</LoadingSpinnerAlert>
);
case "EstablishingTorCircuits":
return (
<LoadingSpinnerAlert severity="warning">
Connecting to the Tor network
</LoadingSpinnerAlert>
);
}
break;
return contextStatus.content
.map((status) => (
<PartialInitStatus
key={status.componentName}
status={status}
classes={classes}
/>
))
case "Available":
return <Alert severity="success">The daemon is running</Alert>;
case "Failed":

View File

@ -69,10 +69,26 @@ export const rpcSlice = createSlice({
slice,
action: PayloadAction<TauriContextStatusEvent>,
) {
slice.status = action.payload;
// If we are already initializing, and we receive a new partial status, we update the existing status
if (slice.status?.type === "Initializing" && action.payload.type === "Initializing") {
for (const partialStatus of action.payload.content) {
// We find the existing status with the same type
const existingStatus = slice.status.content.find(s => s.componentName === partialStatus.componentName);
if (existingStatus) {
// If we find it, we update the content
existingStatus.progress = partialStatus.progress;
} else {
// Otherwise, we add the new partial status
slice.status.content.push(partialStatus);
}
}
} else {
// Otherwise, we replace the whole status
slice.status = action.payload;
}
},
timelockChangeEventReceived(
slice,
slice: RPCSlice,
action: PayloadAction<TauriTimelockChangeEvent>
) {
if (slice.state.swapInfos[action.payload.swap_id]) {

View File

@ -19,7 +19,7 @@ use std::future::Future;
use std::path::PathBuf;
use std::sync::{Arc, Mutex as SyncMutex, Once};
use tauri_bindings::{
TauriContextInitializationProgress, TauriContextStatusEvent, TauriEmitter, TauriHandle,
PendingCompleted, TauriContextStatusEvent, TauriEmitter, TauriHandle, TauriPartialInitProgress,
};
use tokio::sync::{broadcast, broadcast::Sender, Mutex as TokioMutex, RwLock};
use tokio::task::JoinHandle;
@ -282,9 +282,13 @@ impl ContextBuilder {
/// Takes the builder, initializes the context by initializing the wallets and other components and returns the Context.
pub async fn build(self) -> Result<Context> {
// These are needed for everything else, and are blocking calls
let data_dir = data::data_dir_from(self.data, self.is_testnet)?;
let env_config = env_config_from(self.is_testnet);
let seed = Seed::from_file_or_generate(data_dir.as_path())
.context("Failed to read seed in file")?;
// Initialize logging
let format = if self.json { Format::Json } else { Format::Raw };
let level_filter = if self.debug {
LevelFilter::from_level(Level::DEBUG)
@ -301,26 +305,15 @@ impl ContextBuilder {
);
});
let seed = Seed::from_file_or_generate(data_dir.as_path())
.context("Failed to read seed in file")?;
// Create the data structure we use to manage the swap lock
let swap_lock = Arc::new(SwapLock::new());
let tasks = PendingTaskList::default().into();
// We initialize the Bitcoin wallet below
// To display the progress to the user, we emit events to the Tauri frontend
// Initialize the database
self.tauri_handle
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::OpeningBitcoinWallet,
));
let bitcoin_wallet = if let Some(bitcoin) = self.bitcoin {
let (url, target_block) = bitcoin.apply_defaults(self.is_testnet)?;
Some(Arc::new(
init_bitcoin_wallet(url, &seed, data_dir.clone(), env_config, target_block).await?,
))
} else {
None
};
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningDatabase(PendingCompleted::Pending(())),
]));
let db = open_db(
data_dir.join("sqlite"),
@ -329,39 +322,112 @@ impl ContextBuilder {
)
.await?;
// We initialize the Monero wallet below
// To display the progress to the user, we emit events to the Tauri frontend
self.tauri_handle
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::OpeningMoneroWallet,
));
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningDatabase(PendingCompleted::Completed),
]));
let (monero_wallet, monero_rpc_process) = {
if let Some(monero) = self.monero {
let monero_daemon_address = monero.apply_defaults(self.is_testnet);
let (wlt, prc) = init_monero_wallet(
data_dir.clone(),
monero_daemon_address,
env_config,
self.tauri_handle.clone(),
)
.await?;
// Initialize these components concurrently
let initialize_bitcoin_wallet = async {
match self.bitcoin {
Some(bitcoin) => {
let (url, target_block) = bitcoin.apply_defaults(self.is_testnet)?;
(Some(Arc::new(wlt)), Some(Arc::new(SyncMutex::new(prc))))
} else {
(None, None)
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningBitcoinWallet(
PendingCompleted::Pending(()),
),
]),
);
let wallet =
init_bitcoin_wallet(url, &seed, data_dir.clone(), env_config, target_block)
.await?;
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningBitcoinWallet(
PendingCompleted::Completed,
),
]),
);
Ok::<std::option::Option<Arc<bitcoin::wallet::Wallet>>, Error>(Some(Arc::new(
wallet,
)))
}
None => Ok(None),
}
};
// We initialize the Database below
// To display the progress to the user, we emit events to the Tauri frontend
self.tauri_handle
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::OpeningDatabase,
));
let initialize_monero_wallet = async {
match self.monero {
Some(monero) => {
let monero_daemon_address = monero.apply_defaults(self.is_testnet);
// If we are connected to the Bitcoin blockchain and if there is a handle to Tauri present,
// we start a background task to watch for timelock changes.
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningMoneroWallet(
PendingCompleted::Pending(()),
),
]),
);
let (wlt, prc) = init_monero_wallet(
data_dir.clone(),
monero_daemon_address,
env_config,
self.tauri_handle.clone(),
)
.await?;
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningMoneroWallet(
PendingCompleted::Completed,
),
]),
);
Ok((Some(Arc::new(wlt)), Some(Arc::new(SyncMutex::new(prc)))))
}
None => Ok((None, None)),
}
};
let initialize_tor_client = async {
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::EstablishingTorCircuits(
PendingCompleted::Pending(()),
),
]),
);
let maybe_tor_client = init_tor_client(&data_dir)
.await
.inspect_err(|err| {
tracing::warn!(%err, "Failed to create Tor client. We will continue without Tor");
})
.ok();
self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::EstablishingTorCircuits(PendingCompleted::Completed),
]),
);
Ok(maybe_tor_client)
};
let (bitcoin_wallet, (monero_wallet, monero_rpc_process), tor) = tokio::try_join!(
initialize_bitcoin_wallet,
initialize_monero_wallet,
initialize_tor_client,
)?;
// If we have a bitcoin wallet and a tauri handle, we start a background task
if let Some(wallet) = bitcoin_wallet.clone() {
if self.tauri_handle.is_some() {
let watcher = Watcher::new(
@ -375,20 +441,7 @@ impl ContextBuilder {
}
self.tauri_handle
.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::EstablishingTorCircuits,
));
let tor = if self.tor {
init_tor_client(&data_dir)
.await
.inspect_err(|err| {
tracing::error!(%err, "Failed to establish Tor client");
})
.ok()
} else {
None
};
.emit_context_init_progress_event(TauriContextStatusEvent::Available);
let context = Context {
db,
@ -398,14 +451,14 @@ impl ContextBuilder {
config: Config {
namespace: XmrBtcNamespace::from_is_testnet(self.is_testnet),
env_config,
seed: Some(seed),
seed: seed.into(),
debug: self.debug,
json: self.json,
is_testnet: self.is_testnet,
data_dir,
},
swap_lock,
tasks: Arc::new(PendingTaskList::default()),
tasks,
tauri_handle: self.tauri_handle,
tor_client: tor,
};
@ -431,15 +484,15 @@ impl Context {
let config = Config::for_harness(seed, env_config);
Self {
bitcoin_wallet: Some(bob_bitcoin_wallet),
monero_wallet: Some(bob_monero_wallet),
bitcoin_wallet: bob_bitcoin_wallet.into(),
monero_wallet: bob_monero_wallet.into(),
config,
db: open_db(db_path, AccessMode::ReadWrite, None)
.await
.expect("Could not open sqlite database"),
monero_rpc_process: None,
swap_lock: Arc::new(SwapLock::new()),
tasks: Arc::new(PendingTaskList::default()),
swap_lock: SwapLock::new().into(),
tasks: PendingTaskList::default().into(),
tauri_handle: None,
tor_client: None,
}
@ -511,7 +564,7 @@ async fn init_monero_wallet(
);
let monero_wallet_rpc_process = monero_wallet_rpc
.run(network, Some(monero_daemon_address))
.run(network, monero_daemon_address.into())
.await
.context("Failed to start monero-wallet-rpc process")?;
@ -560,7 +613,7 @@ impl Config {
Self {
namespace: XmrBtcNamespace::from_is_testnet(false),
env_config,
seed: Some(seed),
seed: seed.into(),
debug: false,
json: false,
is_testnet: false,
@ -596,7 +649,7 @@ pub mod api_test {
Self {
namespace: XmrBtcNamespace::from_is_testnet(is_testnet),
env_config,
seed: Some(seed),
seed: seed.into(),
debug,
json,
is_testnet,

View File

@ -111,19 +111,31 @@ impl TauriEmitter for Option<TauriHandle> {
#[typeshare]
#[derive(Display, Clone, Serialize)]
#[serde(tag = "type", content = "content")]
pub enum TauriContextInitializationProgress {
OpeningBitcoinWallet,
DownloadingMoneroWalletRpc {
// Progress of the download in percent (0-100)
#[typeshare(serialized_as = "number")]
progress: u64,
// Size of the download file in bytes
#[typeshare(serialized_as = "number")]
size: u64,
},
OpeningMoneroWallet,
OpeningDatabase,
EstablishingTorCircuits,
pub enum PendingCompleted<P> {
Pending(P),
Completed,
}
#[derive(Serialize, Clone)]
#[typeshare]
pub struct DownloadProgress {
// Progress of the download in percent (0-100)
#[typeshare(serialized_as = "number")]
pub progress: u64,
// Size of the download file in bytes
#[typeshare(serialized_as = "number")]
pub size: u64,
}
#[typeshare]
#[derive(Display, Clone, Serialize)]
#[serde(tag = "componentName", content = "progress")]
pub enum TauriPartialInitProgress {
OpeningBitcoinWallet(PendingCompleted<()>),
DownloadingMoneroWalletRpc(PendingCompleted<DownloadProgress>),
OpeningMoneroWallet(PendingCompleted<()>),
OpeningDatabase(PendingCompleted<()>),
EstablishingTorCircuits(PendingCompleted<()>),
}
#[typeshare]
@ -131,7 +143,7 @@ pub enum TauriContextInitializationProgress {
#[serde(tag = "type", content = "content")]
pub enum TauriContextStatusEvent {
NotInitialized,
Initializing(TauriContextInitializationProgress),
Initializing(Vec<TauriPartialInitProgress>),
Available,
Failed,
}

View File

@ -22,7 +22,8 @@ use tokio_util::codec::{BytesCodec, FramedRead};
use tokio_util::io::StreamReader;
use crate::cli::api::tauri_bindings::{
TauriContextInitializationProgress, TauriContextStatusEvent, TauriEmitter, TauriHandle,
DownloadProgress, PendingCompleted, TauriContextStatusEvent, TauriEmitter, TauriHandle,
TauriPartialInitProgress,
};
// See: https://www.moneroworld.com/#nodes, https://monero.fail
@ -265,10 +266,12 @@ impl WalletRpc {
// Emit a tauri event to update the progress
tauri_handle.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::DownloadingMoneroWalletRpc {
progress: 0,
size: content_length,
},
vec![TauriPartialInitProgress::DownloadingMoneroWalletRpc(
PendingCompleted::Pending(DownloadProgress {
progress: 0,
size: content_length,
}),
)],
));
let mut hasher = Sha256::new();
@ -311,12 +314,14 @@ impl WalletRpc {
// Emit a tauri event to update the progress
tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(
TauriContextInitializationProgress::DownloadingMoneroWalletRpc {
progress: percent,
size: content_length,
},
),
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::DownloadingMoneroWalletRpc(
PendingCompleted::Pending(DownloadProgress {
progress: percent,
size: content_length,
}),
),
]),
);
}
file.write_all(&bytes).await?;
@ -346,6 +351,12 @@ impl WalletRpc {
tracing::debug!("Extracting archive");
Self::extract_archive(&monero_wallet_rpc).await?;
}
// Emit a tauri event to update the progress
tauri_handle.emit_context_init_progress_event(TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::DownloadingMoneroWalletRpc(PendingCompleted::Completed),
]));
Ok(monero_wallet_rpc)
}