diff --git a/Cargo.lock b/Cargo.lock index 19be1b98c..22cd64f4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -126,47 +126,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -246,7 +247,7 @@ checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.1", + "event-listener-strategy 0.5.2", "futures-core", "pin-project-lite", ] @@ -259,7 +260,7 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-lite 2.3.0", "slab", ] @@ -311,8 +312,8 @@ dependencies = [ "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.6.0", - "rustix 0.38.32", + "polling 3.7.0", + "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", @@ -384,14 +385,14 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" @@ -401,7 +402,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -443,9 +444,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -488,7 +489,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "itoa", "matchit", @@ -568,6 +569,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -624,7 +631,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -670,18 +677,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" dependencies = [ "async-channel 2.2.1", "async-lock 3.3.0", "async-task", - "fastrand 2.0.2", "futures-io", "futures-lite 2.3.0", "piper", - "tracing", ] [[package]] @@ -808,12 +813,13 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -890,9 +896,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -998,7 +1004,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1009,15 +1015,15 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -1287,7 +1293,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1311,7 +1317,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1322,7 +1328,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1332,7 +1338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if 1.0.0", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1340,9 +1346,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "delegate-display" @@ -1353,7 +1359,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1569,9 +1575,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -1595,7 +1601,7 @@ dependencies = [ "macroific", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1624,15 +1630,15 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fiat-crypto" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" +checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" [[package]] name = "filetime" @@ -1642,7 +1648,7 @@ checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "windows-sys 0.52.0", ] @@ -1663,9 +1669,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -1770,7 +1776,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "futures-io", "parking", @@ -1785,7 +1791,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1941,9 +1947,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", ] @@ -2122,7 +2128,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -2131,9 +2137,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", @@ -2183,9 +2189,9 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.1", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", ] @@ -2282,7 +2288,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -2358,6 +2364,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -2393,9 +2405,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -2411,7 +2423,7 @@ dependencies = [ [[package]] name = "kaspa-addresses" -version = "0.13.6" +version = "0.14.1" dependencies = [ "borsh", "criterion", @@ -2428,7 +2440,7 @@ dependencies = [ [[package]] name = "kaspa-addressmanager" -version = "0.13.6" +version = "0.14.1" dependencies = [ "borsh", "igd-next", @@ -2451,14 +2463,14 @@ dependencies = [ [[package]] name = "kaspa-alloc" -version = "0.13.6" +version = "0.14.1" dependencies = [ "mimalloc", ] [[package]] name = "kaspa-bip32" -version = "0.13.6" +version = "0.14.1" dependencies = [ "borsh", "bs58", @@ -2484,7 +2496,7 @@ dependencies = [ [[package]] name = "kaspa-cli" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "borsh", @@ -2529,7 +2541,7 @@ dependencies = [ [[package]] name = "kaspa-connectionmanager" -version = "0.13.6" +version = "0.14.1" dependencies = [ "duration-string", "futures-util", @@ -2546,7 +2558,7 @@ dependencies = [ [[package]] name = "kaspa-consensus" -version = "0.13.6" +version = "0.14.1" dependencies = [ "arc-swap", "async-channel 2.2.1", @@ -2589,7 +2601,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-client" -version = "0.13.6" +version = "0.14.1" dependencies = [ "ahash 0.8.11", "cfg-if 1.0.0", @@ -2617,7 +2629,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "bincode", @@ -2654,7 +2666,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-notify" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "cfg-if 1.0.0", @@ -2673,7 +2685,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-wasm" -version = "0.13.6" +version = "0.14.1" dependencies = [ "cfg-if 1.0.0", "faster-hex 0.6.1", @@ -2697,7 +2709,7 @@ dependencies = [ [[package]] name = "kaspa-consensusmanager" -version = "0.13.6" +version = "0.14.1" dependencies = [ "duration-string", "futures", @@ -2715,7 +2727,7 @@ dependencies = [ [[package]] name = "kaspa-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "cfg-if 1.0.0", "ctrlc", @@ -2733,7 +2745,7 @@ dependencies = [ [[package]] name = "kaspa-daemon" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "borsh", @@ -2755,7 +2767,7 @@ dependencies = [ [[package]] name = "kaspa-database" -version = "0.13.6" +version = "0.14.1" dependencies = [ "bincode", "enum-primitive-derive", @@ -2777,7 +2789,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-client" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-stream", @@ -2808,7 +2820,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-stream", @@ -2837,7 +2849,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-server" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-stream", @@ -2872,7 +2884,7 @@ dependencies = [ [[package]] name = "kaspa-hashes" -version = "0.13.6" +version = "0.14.1" dependencies = [ "blake2b_simd", "borsh", @@ -2893,7 +2905,7 @@ dependencies = [ [[package]] name = "kaspa-index-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -2912,7 +2924,7 @@ dependencies = [ [[package]] name = "kaspa-index-processor" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -2940,7 +2952,7 @@ dependencies = [ [[package]] name = "kaspa-math" -version = "0.13.6" +version = "0.14.1" dependencies = [ "borsh", "criterion", @@ -2961,14 +2973,14 @@ dependencies = [ [[package]] name = "kaspa-merkle" -version = "0.13.6" +version = "0.14.1" dependencies = [ "kaspa-hashes", ] [[package]] name = "kaspa-metrics-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "borsh", @@ -2984,7 +2996,7 @@ dependencies = [ [[package]] name = "kaspa-mining" -version = "0.13.6" +version = "0.14.1" dependencies = [ "criterion", "futures-util", @@ -3010,7 +3022,7 @@ dependencies = [ [[package]] name = "kaspa-mining-errors" -version = "0.13.6" +version = "0.14.1" dependencies = [ "kaspa-consensus-core", "thiserror", @@ -3018,7 +3030,7 @@ dependencies = [ [[package]] name = "kaspa-muhash" -version = "0.13.6" +version = "0.14.1" dependencies = [ "criterion", "kaspa-hashes", @@ -3031,7 +3043,7 @@ dependencies = [ [[package]] name = "kaspa-notify" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -3066,7 +3078,7 @@ dependencies = [ [[package]] name = "kaspa-p2p-flows" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "chrono", @@ -3097,7 +3109,7 @@ dependencies = [ [[package]] name = "kaspa-p2p-lib" -version = "0.13.6" +version = "0.14.1" dependencies = [ "borsh", "ctrlc", @@ -3128,7 +3140,7 @@ dependencies = [ [[package]] name = "kaspa-perf-monitor" -version = "0.13.6" +version = "0.14.1" dependencies = [ "kaspa-core", "log", @@ -3140,7 +3152,7 @@ dependencies = [ [[package]] name = "kaspa-pow" -version = "0.13.6" +version = "0.14.1" dependencies = [ "criterion", "js-sys", @@ -3156,7 +3168,7 @@ dependencies = [ [[package]] name = "kaspa-resolver" -version = "0.13.6" +version = "0.14.1" dependencies = [ "ahash 0.8.11", "axum 0.7.5", @@ -3186,7 +3198,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -3226,7 +3238,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-macros" -version = "0.13.6" +version = "0.14.1" dependencies = [ "convert_case 0.6.0", "proc-macro-error", @@ -3238,7 +3250,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-service" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "kaspa-addresses", @@ -3267,7 +3279,7 @@ dependencies = [ [[package]] name = "kaspa-testing-integration" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -3327,7 +3339,7 @@ dependencies = [ [[package]] name = "kaspa-txscript" -version = "0.13.6" +version = "0.14.1" dependencies = [ "blake2b_simd", "borsh", @@ -3353,7 +3365,7 @@ dependencies = [ [[package]] name = "kaspa-txscript-errors" -version = "0.13.6" +version = "0.14.1" dependencies = [ "secp256k1", "thiserror", @@ -3361,7 +3373,7 @@ dependencies = [ [[package]] name = "kaspa-utils" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "async-trait", @@ -3390,7 +3402,7 @@ dependencies = [ [[package]] name = "kaspa-utils-tower" -version = "0.13.6" +version = "0.14.1" dependencies = [ "cfg-if 1.0.0", "futures", @@ -3404,7 +3416,7 @@ dependencies = [ [[package]] name = "kaspa-utxoindex" -version = "0.13.6" +version = "0.14.1" dependencies = [ "futures", "kaspa-consensus", @@ -3425,7 +3437,7 @@ dependencies = [ [[package]] name = "kaspa-wallet" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-std", "async-trait", @@ -3437,7 +3449,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-cli-wasm" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "js-sys", @@ -3451,7 +3463,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "aes", "ahash 0.8.11", @@ -3459,7 +3471,7 @@ dependencies = [ "async-channel 2.2.1", "async-std", "async-trait", - "base64", + "base64 0.21.7", "borsh", "cfb-mode", "cfg-if 1.0.0", @@ -3531,7 +3543,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-keys" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "borsh", @@ -3564,7 +3576,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-macros" -version = "0.13.6" +version = "0.14.1" dependencies = [ "convert_case 0.5.0", "proc-macro-error", @@ -3577,7 +3589,7 @@ dependencies = [ [[package]] name = "kaspa-wasm" -version = "0.13.6" +version = "0.14.1" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3603,7 +3615,7 @@ dependencies = [ [[package]] name = "kaspa-wasm-core" -version = "0.13.6" +version = "0.14.1" dependencies = [ "faster-hex 0.6.1", "js-sys", @@ -3612,7 +3624,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-client" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-std", "async-trait", @@ -3646,7 +3658,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-example-subscriber" -version = "0.13.6" +version = "0.14.1" dependencies = [ "ctrlc", "futures", @@ -3661,7 +3673,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-proxy" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "clap 4.5.4", @@ -3680,7 +3692,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-server" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-trait", "borsh", @@ -3707,7 +3719,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-wasm" -version = "0.13.6" +version = "0.14.1" dependencies = [ "ahash 0.8.11", "async-std", @@ -3736,7 +3748,7 @@ dependencies = [ [[package]] name = "kaspad" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "clap 4.5.4", @@ -3811,9 +3823,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -3833,9 +3845,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libmimalloc-sys" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +checksum = "81eb4061c0582dedea1cbc7aff2240300dd6982e0239d1c99e65c1dbf4a30ba7" dependencies = [ "cc", "libc", @@ -3924,9 +3936,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -4016,7 +4028,7 @@ dependencies = [ "cfg-if 1.0.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4027,7 +4039,7 @@ checksum = "13198c120864097a565ccb3ff947672d969932b7975ebd4085732c9f09435e55" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4040,7 +4052,7 @@ dependencies = [ "macroific_core", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4049,7 +4061,7 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d073a3d1e4e037975af5ef176a2632672e25e8ddbe8e1811745c2e0726b6ad94" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", "itertools 0.11.0", "libm", "ryu", @@ -4108,9 +4120,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mimalloc" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +checksum = "9f41a2280ded0da56c8cf898babb86e8f10651a34adcfff190ae9a1159c6908d" dependencies = [ "libmimalloc-sys", ] @@ -4349,9 +4361,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -4383,9 +4395,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -4479,7 +4491,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4548,9 +4560,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -4558,15 +4570,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -4586,7 +4598,7 @@ checksum = "70df726c43c645ef1dde24c7ae14692036ebe5457c92c5f0ec4cfceb99634ff6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4655,7 +4667,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4677,7 +4689,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ "atomic-waker", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-io", ] @@ -4711,15 +4723,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", "hermit-abi 0.3.9", "pin-project-lite", - "rustix 0.38.32", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -4755,12 +4767,12 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "prettyplease" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4797,9 +4809,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -4831,7 +4843,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.58", + "syn 2.0.60", "tempfile", ] @@ -4845,7 +4857,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4991,6 +5003,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -5037,7 +5058,7 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -5116,7 +5137,7 @@ dependencies = [ [[package]] name = "rothschild" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "clap 4.5.4", @@ -5175,9 +5196,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -5188,9 +5209,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -5204,7 +5225,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64", + "base64 0.21.7", ] [[package]] @@ -5300,11 +5321,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -5313,9 +5334,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -5347,9 +5368,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] @@ -5377,20 +5398,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -5415,7 +5436,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5441,11 +5462,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -5459,14 +5480,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5552,16 +5573,16 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "simpa" -version = "0.13.6" +version = "0.14.1" dependencies = [ "async-channel 2.2.1", "clap 4.5.4", @@ -5634,9 +5655,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -5721,9 +5742,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -5770,8 +5791,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", - "fastrand 2.0.2", - "rustix 0.38.32", + "fastrand 2.1.0", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -5806,22 +5827,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5921,7 +5942,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.48.0", ] @@ -5944,7 +5965,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5994,16 +6015,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -6038,9 +6058,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", "serde", @@ -6058,7 +6078,7 @@ dependencies = [ "async-stream", "async-trait", "axum 0.6.20", - "base64", + "base64 0.21.7", "bytes", "flate2", "h2", @@ -6090,7 +6110,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6179,7 +6199,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6299,9 +6319,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "universal-hash" @@ -6386,9 +6406,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" +checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" [[package]] name = "vcpkg" @@ -6483,7 +6503,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -6517,7 +6537,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6550,7 +6570,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6572,7 +6592,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -6593,11 +6613,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -6756,9 +6776,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" dependencies = [ "memchr", ] @@ -7019,7 +7039,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "762861614298160b9205302bec4f2b7eb45853413d10a90ad8edca44bafc324b" dependencies = [ "async-std", - "base64", + "base64 0.21.7", "cfg-if 1.0.0", "chrome-sys", "faster-hex 0.9.0", @@ -7200,22 +7220,22 @@ checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b998a6dbe..48348378a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ members = [ "consensus/notify", "consensus/pow", "consensus/wasm", - # "kos", "kaspad", "simpa", "wasm", @@ -63,7 +62,7 @@ members = [ [workspace.package] rust-version = "1.77.0" -version = "0.13.6" +version = "0.14.1" authors = ["Kaspa developers"] license = "ISC" repository = "https://github.com/kaspanet/rusty-kaspa" @@ -80,63 +79,62 @@ include = [ ] [workspace.dependencies] -# kaspa-testing-integration = { version = "0.13.6", path = "testing/integration" } -kaspa-addresses = { version = "0.13.6", path = "crypto/addresses" } -kaspa-addressmanager = { version = "0.13.6", path = "components/addressmanager" } -kaspa-bip32 = { version = "0.13.6", path = "wallet/bip32" } -kaspa-resolver = { version = "0.13.6", path = "rpr/wrpc/resolver" } -kaspa-cli = { version = "0.13.6", path = "cli" } -kaspa-connectionmanager = { version = "0.13.6", path = "components/connectionmanager" } -kaspa-consensus = { version = "0.13.6", path = "consensus" } -kaspa-consensus-core = { version = "0.13.6", path = "consensus/core" } -kaspa-consensus-client = { version = "0.13.6", path = "consensus/client" } -kaspa-consensus-notify = { version = "0.13.6", path = "consensus/notify" } -kaspa-consensus-wasm = { version = "0.13.6", path = "consensus/wasm" } -kaspa-consensusmanager = { version = "0.13.6", path = "components/consensusmanager" } -kaspa-core = { version = "0.13.6", path = "core" } -kaspa-daemon = { version = "0.13.6", path = "daemon" } -kaspa-database = { version = "0.13.6", path = "database" } -kaspa-grpc-client = { version = "0.13.6", path = "rpc/grpc/client" } -kaspa-grpc-core = { version = "0.13.6", path = "rpc/grpc/core" } -kaspa-grpc-server = { version = "0.13.6", path = "rpc/grpc/server" } -kaspa-hashes = { version = "0.13.6", path = "crypto/hashes" } -kaspa-index-core = { version = "0.13.6", path = "indexes/core" } -kaspa-index-processor = { version = "0.13.6", path = "indexes/processor" } -kaspa-math = { version = "0.13.6", path = "math" } -kaspa-merkle = { version = "0.13.6", path = "crypto/merkle" } -kaspa-metrics-core = { version = "0.13.6", path = "metrics/core" } -kaspa-mining = { version = "0.13.6", path = "mining" } -kaspa-mining-errors = { version = "0.13.6", path = "mining/errors" } -kaspa-muhash = { version = "0.13.6", path = "crypto/muhash" } -kaspa-notify = { version = "0.13.6", path = "notify" } -# kaspa-os = { version = "0.13.6", path = "kaspa-os" } -kaspa-p2p-flows = { version = "0.13.6", path = "protocol/flows" } -kaspa-p2p-lib = { version = "0.13.6", path = "protocol/p2p" } -kaspa-perf-monitor = { version = "0.13.6", path = "metrics/perf_monitor" } -kaspa-pow = { version = "0.13.6", path = "consensus/pow" } -kaspa-rpc-core = { version = "0.13.6", path = "rpc/core" } -kaspa-rpc-macros = { version = "0.13.6", path = "rpc/macros" } -kaspa-rpc-service = { version = "0.13.6", path = "rpc/service" } -kaspa-txscript = { version = "0.13.6", path = "crypto/txscript" } -kaspa-txscript-errors = { version = "0.13.6", path = "crypto/txscript/errors" } -kaspa-utils = { version = "0.13.6", path = "utils" } -kaspa-utils-tower = { version = "0.13.6", path = "utils/tower" } -kaspa-utxoindex = { version = "0.13.6", path = "indexes/utxoindex" } -kaspa-wallet = { version = "0.13.6", path = "wallet/native" } -kaspa-wallet-cli-wasm = { version = "0.13.6", path = "wallet/wasm" } -kaspa-wallet-keys = { version = "0.13.6", path = "wallet/keys" } -kaspa-wallet-core = { version = "0.13.6", path = "wallet/core" } -kaspa-wallet-macros = { version = "0.13.6", path = "wallet/macros" } -kaspa-wasm = { version = "0.13.6", path = "wasm" } -kaspa-wasm-core = { version = "0.13.6", path = "wasm/core" } -kaspa-wrpc-client = { version = "0.13.6", path = "rpc/wrpc/client" } -kaspa-wrpc-core = { version = "0.13.6", path = "rpc/wrpc/core" } -kaspa-wrpc-proxy = { version = "0.13.6", path = "rpc/wrpc/proxy" } -kaspa-wrpc-server = { version = "0.13.6", path = "rpc/wrpc/server" } -kaspa-wrpc-wasm = { version = "0.13.6", path = "rpc/wrpc/wasm" } -kaspa-wrpc-example-subscriber = { version = "0.13.6", path = "rpc/wrpc/examples/subscriber" } -kaspad = { version = "0.13.6", path = "kaspad" } -kaspa-alloc = { version = "0.13.6", path = "utils/alloc" } +# kaspa-testing-integration = { version = "0.14.1", path = "testing/integration" } +kaspa-addresses = { version = "0.14.1", path = "crypto/addresses" } +kaspa-addressmanager = { version = "0.14.1", path = "components/addressmanager" } +kaspa-bip32 = { version = "0.14.1", path = "wallet/bip32" } +kaspa-resolver = { version = "0.14.1", path = "rpr/wrpc/resolver" } +kaspa-cli = { version = "0.14.1", path = "cli" } +kaspa-connectionmanager = { version = "0.14.1", path = "components/connectionmanager" } +kaspa-consensus = { version = "0.14.1", path = "consensus" } +kaspa-consensus-core = { version = "0.14.1", path = "consensus/core" } +kaspa-consensus-client = { version = "0.14.1", path = "consensus/client" } +kaspa-consensus-notify = { version = "0.14.1", path = "consensus/notify" } +kaspa-consensus-wasm = { version = "0.14.1", path = "consensus/wasm" } +kaspa-consensusmanager = { version = "0.14.1", path = "components/consensusmanager" } +kaspa-core = { version = "0.14.1", path = "core" } +kaspa-daemon = { version = "0.14.1", path = "daemon" } +kaspa-database = { version = "0.14.1", path = "database" } +kaspa-grpc-client = { version = "0.14.1", path = "rpc/grpc/client" } +kaspa-grpc-core = { version = "0.14.1", path = "rpc/grpc/core" } +kaspa-grpc-server = { version = "0.14.1", path = "rpc/grpc/server" } +kaspa-hashes = { version = "0.14.1", path = "crypto/hashes" } +kaspa-index-core = { version = "0.14.1", path = "indexes/core" } +kaspa-index-processor = { version = "0.14.1", path = "indexes/processor" } +kaspa-math = { version = "0.14.1", path = "math" } +kaspa-merkle = { version = "0.14.1", path = "crypto/merkle" } +kaspa-metrics-core = { version = "0.14.1", path = "metrics/core" } +kaspa-mining = { version = "0.14.1", path = "mining" } +kaspa-mining-errors = { version = "0.14.1", path = "mining/errors" } +kaspa-muhash = { version = "0.14.1", path = "crypto/muhash" } +kaspa-notify = { version = "0.14.1", path = "notify" } +kaspa-p2p-flows = { version = "0.14.1", path = "protocol/flows" } +kaspa-p2p-lib = { version = "0.14.1", path = "protocol/p2p" } +kaspa-perf-monitor = { version = "0.14.1", path = "metrics/perf_monitor" } +kaspa-pow = { version = "0.14.1", path = "consensus/pow" } +kaspa-rpc-core = { version = "0.14.1", path = "rpc/core" } +kaspa-rpc-macros = { version = "0.14.1", path = "rpc/macros" } +kaspa-rpc-service = { version = "0.14.1", path = "rpc/service" } +kaspa-txscript = { version = "0.14.1", path = "crypto/txscript" } +kaspa-txscript-errors = { version = "0.14.1", path = "crypto/txscript/errors" } +kaspa-utils = { version = "0.14.1", path = "utils" } +kaspa-utils-tower = { version = "0.14.1", path = "utils/tower" } +kaspa-utxoindex = { version = "0.14.1", path = "indexes/utxoindex" } +kaspa-wallet = { version = "0.14.1", path = "wallet/native" } +kaspa-wallet-cli-wasm = { version = "0.14.1", path = "wallet/wasm" } +kaspa-wallet-keys = { version = "0.14.1", path = "wallet/keys" } +kaspa-wallet-core = { version = "0.14.1", path = "wallet/core" } +kaspa-wallet-macros = { version = "0.14.1", path = "wallet/macros" } +kaspa-wasm = { version = "0.14.1", path = "wasm" } +kaspa-wasm-core = { version = "0.14.1", path = "wasm/core" } +kaspa-wrpc-client = { version = "0.14.1", path = "rpc/wrpc/client" } +kaspa-wrpc-core = { version = "0.14.1", path = "rpc/wrpc/core" } +kaspa-wrpc-proxy = { version = "0.14.1", path = "rpc/wrpc/proxy" } +kaspa-wrpc-server = { version = "0.14.1", path = "rpc/wrpc/server" } +kaspa-wrpc-wasm = { version = "0.14.1", path = "rpc/wrpc/wasm" } +kaspa-wrpc-example-subscriber = { version = "0.14.1", path = "rpc/wrpc/examples/subscriber" } +kaspad = { version = "0.14.1", path = "kaspad" } +kaspa-alloc = { version = "0.14.1", path = "utils/alloc" } # external aes = "0.8.3" @@ -323,3 +321,4 @@ overflow-checks = true inherits = "release" debug = true strip = false + diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4d3a78ab8..f2c80a5fa 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -79,3 +79,6 @@ features = [ [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/components/addressmanager/src/stores/address_store.rs b/components/addressmanager/src/stores/address_store.rs index 41b12f6cc..accfcfda4 100644 --- a/components/addressmanager/src/stores/address_store.rs +++ b/components/addressmanager/src/stores/address_store.rs @@ -26,6 +26,7 @@ pub trait AddressesStoreReader { pub trait AddressesStore: AddressesStoreReader { fn set(&mut self, key: AddressKey, entry: Entry) -> StoreResult<()>; + #[allow(dead_code)] fn set_failed_count(&mut self, key: AddressKey, connection_failed_count: u64) -> StoreResult<()>; fn remove(&mut self, key: AddressKey) -> StoreResult<()>; } diff --git a/consensus/client/Cargo.toml b/consensus/client/Cargo.toml index c2c49827d..38cbed9a3 100644 --- a/consensus/client/Cargo.toml +++ b/consensus/client/Cargo.toml @@ -37,3 +37,6 @@ itertools.workspace = true workflow-wasm.workspace = true workflow-log.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/consensus/client/src/sign.rs b/consensus/client/src/sign.rs index 3504ccff0..fdab66a60 100644 --- a/consensus/client/src/sign.rs +++ b/consensus/client/src/sign.rs @@ -54,7 +54,7 @@ pub fn sign_with_multiple_v3(tx: Transaction, privkeys: &[[u8; 32]]) -> crate::r } }; let script = script_pub_key.script(); - if let Some(schnorr_key) = map.get(&script.to_vec()) { + if let Some(schnorr_key) = map.get(script) { let sig_hash = calc_schnorr_signature_hash(&populated_transaction, i, SIG_HASH_ALL, &mut reused_values); let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap(); let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref(); diff --git a/consensus/core/Cargo.toml b/consensus/core/Cargo.toml index 4b144f9ba..4e4bd9ea0 100644 --- a/consensus/core/Cargo.toml +++ b/consensus/core/Cargo.toml @@ -52,3 +52,6 @@ web-sys.workspace = true [[bench]] name = "serde_benchmark" harness = false + +[lints.clippy] +empty_docs = "allow" diff --git a/consensus/core/src/sign.rs b/consensus/core/src/sign.rs index 7e3322444..dee0d3844 100644 --- a/consensus/core/src/sign.rs +++ b/consensus/core/src/sign.rs @@ -136,7 +136,7 @@ pub fn sign_with_multiple_v2(mut mutable_tx: SignableTransaction, privkeys: &[[u let mut additional_signatures_required = false; for i in 0..mutable_tx.tx.inputs.len() { let script = mutable_tx.entries[i].as_ref().unwrap().script_public_key.script(); - if let Some(schnorr_key) = map.get(&script.to_vec()) { + if let Some(schnorr_key) = map.get(script) { let sig_hash = calc_schnorr_signature_hash(&mutable_tx.as_verifiable(), i, SIG_HASH_ALL, &mut reused_values); let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap(); let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref(); diff --git a/consensus/core/src/subnets.rs b/consensus/core/src/subnets.rs index 94c08fb62..2456f8444 100644 --- a/consensus/core/src/subnets.rs +++ b/consensus/core/src/subnets.rs @@ -4,6 +4,7 @@ use std::str::{self, FromStr}; use borsh::{BorshDeserialize, BorshSerialize}; use kaspa_utils::hex::{FromHex, ToHex}; use kaspa_utils::{serde_impl_deser_fixed_bytes_ref, serde_impl_ser_fixed_bytes_ref}; +use thiserror::Error; /// The size of the array used to store subnetwork IDs. pub const SUBNETWORK_ID_SIZE: usize = 20; @@ -65,12 +66,28 @@ impl SubnetworkId { } } +#[derive(Error, Debug, Clone)] +pub enum SubnetworkConversionError { + #[error("Invalid bytes")] + InvalidBytes, + + #[error(transparent)] + SliceError(#[from] std::array::TryFromSliceError), + + #[error(transparent)] + HexError(#[from] faster_hex::Error), +} + impl TryFrom<&[u8]> for SubnetworkId { - type Error = std::array::TryFromSliceError; + type Error = SubnetworkConversionError; fn try_from(value: &[u8]) -> Result { let bytes = <[u8; SUBNETWORK_ID_SIZE]>::try_from(value)?; - Ok(Self(bytes)) + if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 { + Err(Self::Error::InvalidBytes) + } else { + Ok(Self(bytes)) + } } } @@ -92,22 +109,30 @@ impl ToHex for SubnetworkId { } impl FromStr for SubnetworkId { - type Err = faster_hex::Error; + type Err = SubnetworkConversionError; #[inline] fn from_str(hex_str: &str) -> Result { let mut bytes = [0u8; SUBNETWORK_ID_SIZE]; faster_hex::hex_decode(hex_str.as_bytes(), &mut bytes)?; - Ok(SubnetworkId(bytes)) + if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 { + Err(Self::Err::InvalidBytes) + } else { + Ok(Self(bytes)) + } } } impl FromHex for SubnetworkId { - type Error = faster_hex::Error; + type Error = SubnetworkConversionError; fn from_hex(hex_str: &str) -> Result { let mut bytes = [0u8; SUBNETWORK_ID_SIZE]; faster_hex::hex_decode(hex_str.as_bytes(), &mut bytes)?; - Ok(SubnetworkId(bytes)) + if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 { + Err(Self::Error::InvalidBytes) + } else { + Ok(Self(bytes)) + } } } diff --git a/consensus/wasm/Cargo.toml b/consensus/wasm/Cargo.toml index 354bb9826..ea211f3f9 100644 --- a/consensus/wasm/Cargo.toml +++ b/consensus/wasm/Cargo.toml @@ -34,3 +34,6 @@ wasm-bindgen.workspace = true workflow-wasm.workspace = true workflow-log.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/crypto/addresses/Cargo.toml b/crypto/addresses/Cargo.toml index 8266b3f80..dd9f8e3ac 100644 --- a/crypto/addresses/Cargo.toml +++ b/crypto/addresses/Cargo.toml @@ -27,3 +27,6 @@ web-sys.workspace = true [[bench]] name = "bench" harness = false + +[lints.clippy] +empty_docs = "allow" diff --git a/crypto/txscript/src/data_stack.rs b/crypto/txscript/src/data_stack.rs index 0eafb8d14..74988042a 100644 --- a/crypto/txscript/src/data_stack.rs +++ b/crypto/txscript/src/data_stack.rs @@ -14,6 +14,7 @@ pub(crate) trait DataStack { fn pop_items(&mut self) -> Result<[T; SIZE], TxScriptError> where Vec: OpcodeData; + #[allow(dead_code)] fn peek_items(&self) -> Result<[T; SIZE], TxScriptError> where Vec: OpcodeData; diff --git a/crypto/txscript/src/opcodes/mod.rs b/crypto/txscript/src/opcodes/mod.rs index 9727e2e87..5d6096b7a 100644 --- a/crypto/txscript/src/opcodes/mod.rs +++ b/crypto/txscript/src/opcodes/mod.rs @@ -1013,7 +1013,7 @@ mod test { let mut reused_values = SigHashReusedValues::new(); for ErrorTestCase { init, code, error } in tests { let mut vm = TxScriptEngine::new(&mut reused_values, &cache); - vm.dstack = init.clone(); + vm.dstack.clone_from(&init); assert_eq!( code.execute(&mut vm) .expect_err(format!("Opcode {} should have errored (init: {:?})", code.value(), init.clone()).as_str()), diff --git a/kaspad/src/args.rs b/kaspad/src/args.rs index 7483d9091..e11672915 100644 --- a/kaspad/src/args.rs +++ b/kaspad/src/args.rs @@ -154,7 +154,7 @@ impl Args { config.is_archival = self.archival; // TODO: change to `config.enable_sanity_checks = self.sanity` when we reach stable versions config.enable_sanity_checks = true; - config.user_agent_comments = self.user_agent_comments.clone(); + config.user_agent_comments.clone_from(&self.user_agent_comments); config.block_template_cache_lifetime = self.block_template_cache_lifetime; config.p2p_listen_address = self.listen.unwrap_or(ContextualNetAddress::unspecified()); config.externalip = self.externalip.map(|v| v.normalize(config.default_p2p_port())); diff --git a/kos/.gitignore b/kos/.gitignore deleted file mode 100644 index b02305c0a..000000000 --- a/kos/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -target -Cargo.lock -analyzer-target diff --git a/kos/Cargo.toml b/kos/Cargo.toml deleted file mode 100644 index a808a7603..000000000 --- a/kos/Cargo.toml +++ /dev/null @@ -1,68 +0,0 @@ -[package] -name = "kaspa-os" -description = "Kaspa Node & Wallet Manager" -# please keep this version detached from the workspace -rust-version.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true -repository.workspace = true -include = [ - "src/**/*.rs", - "src/**/*.txt", - "src/**/*.css", - "Cargo.toml", - "Cargo.lock", -] - -[features] -metrics = [] -default = ["metrics"] - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -async-trait.workspace = true -borsh.workspace = true -cfg-if.workspace = true -downcast.workspace = true -futures.workspace = true -js-sys.workspace = true -kaspa-cli.workspace = true -kaspa-consensus-core.workspace = true -kaspa-core.workspace = true -kaspa-daemon.workspace = true -kaspa-metrics-core.workspace = true -kaspa-rpc-core.workspace = true -kaspa-wallet-core.workspace = true -nw-sys.workspace = true -regex.workspace = true -serde_json.workspace = true -serde.workspace = true -thiserror.workspace = true -wasm-bindgen-futures.workspace = true -wasm-bindgen.workspace = true -workflow-core.workspace = true -workflow-d3.workspace = true -workflow-dom.workspace = true -workflow-log.workspace = true -workflow-nw.workspace = true -workflow-terminal.workspace = true -workflow-wasm.workspace = true - -[dependencies.web-sys] -workspace = true -features = [ - 'console', - 'Document', - 'Window', - 'HtmlElement', - 'CustomEvent', - # 'DomRect', - # 'MouseEvent', - # 'HtmlCanvasElement', - # 'CanvasRenderingContext2d' -] - diff --git a/kos/README.md b/kos/README.md deleted file mode 100644 index deb7feb0e..000000000 --- a/kos/README.md +++ /dev/null @@ -1,117 +0,0 @@ -# `KOS` - -An integrated desktop application that provides a local Kaspa node instance, a CPU miner (for testnet) -and the Wallet subsystem based on the Rusty Kaspa project. This application is written in Rust and integrates -the Rusty Kaspa framework. - -This application is compatible with Windows, MacOS and Linux desktop environments. - -Please note that this project is comprised of 3 top-level components: -- `/kos` - desktop application environment (can run as a dekstop application) -- `/cli` - native terminal environment (can run from a command line) -- `/wallet/wasm` - web application (can run in the browser) - -All three components listed above are the same application written in Rust, the only -difference is that the `cli` and `wallet` can not run `kaspad` (but can connect remotely to it). -Also, `cli` and `kos` store all wallet data on the filesystem and are interchangeable, -while the `web wallet` stores the wallet data in your browser (associated and locked by your browser -to the domain name where the wallet is running). - -## Dependencies - -- cargo nw: `cargo install cargo-nw` (`cargo nw --help` for more info) - -Cargo NW is a tool for running and deploying NWJS applications. - -Please make sure that you have the latest Rust version by running `rustup update` and the latest -`wasm-pack` by running `cargo install wasm-pack`. - -If you have not previously setup Rusty Kaspa development environment, please follow the README -in the root of this project. - -## Repositories - -To use KOS on the testnet, you need to clone rusty-kaspa and cpu-miner repositories as follows. - -``` -mkdir kaspa -cd kaspa -git clone -b kos https://github.com/aspectron/rusty-kaspa -git clone https://github.com/aspectron/kaspa-cpu-miner -``` -(please note that you are cloning `kos` branch from `aspectron/rusty-kaspa` repository until KOS is merged into `kaspanet/master`) - -## Building - -Please note that to run this application in the development environment -you need to build Rusty Kaspa and CPU Miner. You can do that as follows: - -``` -cd rusty-kaspa -cargo build --bin kaspad --release -cd ../kaspa-cpu-miner -cargo build --release -cd ../rusty-kaspa/kos -``` - - -### Release -``` -cd rusty-kaspa/kos -./build -``` -### Debug -``` -cd rusty-kaspa/kos -./build --dev -``` - -## Running - -- regular: `cargo nw run` -- with NWJS SDK: `cargo nw run --sdk` -- using local cargo-nw: `cargo run -- nw ../rusty-kaspa/kos run --sdk` - -The `--sdk` option allows you to bring up the development console which -gives you access to application log outputs (using `log_info!` and related macros). - - -## KOS and CLI - -NOTE: `/kos` and `/cli` are practically identical. KOS runs in a desktop environment -powered by NWJS and automated via `cargo-nw`. CLI runs in a command-line environment. -KOS is capable of running and managing Rusty Kaspa node (`kaspad`) as a child process as -well as (during initial alpha stages) a CPU miner. - -KOS will auto-detect Kaspa node and CPU miner applications by looking at `../target/release/kaspad` and `../../kaspa-cpu-miner/target/release/kaspa-cpu-miner` - -You can also use `node select` and `miner select` commands to select release or debug versions or supply a custom path as a 3rd argument to these commands. - -## Basic Guide - -Once you power up KOS you can do the following: - -Before you do anything else, enter: `network testnet-10` - specify that you want to interface with `testnet-10`. - -`node start` - start the kaspa node; you will need to wait for the node to sync - -`node mute` - toggles node log output - -`wallet create` - create a local wallet; You can create multiple wallets by specifying a name after the create command. For example: `wallet create alpha` will create a wallet `alpha` which can later be opened with `open alpha`. The default name for the wallet is `kaspa`. Each named wallet is stored in a separate wallet file. (you can not currently rename the wallet once created) - -`account create bip32` - creates a new account in the currently opened wallet. You can give a name to the account by supplying it during creation as follows: `account create bip32 personal` or `account create bip32 business`. This will create an account named `personal` or `business`. Account names can be later used as shorthand when transferring funds between accounts or selecting them. - -Once you are synced and have the miner operational, make sure you have a wallet open with a selected account and use `miner start`. This will launch the miner and start mining to your selected account. If your hashrate is in Kh/s, it may take a while to find a block. - -Once you have received some TKAS, you can test sending it by doing `transfer p 10`. The letter `p` is for `personal` - when using account names you can use first set of letters of the account name or its id. If more than one account matches your supplied prefix, you will be asked to be more specific. - -Use `list` to see your accounts and their balances. - -You can click on any address to copy it to the clipboard - -Use `mute` to toggle visibility of internal framework events. Applications integrating with this framework will receive these events and will be able to update UI accordingly. - -Use `send
10` to send funds to someone else. - -Use `guide` for an internal guide that provides additional information about supported commands. - diff --git a/kos/app/index.html b/kos/app/index.html deleted file mode 100644 index 4701d70cd..000000000 --- a/kos/app/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Kaspa OS - - - - - - diff --git a/kos/app/metrics.html b/kos/app/metrics.html deleted file mode 100644 index 55c6e1320..000000000 --- a/kos/app/metrics.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - Kaspa OS - Metrics - - - - - - diff --git a/kos/build b/kos/build deleted file mode 100755 index 1995e0101..000000000 --- a/kos/build +++ /dev/null @@ -1,3 +0,0 @@ -cargo fmt --all - -wasm-pack build --target web --out-name kaspa --out-dir app/wasm $@ diff --git a/kos/build.ps1 b/kos/build.ps1 deleted file mode 100644 index 604ff73d1..000000000 --- a/kos/build.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -cargo fmt --all - -if ($args.Contains("--dev")) { - & "wasm-pack" build --dev --target web --out-name kaspa --out-dir app/wasm -} else { - & "wasm-pack" build --target web --out-name kaspa --out-dir app/wasm -} diff --git a/kos/index.js b/kos/index.js deleted file mode 100644 index 08ce684e0..000000000 --- a/kos/index.js +++ /dev/null @@ -1,11 +0,0 @@ -false && process.versions["nw-flavor"] === "sdk" && chrome.developerPrivate.openDevTools({ - renderViewId: -1, - renderProcessId: -1, - extensionId: chrome.runtime.id, -}); - -(async()=>{ - window.kaspa = await import('/app/wasm/kaspa.js'); - const wasm = await window.kaspa.default('/app/wasm/kaspa_bg.wasm'); - await window.kaspa.init_core(); -})(); diff --git a/kos/linux-deps.sh b/kos/linux-deps.sh deleted file mode 100644 index 5df71d0bd..000000000 --- a/kos/linux-deps.sh +++ /dev/null @@ -1,2 +0,0 @@ -# ubuntu dependencies needed for NWJS binaries -sudo apt install libnss3-dev libasound2 diff --git a/kos/nw.toml b/kos/nw.toml deleted file mode 100644 index 5b5895043..000000000 --- a/kos/nw.toml +++ /dev/null @@ -1,65 +0,0 @@ -[application] -name = "kaspa-os" -version = "Cargo.toml::package.version" -title = "Kaspa OS" -organization = "Kaspa Contributors" - -[description] -short = "Kaspa Desktop OS" -long = """ -Kaspa Desktop OS -"""" - -[package] -root = ".." -# resources = "resources/setup" -# exclude = ["resources/setup"] -exclude = [{ glob = ["{src/*,target/*,test/*,resources/setup/*,*.lock,*.toml,.git*,build*}"] }] -output = "../setup" -use-app-nw = true -update-package-json = true -build = [{ WASM = { name = "kaspa", outdir = "app/wasm" }}] - -[nwjs] -version = "0.77.0" -windows = "0.72.0" -ffmpeg = false - -[macos-disk-image] -# window_caption_height = 60 -# icon_size = 72 -# window_position = [200,200] -# window_size = [485,330] -application_icon_position = [100,178] -system_applications_folder_position = [385,178] - -[windows] -uuid = "9464f462-db23-4f78-a027-c864db698121" -group = "Kaspa" -# run_on_startup = "everyone" -run_after_setup = true - -# [languages] -# languages = ["english"] - -[firewall] -application = { direction = "in+out" } -rules = [ - { name = "Kaspad", program = "bin\\kaspad.exe", direction="in+out" } -] - -[[action]] -stage = "build" -name = "building rusty kaspa daemon (bin/kaspad)" -items = [ - { run = { cmd = "cargo build --release --bin kaspad", cwd = ".." } }, - { copy = { file = "../target/release/kaspad$EXE", to = "$TARGET/bin/" } }, -] - -[[action]] -stage = "build" -name = "building kaspa CPU miner (bin/kaspa-cpu-miner)" -items = [ - { run = { cmd = "cargo build --release", cwd = "../../kaspa-cpu-miner" } }, - { copy = { file = "../../kaspa-cpu-miner/target/release/kaspa-miner$EXE", to = "$TARGET/bin/kaspa-cpu-miner$EXE" } }, -] diff --git a/kos/package b/kos/package deleted file mode 100755 index 17ec81cc9..000000000 --- a/kos/package +++ /dev/null @@ -1,24 +0,0 @@ - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - $INSTALLER = "snap" -elif [[ "$OSTYPE" == "darwin"* ]]; then - $INSTALLER = "dmg" -elif [[ "$OSTYPE" == "cygwin" ]]; then - $INSTALLER = "innosetup" -elif [[ "$OSTYPE" == "msys" ]]; then - $INSTALLER = "innosetup" -elif [[ "$OSTYPE" == "win32" ]]; then - $INSTALLER = "innosetup" -elif [[ "$OS" == "Windows"* ]]; then - $INSTALLER = "innosetup" -elif [[ "$OSTYPE" == "freebsd"* ]]; then - echo "FreeBSD is not supported" -else - echo "Unknown operating system" -fi - -if [ "$1" = "--dev" ]; then - cargo nw build --sdk $INSTALLER -else - cargo nw build $INSTALLER -fi diff --git a/kos/package.json b/kos/package.json deleted file mode 100644 index 0a6affa60..000000000 --- a/kos/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "kaspa-os", - "main": "index.js", - "description": "Kaspa OS", - "version": "0.1.0", - "chromium-args": "--disable-background-timer-throttling" -} \ No newline at end of file diff --git a/kos/package.ps1 b/kos/package.ps1 deleted file mode 100644 index edf4918f0..000000000 --- a/kos/package.ps1 +++ /dev/null @@ -1,6 +0,0 @@ - -if ($args.Contains("--dev")) { - & "cargo nw build --sdk innosetup" -} else { - & "cargo nw build innosetup" -} diff --git a/kos/resources/icons/tray-icon@2x.png b/kos/resources/icons/tray-icon@2x.png deleted file mode 100644 index efc89ec40..000000000 Binary files a/kos/resources/icons/tray-icon@2x.png and /dev/null differ diff --git a/kos/resources/setup/application.png b/kos/resources/setup/application.png deleted file mode 100644 index 8e656ae7a..000000000 Binary files a/kos/resources/setup/application.png and /dev/null differ diff --git a/kos/resources/setup/document.png b/kos/resources/setup/document.png deleted file mode 100644 index 6a8d7dfbf..000000000 Binary files a/kos/resources/setup/document.png and /dev/null differ diff --git a/kos/resources/setup/innosetup-wizard-large.png b/kos/resources/setup/innosetup-wizard-large.png deleted file mode 100644 index 0837f5598..000000000 Binary files a/kos/resources/setup/innosetup-wizard-large.png and /dev/null differ diff --git a/kos/resources/setup/innosetup-wizard-small.png b/kos/resources/setup/innosetup-wizard-small.png deleted file mode 100644 index 4246599c3..000000000 Binary files a/kos/resources/setup/innosetup-wizard-small.png and /dev/null differ diff --git a/kos/resources/setup/macos-application.png b/kos/resources/setup/macos-application.png deleted file mode 100644 index 476d0f6c5..000000000 Binary files a/kos/resources/setup/macos-application.png and /dev/null differ diff --git a/kos/resources/setup/macos-disk-image-background.png b/kos/resources/setup/macos-disk-image-background.png deleted file mode 100644 index d824c0e54..000000000 Binary files a/kos/resources/setup/macos-disk-image-background.png and /dev/null differ diff --git a/kos/run b/kos/run deleted file mode 100755 index cd21f05c8..000000000 --- a/kos/run +++ /dev/null @@ -1,6 +0,0 @@ - -if [ "$1" = "--dev" ]; then - cargo nw run --sdk -else - cargo nw run -fi diff --git a/kos/src/core/core.rs b/kos/src/core/core.rs deleted file mode 100644 index c85065bb6..000000000 --- a/kos/src/core/core.rs +++ /dev/null @@ -1,654 +0,0 @@ -use kaspa_wallet_core::settings::{application_folder, ensure_application_folder}; - -use crate::imports::*; - -#[derive(Debug, Clone)] -pub struct Terminal { - #[allow(dead_code)] - window: Arc, - ipc: TerminalIpc, -} - -impl Terminal { - fn new(window: Arc) -> Self { - Terminal { ipc: TerminalIpc::new(window.clone().into()), window } - } - - #[allow(dead_code)] - pub fn window(&self) -> &Arc { - &self.window - } - - pub fn ipc(&self) -> &TerminalIpc { - &self.ipc - } -} - -#[derive(Debug, Clone)] -pub struct Metrics { - #[allow(dead_code)] - window: Arc, - #[allow(dead_code)] - ipc: MetricsIpc, -} - -impl Metrics { - fn new(window: Arc) -> Self { - Metrics { ipc: MetricsIpc::new(window.clone().into()), window } - } - - #[allow(dead_code)] - pub fn window(&self) -> &Arc { - &self.window - } - - #[allow(dead_code)] - pub fn ipc(&self) -> &MetricsIpc { - &self.ipc - } -} - -/// Global application object created on application initialization. -static mut CORE: Option> = None; - -/// Application struct wrapping `workflow_nw::Application` as an inner. -#[derive(Clone)] -pub struct Core { - pub inner: Arc, - pub ipc: Arc>, - terminal: Arc>>>, - metrics: Arc>>>, - pub kaspad: Arc, - pub cpu_miner: Arc, - pub task_ctl: DuplexChannel, - pub terminal_ready_ctl: Channel<()>, - pub metrics_ready_ctl: Channel<()>, - pub shutdown_ctl: Channel<()>, - pub settings: Arc>, -} - -unsafe impl Send for Core {} -unsafe impl Sync for Core {} - -impl Core { - /// Get access to the global application object - #[allow(dead_code)] - pub fn global() -> Option> { - unsafe { CORE.clone() } - } - - /// Create a new application instance - pub async fn try_new() -> Result> { - log_info!("-> loading core settings"); - let settings = Arc::new(SettingsStore::::try_new("core")?); - settings.try_load().await?; - - log_info!("-> creating core application instance"); - let app = Arc::new(Self { - inner: Application::new()?, - ipc: Ipc::try_new_global_binding(Modules::Core)?, - terminal: Arc::new(Mutex::new(Option::None)), - metrics: Arc::new(Mutex::new(Option::None)), - kaspad: Arc::new(Kaspad::default()), - cpu_miner: Arc::new(CpuMiner::default()), - task_ctl: DuplexChannel::oneshot(), - terminal_ready_ctl: Channel::oneshot(), - metrics_ready_ctl: Channel::oneshot(), - shutdown_ctl: Channel::oneshot(), - settings, - }); - - unsafe { - CORE = Some(app.clone()); - }; - - Ok(app) - } - - pub fn terminal(&self) -> Arc { - self.terminal.lock().unwrap().as_ref().unwrap().clone() - } - - pub fn metrics(&self) -> Option> { - self.metrics.lock().unwrap().clone() - } - - /// Create application menu - fn create_menu(self: &Arc) -> Result<()> { - let modifier = if is_macos() { "command" } else { "ctrl" }; - - let this = self.clone(); - let clipboard_copy = MenuItemBuilder::new() - .label("Copy") - // .key("c") - // .modifiers(modifier) - .callback(move |_| -> std::result::Result<(), JsValue> { - let this = this.clone(); - spawn(async move { - this.terminal().ipc().clipboard_copy().await.unwrap_or_else(|e| log_error!("{}", e)); - }); - Ok(()) - }) - .build()?; - - let this = self.clone(); - let clipboard_paste = MenuItemBuilder::new() - .label("Paste") - // .key("v") - // .modifiers(modifier) - .callback(move |_| -> std::result::Result<(), JsValue> { - let this = this.clone(); - spawn(async move { - this.terminal().ipc().clipboard_paste().await.unwrap_or_else(|e| log_error!("{}", e)); - }); - Ok(()) - }) - .build()?; - - let this = self.clone(); - let increase_font = MenuItemBuilder::new() - .label("Increase Font") - .key(if is_windows() { "=" } else { "+" }) - .modifiers(modifier) - .callback(move |_| -> std::result::Result<(), JsValue> { - // window().alert_with_message("Hello")?; - let this = this.clone(); - spawn(async move { - this.terminal().ipc().increase_font_size().await.unwrap_or_else(|e| log_error!("{}", e)); - }); - Ok(()) - }) - .build()?; - - let this = self.clone(); - let decrease_font = MenuItemBuilder::new() - .label("Decrease Font") - .key("-") - .modifiers(modifier) - .callback(move |_| -> std::result::Result<(), JsValue> { - // window().alert_with_message("Hello")?; - let this = this.clone(); - spawn(async move { - this.terminal().ipc().decrease_font_size().await.unwrap_or_else(|e| log_error!("{}", e)); - }); - Ok(()) - }) - .build()?; - - let this = self.clone(); - let toggle_metrics = MenuItemBuilder::new() - .label("Toggle Metrics") - .key("M") - .modifiers(modifier) - .callback(move |_| -> std::result::Result<(), JsValue> { - // window().alert_with_message("Hello")?; - let this = this.clone(); - spawn(async move { - this.toggle_metrics().await.unwrap_or_else(|e| log_error!("{}", e)); - // this.terminal().ipc().decrease_font_size().await.unwrap_or_else(|e| log_error!("{}", e)); - }); - Ok(()) - }) - .build()?; - - let terminal_item = MenuItemBuilder::new() - .label("Terminal") - .submenus(vec![clipboard_copy, clipboard_paste, menu_separator(), increase_font, decrease_font]) - .build()?; - - let metrics_item = MenuItemBuilder::new().label("Metrics").submenus(vec![toggle_metrics]).build()?; - MenubarBuilder::new("Kaspa OS", is_macos()) - .mac_hide_edit(true) - .mac_hide_window(true) - .append(terminal_item) - .append(metrics_item) - .build(true)?; - - Ok(()) - } - - /// Create application tray icon - pub fn _create_tray_icon(&self) -> Result<()> { - let _tray = TrayMenuBuilder::new() - .icon("resources/icons/tray-icon@2x.png") - .icons_are_templates(false) - .callback(|_| { - window().alert_with_message("Tray Icon click")?; - Ok(()) - }) - .build()?; - Ok(()) - } - - /// Create application tray icon and tray menu - pub fn _create_tray_icon_with_menu(self: Arc) -> Result<()> { - let this = self; - let submenu_1 = MenuItemBuilder::new() - .label("TEST IPC") - .key("6") - .modifiers("ctrl") - .callback(move |_| -> std::result::Result<(), JsValue> { - let this = this.clone(); - - spawn(async move { - let target = IpcTarget::new(this.terminal.lock().unwrap().as_ref().unwrap().window.as_ref()); - let req = TestReq { req: "Hello World...".to_string() }; - let _resp = target.call::(TermOps::TestTerminal, req).await; - }); - - Ok(()) - }) - .build()?; - - let exit_menu = MenuItemBuilder::new() - .label("Exit") - .callback(move |_| -> std::result::Result<(), JsValue> { - window().alert_with_message("TODO: Exit")?; - Ok(()) - }) - .build()?; - - let _tray = TrayMenuBuilder::new() - .icon("resources/icons/tray-icon@2x.png") - .icons_are_templates(false) - .submenus(vec![submenu_1, menu_separator(), exit_menu]) - .build()?; - - Ok(()) - } - - /// Create a custom application context menu - #[allow(dead_code)] - pub fn create_context_menu(self: Arc) -> Result<()> { - let item_1 = MenuItemBuilder::new() - .label("Sub Menu 1") - .callback(move |_| -> std::result::Result<(), JsValue> { - window().alert_with_message("Context menu 1 clicked")?; - Ok(()) - }) - .build()?; - - let item_2 = MenuItemBuilder::new() - .label("Sub Menu 2") - .callback(move |_| -> std::result::Result<(), JsValue> { - window().alert_with_message("Context menu 2 clicked")?; - Ok(()) - }) - .build()?; - - self.inner.create_context_menu(vec![item_1, item_2])?; - - Ok(()) - } - - fn register_ipc_handlers(self: &Arc) -> Result<()> { - let this = self.clone(); - self.ipc.method( - CoreOps::KaspadCtl, - Method::new(move |op: KaspadOps| { - let this = this.clone(); - Box::pin(async move { - match op { - KaspadOps::Configure(config) => { - this.kaspad.configure(config)?; - } - KaspadOps::DaemonCtl(ctl) => match ctl { - DaemonCtl::Start => { - this.kaspad.start()?; - } - DaemonCtl::Stop => { - this.kaspad.stop()?; - } - DaemonCtl::Join => { - this.kaspad.join().await?; - } - DaemonCtl::Restart => { - this.kaspad.restart()?; - } - DaemonCtl::Kill => { - this.kaspad.kill()?; - } - DaemonCtl::Mute(mute) => { - this.kaspad.mute(mute).await?; - } - DaemonCtl::ToggleMute => { - this.kaspad.toggle_mute().await?; - } - }, - } - - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::KaspadStatus, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - let uptime = this.kaspad.uptime().map(|u| u.as_secs()); - Ok(DaemonStatus { uptime }) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::KaspadVersion, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - let version = this.kaspad.version().await?; - Ok(version) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::CpuMinerCtl, - Method::new(move |op: CpuMinerOps| { - let this = this.clone(); - Box::pin(async move { - match op { - CpuMinerOps::Configure(config) => { - this.cpu_miner.configure(config)?; - } - CpuMinerOps::DaemonCtl(ctl) => match ctl { - DaemonCtl::Start => { - this.cpu_miner.start()?; - } - DaemonCtl::Stop => { - this.cpu_miner.stop()?; - } - DaemonCtl::Join => { - this.cpu_miner.join().await?; - } - DaemonCtl::Restart => { - this.cpu_miner.restart()?; - } - DaemonCtl::Kill => { - this.cpu_miner.kill()?; - } - DaemonCtl::Mute(mute) => { - this.cpu_miner.mute(mute).await?; - } - DaemonCtl::ToggleMute => { - this.cpu_miner.toggle_mute().await?; - } - }, - } - - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::CpuMinerStatus, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - let uptime = this.cpu_miner.uptime().map(|u| u.as_secs()); - Ok(DaemonStatus { uptime }) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::CpuMinerVersion, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - let version = this.cpu_miner.version().await?; - Ok(version) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::MetricsOpen, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - this.settings.set(CoreSettings::Metrics, true).await.ok(); - this.create_metrics_window().await?; - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::MetricsCtl, - Method::new(move |op: MetricsCtl| { - let this = this.clone(); - Box::pin(async move { - this.metrics_ctl(op).await?; - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::TerminalReady, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - this.terminal_ready_ctl.send(()).await.unwrap_or_else(|e| log_error!("Error signaling terminal init: {e}")); - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::MetricsReady, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - this.metrics_ready_ctl.send(()).await.unwrap_or_else(|e| log_error!("Error signaling terminal init: {e}")); - this.terminal().ipc().metrics_ctl(MetricsSinkCtl::Activate).await.unwrap_or_else(|e| log_error!("{}", e)); - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::MetricsClose, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - this.destroy_metrics_window().await.unwrap_or_else(|e| log_error!("{}", e)); - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - CoreOps::Shutdown, - Method::new(move |_op: ()| { - let this = this.clone(); - Box::pin(async move { - this.shutdown_ctl.send(()).await.unwrap_or_else(|err| log_error!("{}", err)); - Ok(()) - }) - }), - ); - - Ok(()) - } - - pub async fn handle_event(self: &Arc, event: DaemonEvent) -> Result<()> { - self.terminal().ipc().relay_event(event).await?; - - Ok(()) - } - - pub async fn start_task(self: &Arc) -> Result<()> { - let this = self.clone(); - let task_ctl_receiver = self.task_ctl.request.receiver.clone(); - let task_ctl_sender = self.task_ctl.response.sender.clone(); - let kaspad_events_receiver = self.kaspad.events().receiver.clone(); - let cpu_miner_events_receiver = self.cpu_miner.events().receiver.clone(); - - spawn(async move { - loop { - select! { - _ = task_ctl_receiver.recv().fuse() => { - break; - }, - event = kaspad_events_receiver.recv().fuse() => { - if let Ok(event) = event { - this.handle_event(DaemonEvent::new(DaemonKind::Kaspad, event)).await.unwrap_or_else(|err| { - log_error!("error while handling kaspad stdout: {err}"); - }); - } - }, - event = cpu_miner_events_receiver.recv().fuse() => { - if let Ok(event) = event { - this.handle_event(DaemonEvent::new(DaemonKind::CpuMiner, event)).await.unwrap_or_else(|err| { - log_error!("error while handling cpu miner stdout: {err}"); - }); - } - }, - } - } - - task_ctl_sender.send(()).await.unwrap(); - }); - - Ok(()) - } - - pub async fn stop_task(&self) -> Result<()> { - self.task_ctl.signal(()).await.expect("Core::stop_task() `signal` error"); - Ok(()) - } - - pub async fn create_terminal_window(self: &Arc) -> Result<()> { - let window = Arc::new( - Application::create_window_async( - "/app/index.html", - &nw_sys::window::Options::new().new_instance(false).height(768).width(1280).show(false), - ) - .await?, - ); - - self.terminal.lock().unwrap().replace(Arc::new(Terminal::new(window))); - - self.terminal_ready_ctl.recv().await.unwrap_or_else(|e| { - log_error!("Core::main() `terminal_ready_ctl` error: {e}"); - }); - - Ok(()) - } - - pub async fn create_metrics_window(self: &Arc) -> Result<()> { - if self.metrics().is_none() { - // log_info!("*** CREATING WINDOW ***"); - let window = Arc::new( - Application::create_window_async( - "/app/metrics.html", - &nw_sys::window::Options::new().new_instance(false).height(768).width(1280).show(false), - ) - .await - .expect("Core: failed to create metrics window"), - ); - // log_info!("*** WINDOW CREATED ***"); - let metrics = Arc::new(Metrics::new(window)); - *self.metrics.lock().unwrap() = Some(metrics); - - self.metrics_ready_ctl.recv().await.unwrap_or_else(|e| { - log_error!("Core::main() `terminal_ready_ctl` error: {e}"); - }); - } - Ok(()) - } - - pub async fn destroy_metrics_window(self: &Arc) -> Result<()> { - if let Some(metrics) = self.metrics() { - self.settings.set(CoreSettings::Metrics, false).await.ok(); - self.terminal().ipc().metrics_ctl(MetricsSinkCtl::Deactivate).await.unwrap_or_else(|e| log_error!("{}", e)); - metrics.window().close_impl(true); - self.metrics.lock().unwrap().take(); - } - Ok(()) - } - - pub async fn metrics_ctl(self: &Arc, _ctl: MetricsCtl) -> Result<()> { - if let Some(_metrics) = self.metrics() { - // metrics.ctl(ctl).await?; - } - Ok(()) - } - - pub async fn toggle_metrics(self: &Arc) -> Result<()> { - if self.metrics().is_none() { - self.create_metrics_window().await.unwrap_or_else(|e| log_error!("Core::toggle_metrics() error: {e}")); - } else { - self.destroy_metrics_window().await.unwrap_or_else(|e| log_error!("Core::toggle_metrics() error: {e}")); - } - Ok(()) - } - - pub async fn main(self: &Arc) -> Result<()> { - log_info!("-> register ipc handlers"); - self.register_ipc_handlers()?; - - log_info!("-> create terminal window"); - self.create_terminal_window().await?; - - log_info!("-> create application menu"); - self.create_menu()?; - - log_info!("-> start daemon event relay task"); - self.start_task().await?; - - // self.terminal_ready_ctl.recv().await.unwrap_or_else(|e| { - // log_error!("Core::main() `terminal_init_ctl` error: {e}"); - // }); - - log_info!("-> create metrics window"); - if let Some(metrics) = self.settings.get(CoreSettings::Metrics) { - if metrics { - self.create_metrics_window().await?; - } - } - - log_info!("-> await shutdown signal ..."); - self.shutdown_ctl.recv().await?; - - log_info!("-> shutdown daemon event relay task"); - self.stop_task().await?; - - Ok(()) - } -} - -#[wasm_bindgen] -pub async fn init_core() -> Result<()> { - workflow_wasm::panic::init_console_panic_hook(); - kaspa_core::log::set_log_level(LevelFilter::Info); - - if let Err(e) = ensure_application_folder().await { - let home_dir = application_folder().map(|f| f.display().to_string()).unwrap_or("???".to_string()); - let err = format!("Unable to access user home folder `{home_dir}` (do you have access?): {e}"); - window().alert_with_message(&err)?; - } - - let core = Core::try_new().await?; - core.main().await?; - - nw_sys::app::quit(); - - Ok(()) -} diff --git a/kos/src/core/ipc.rs b/kos/src/core/ipc.rs deleted file mode 100644 index 90544ab20..000000000 --- a/kos/src/core/ipc.rs +++ /dev/null @@ -1,202 +0,0 @@ -use crate::imports::*; - -#[derive(Debug, Clone, PartialEq, Eq, Hash, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum CoreOps { - TestBg, - Shutdown, - TerminalReady, - KaspadCtl, - KaspadStatus, - KaspadVersion, - CpuMinerCtl, - CpuMinerStatus, - CpuMinerVersion, - MetricsOpen, - MetricsClose, - MetricsReady, - MetricsCtl, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub struct TestReq { - pub req: String, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub struct TestResp { - pub resp: String, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum DaemonCtl { - Start, - Stop, - Join, - Restart, - Kill, - Mute(bool), - ToggleMute, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum KaspadOps { - Configure(KaspadConfig), - DaemonCtl(DaemonCtl), -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum CpuMinerOps { - Configure(CpuMinerConfig), - DaemonCtl(DaemonCtl), -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum MetricsCtl { - Retention(u64), -} - -#[derive(Debug, Clone)] -pub struct CoreIpc { - target: IpcTarget, -} - -impl CoreIpc { - pub fn new(target: IpcTarget) -> CoreIpc { - CoreIpc { target } - } - - pub async fn shutdown(&self) -> Result<()> { - self.target.call(CoreOps::Shutdown, ()).await?; - Ok(()) - } - - pub async fn metrics_open(&self) -> Result<()> { - self.target.call(CoreOps::MetricsOpen, ()).await?; - Ok(()) - } - - pub async fn metrics_close(&self) -> Result<()> { - self.target.call(CoreOps::MetricsClose, ()).await?; - Ok(()) - } - - pub async fn metrics_ctl(&self, ctl: MetricsCtl) -> Result<()> { - self.target.call(CoreOps::MetricsCtl, ctl).await?; - Ok(()) - } - - pub async fn metrics_ready(&self) -> Result<()> { - self.target.call(CoreOps::MetricsReady, ()).await?; - Ok(()) - } - - pub async fn terminal_ready(&self) -> Result<()> { - self.target.call(CoreOps::TerminalReady, ()).await?; - Ok(()) - } -} - -#[async_trait] -impl KaspadCtl for CoreIpc { - async fn configure(&self, config: KaspadConfig) -> DaemonResult<()> { - // self.target.call::<_, _, ()>(CoreOps::KaspadCtl, KaspadOps::Configure(config)).await?; - self.target.call(CoreOps::KaspadCtl, KaspadOps::Configure(config)).await?; - - Ok(()) - } - - async fn start(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Start)).await?; - Ok(()) - } - - async fn stop(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Stop)).await?; - Ok(()) - } - - async fn join(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Join)).await?; - Ok(()) - } - - async fn restart(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Restart)).await?; - Ok(()) - } - - async fn kill(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Kill)).await?; - Ok(()) - } - - async fn status(&self) -> DaemonResult { - Ok(self.target.call(CoreOps::KaspadStatus, ()).await?) - } - - async fn version(&self) -> DaemonResult { - Ok(self.target.call(CoreOps::KaspadVersion, ()).await?) - } - - async fn mute(&self, mute: bool) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::Mute(mute))).await?; - Ok(()) - } - - async fn toggle_mute(&self) -> DaemonResult<()> { - self.target.call(CoreOps::KaspadCtl, KaspadOps::DaemonCtl(DaemonCtl::ToggleMute)).await?; - Ok(()) - } -} - -#[async_trait] -impl CpuMinerCtl for CoreIpc { - async fn configure(&self, config: CpuMinerConfig) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, CpuMinerOps::Configure(config)).await?; - - Ok(()) - } - - async fn start(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Start)).await?; - Ok(()) - } - - async fn stop(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Stop)).await?; - Ok(()) - } - - async fn join(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Join)).await?; - Ok(()) - } - - async fn restart(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Restart)).await?; - Ok(()) - } - - async fn kill(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Kill)).await?; - Ok(()) - } - - async fn status(&self) -> DaemonResult { - Ok(self.target.call(CoreOps::CpuMinerStatus, ()).await?) - } - - async fn version(&self) -> DaemonResult { - Ok(self.target.call(CoreOps::CpuMinerVersion, ()).await?) - } - - async fn mute(&self, mute: bool) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::Mute(mute))).await?; - Ok(()) - } - - async fn toggle_mute(&self) -> DaemonResult<()> { - self.target.call(CoreOps::CpuMinerCtl, KaspadOps::DaemonCtl(DaemonCtl::ToggleMute)).await?; - Ok(()) - } -} diff --git a/kos/src/core/mod.rs b/kos/src/core/mod.rs deleted file mode 100644 index 2c8efc988..000000000 --- a/kos/src/core/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[allow(clippy::module_inception)] -mod core; -mod ipc; -pub use ipc::*; -mod settings; -pub use settings::*; diff --git a/kos/src/core/settings.rs b/kos/src/core/settings.rs deleted file mode 100644 index a79e41cd0..000000000 --- a/kos/src/core/settings.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::imports::*; - -#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[serde(rename_all = "lowercase")] -pub enum CoreSettings { - Metrics, -} - -#[async_trait] -impl DefaultSettings for CoreSettings { - async fn defaults() -> Vec<(Self, Value)> { - vec![] - } -} diff --git a/kos/src/error.rs b/kos/src/error.rs deleted file mode 100644 index c16cc906d..000000000 --- a/kos/src/error.rs +++ /dev/null @@ -1,107 +0,0 @@ -use downcast::DowncastError; -use kaspa_daemon::error::Error as DaemonError; -use thiserror::Error; -use wasm_bindgen::JsValue; -use workflow_core::channel::ChannelError; -use workflow_nw::ipc::ResponseError; -use workflow_wasm::printable::Printable; - -#[derive(Error, Debug)] -pub enum Error { - #[error("{0}")] - Custom(String), - - #[error(transparent)] - Io(#[from] std::io::Error), - - #[error(transparent)] - Utf8(#[from] std::string::FromUtf8Error), - - #[error(transparent)] - WorkflowNw(#[from] workflow_nw::error::Error), - - #[error(transparent)] - Cli(#[from] kaspa_cli_lib::error::Error), - - #[error(transparent)] - Ipc(#[from] workflow_nw::ipc::error::Error), - - #[error("{0}")] - JsValue(Printable), - - #[error("{0}")] - Terminal(#[from] workflow_terminal::error::Error), - - #[error("channel error")] - Recv(#[from] workflow_core::channel::RecvError), - - #[error(transparent)] - Callback(#[from] workflow_wasm::callback::CallbackError), - - #[error("{0}")] - Downcast(String), - - #[error("Channel error")] - Channel(String), - - #[error(transparent)] - Daemon(#[from] kaspa_daemon::error::Error), - - #[error(transparent)] - Wallet(#[from] kaspa_wallet_core::error::Error), - - #[error(transparent)] - Dom(#[from] workflow_dom::error::Error), - - #[error(transparent)] - D3(#[from] workflow_d3::error::Error), -} - -impl From for JsValue { - fn from(err: Error) -> JsValue { - let s: String = err.to_string(); - JsValue::from_str(&s) - } -} - -impl From for Error { - fn from(js_value: JsValue) -> Error { - Error::JsValue(Printable::new(js_value)) - } -} - -impl From for ResponseError { - fn from(err: Error) -> ResponseError { - ResponseError::Custom(err.to_string()) - } -} - -impl From for DaemonError { - fn from(err: Error) -> DaemonError { - DaemonError::Custom(err.to_string()) - } -} - -impl From for Error { - fn from(err: String) -> Self { - Self::Custom(err) - } -} - -impl From<&str> for Error { - fn from(err: &str) -> Self { - Self::Custom(err.to_string()) - } -} - -impl From> for Error { - fn from(e: DowncastError) -> Self { - Error::Downcast(e.to_string()) - } -} - -impl From> for Error { - fn from(e: ChannelError) -> Error { - Error::Channel(e.to_string()) - } -} diff --git a/kos/src/imports.rs b/kos/src/imports.rs deleted file mode 100644 index c38dc7f0c..000000000 --- a/kos/src/imports.rs +++ /dev/null @@ -1,30 +0,0 @@ -pub use crate::core::MetricsCtl; -pub use crate::core::*; -pub use crate::ipc::*; -pub use crate::layout::Layout; -pub use crate::metrics::*; -pub use crate::result::Result; -pub use crate::terminal::*; -pub use async_trait::async_trait; -pub use borsh::{BorshDeserialize, BorshSerialize}; -pub use futures::{select, stream::StreamExt, FutureExt}; -pub use kaspa_cli_lib::{KaspaCli, Options as KaspaCliOptions}; -pub use kaspa_daemon::{ - CpuMiner, CpuMinerConfig, CpuMinerCtl, DaemonEvent, DaemonKind, DaemonStatus, Daemons, Kaspad, KaspadConfig, KaspadCtl, - Result as DaemonResult, -}; -pub use kaspa_wallet_core::settings::{DefaultSettings, SettingsStore, SettingsStoreT}; -pub use nw_sys::prelude::*; -pub use serde::{Deserialize, Serialize}; -pub use serde_json::Value; -pub use wasm_bindgen::prelude::*; -pub use workflow_core::channel::*; -pub use workflow_core::runtime::*; -pub use workflow_core::task::*; -pub use workflow_core::time::*; -pub use workflow_log::*; -pub use workflow_nw::ipc::*; -pub use workflow_nw::prelude::*; -pub use workflow_terminal::prelude::*; -pub use workflow_terminal::{CrLf, Options as TerminalOptions}; -pub use workflow_wasm::callback::{callback, AsCallback, CallbackMap}; diff --git a/kos/src/ipc.rs b/kos/src/ipc.rs deleted file mode 100644 index 195920288..000000000 --- a/kos/src/ipc.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::fmt; - -#[derive(Clone, Debug)] -pub enum Modules { - Core, - Terminal, - Metrics, -} - -impl fmt::Display for Modules { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Modules::Core => write!(f, "core"), - Modules::Terminal => write!(f, "terminal"), - Modules::Metrics => write!(f, "metrics"), - } - } -} diff --git a/kos/src/layout.rs b/kos/src/layout.rs deleted file mode 100644 index 0a882d812..000000000 --- a/kos/src/layout.rs +++ /dev/null @@ -1,69 +0,0 @@ -use crate::imports::*; - -#[derive(Serialize, Deserialize, Debug, Clone)] -struct Position { - x: u32, - y: u32, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -struct Size { - width: u32, - height: u32, -} - -pub struct Layout -where - S: SettingsStoreT, -{ - pub callbacks: CallbackMap, - pub settings: Arc, - pub window: Arc, -} - -impl Layout -where - S: SettingsStoreT, -{ - pub async fn try_new(window: &Arc, settings: &Arc) -> Result { - let callbacks = CallbackMap::new(); - - let settings_ = settings.clone(); - let move_window = callback!(move |x: u32, y: u32| { - let settings_ = settings_.clone(); - let position = Position { x, y }; - spawn(async move { - settings_.set("window.position", position).await.unwrap_or_else(|err| { - log_error!("Unable to store window position: {err}"); - }); - }) - }); - window.on("move", move_window.as_ref()); - callbacks.retain(move_window)?; - - let settings_ = settings.clone(); - let resize_window = callback!(move |width: u32, height: u32| { - let settings_ = settings_.clone(); - let size = Size { width, height }; - spawn(async move { - settings_.set("window.size", size).await.unwrap_or_else(|err| { - log_error!("Unable to store window size: {err}"); - }); - }) - }); - window.on("resize", resize_window.as_ref()); - callbacks.retain(resize_window)?; - - if let Some(position) = settings.get::("window.position").await { - window.move_to(position.x, position.y); - } - - if let Some(size) = settings.get::("window.size").await { - window.resize_to(size.width, size.height); - } - - window.show(); - - Ok(Self { callbacks, settings: settings.clone(), window: window.clone() }) - } -} diff --git a/kos/src/lib.rs b/kos/src/lib.rs deleted file mode 100644 index db8ff8a1f..000000000 --- a/kos/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod core; -mod error; -mod imports; -mod ipc; -mod layout; -mod metrics; -mod modules; -mod result; -mod terminal; diff --git a/kos/src/metrics/ipc.rs b/kos/src/metrics/ipc.rs deleted file mode 100644 index 34e32dc20..000000000 --- a/kos/src/metrics/ipc.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::imports::*; -use kaspa_metrics_core::MetricsSnapshot; - -#[derive(Debug, Clone, PartialEq, Eq, Hash, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum MetricsOps { - MetricsSnapshot, -} - -#[derive(Debug, Clone)] -pub struct MetricsIpc { - #[allow(dead_code)] - target: IpcTarget, -} - -impl MetricsIpc { - pub fn new(target: IpcTarget) -> MetricsIpc { - MetricsIpc { target } - } -} - -#[async_trait] -pub trait MetricsCtl: Send + Sync + 'static { - async fn post_data(&self, data: MetricsSnapshot) -> Result<()>; -} diff --git a/kos/src/metrics/metrics.rs b/kos/src/metrics/metrics.rs deleted file mode 100644 index fca64b4af..000000000 --- a/kos/src/metrics/metrics.rs +++ /dev/null @@ -1,186 +0,0 @@ -use super::toolbar::*; -use crate::imports::*; -use kaspa_metrics_core::{Metric, MetricsSnapshot}; -use std::collections::HashMap; -use workflow_core::time::{HOURS, MINUTES}; -use workflow_d3::container::*; -use workflow_d3::graph::*; - -static mut METRICS: Option> = None; - -#[derive(Clone)] -pub struct Metrics { - pub inner: Arc, - pub ipc: Arc>, - pub core: Arc, - pub window: Arc, - pub callbacks: CallbackMap, - pub settings: Arc>, - pub layout: Arc>>, - pub container: Arc>>>, - pub graphs: Arc>>>, - pub toolbar: Toolbar, -} - -impl Metrics { - pub async fn try_new() -> Result> { - workflow_d3::load().await?; - - let core_ipc_target = get_ipc_target(Modules::Core).await?.expect("Unable to acquire background window"); - let core = Arc::new(CoreIpc::new(core_ipc_target)); - - let settings = Arc::new(SettingsStore::::try_new("metrics")?); - settings.try_load().await?; - // - TODO - setup graph time duration - let _default_duration = settings.get::(MetricsSettings::Duration); - - let window = Arc::new(nw_sys::window::get()); - - let layout = Arc::new(Layout::try_new(&window, &settings).await?); - let container = Arc::new(Mutex::new(None)); - let graphs = Arc::new(Mutex::new(HashMap::new())); - let toolbar = Toolbar::try_new(&window.window(), &container, &graphs)?; - toolbar.try_init()?; - let app = Arc::new(Self { - inner: Application::new()?, - ipc: Ipc::try_new_window_binding(&window, Modules::Metrics)?, - core, - window, - callbacks: CallbackMap::default(), - // shutdown: Arc::new(AtomicBool::new(false)), - settings, - layout, - container, - graphs, - toolbar, - }); - - unsafe { - METRICS = Some(app.clone()); - }; - - Ok(app) - } - - fn register_ipc_handlers(self: &Arc) -> Result<()> { - let this = self.clone(); - self.ipc.notification( - MetricsOps::MetricsSnapshot, - Notification::new(move |data: MetricsSnapshot| { - let this = this.clone(); - Box::pin(async move { - // log_info!("Received metrics data: {:?}", data); - this.ingest(data).await?; - yield_executor().await; - Ok(()) - }) - }), - ); - - Ok(()) - } - - fn register_window_handlers(self: &Arc) -> Result<()> { - let this = self.clone(); - let close_window = callback!(move || { - let this = this.clone(); - spawn(async move { - this.core.metrics_close().await.expect("Unable to close metrics"); - }); - }); - self.window.on("close", close_window.as_ref()); - self.callbacks.retain(close_window)?; - - Ok(()) - } - - pub fn theme(name: &str, kind: &str) -> Box { - let font = "'Consolas', 'Lucida Grande', 'Roboto Mono', 'Source Code Pro', 'Trebuchet'"; - - let primary = match name { - "light" => "black", - "dark" => "#ccc", - _ => "grey", - }; - - let theme = match kind { - "kaspa" => GraphThemeOptions::new(font, primary, "rgb(220, 240, 231)", "rgb(17, 187, 125)", primary), - _ => GraphThemeOptions::new(font, primary, "rgb(220, 231, 240)", "rgb(17, 125, 187)", primary), - }; - - Box::new(theme) - } - - async fn init_graphs(self: &Arc) -> Result<()> { - let window = self.window.window(); - - Container::try_init().await?; - Graph::try_init(Some("graph")).await?; - - let container = Arc::new(Container::try_new(&window).await?); - *self.container.lock().unwrap() = Some(container.clone()); - let mut graphs = vec![]; - for metric in Metric::list() { - let graph = Arc::new( - Graph::try_new( - &self.window.window(), - &container, - None, - "", - Duration::from_millis(5 * MINUTES), - Duration::from_millis(48 * HOURS), - GraphTheme::Custom(Self::theme("light", metric.group())), - Margin::new(20.0, 20.0, 10.0, 30.0), - ) - .await?, - ); - self.graphs.lock().unwrap().insert(metric, graph.clone()); - graphs.push(graph); - } - - Ok(()) - } - - fn graph(&self, metric: &Metric) -> Arc { - self.graphs.lock().unwrap().get(metric).cloned().expect("Unable to find graph") - } - - async fn ingest(self: &Arc, data: MetricsSnapshot) -> Result<()> { - let si = true; - for metric in Metric::list() { - let value = data.get(&metric); - self.graph(&metric).ingest(data.unixtime_millis, value, &data.format(&metric, si, false)).await?; - } - - yield_executor().await; - sleep(Duration::from_millis(100)).await; - - Ok(()) - } - - async fn main(self: &Arc) -> Result<()> { - self.register_window_handlers()?; - self.register_ipc_handlers()?; - - self.init_graphs().await?; - - // this call reflects from core to terminal - // initiating metrics data relay - self.core.metrics_ready().await?; - - Ok(()) - } -} - -#[wasm_bindgen] -pub async fn init_metrics() -> Result<()> { - kaspa_core::log::set_log_level(LevelFilter::Info); - workflow_log::set_colors_enabled(true); - - let metrics = Metrics::try_new().await.unwrap_or_else(|err| { - panic!("Unable to initialize metrics: {:?}", err); - }); - metrics.main().await?; - - Ok(()) -} diff --git a/kos/src/metrics/mod.rs b/kos/src/metrics/mod.rs deleted file mode 100644 index c9ed93da5..000000000 --- a/kos/src/metrics/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod ipc; -#[allow(clippy::module_inception)] -mod metrics; -pub use ipc::*; -mod settings; -pub use settings::*; -mod toolbar; diff --git a/kos/src/metrics/settings.rs b/kos/src/metrics/settings.rs deleted file mode 100644 index e42e7990b..000000000 --- a/kos/src/metrics/settings.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::imports::*; - -#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[serde(rename_all = "lowercase")] -pub enum MetricsSettings { - Duration, -} - -#[async_trait] -impl DefaultSettings for MetricsSettings { - async fn defaults() -> Vec<(Self, Value)> { - vec![] - } -} diff --git a/kos/src/metrics/toolbar.css b/kos/src/metrics/toolbar.css deleted file mode 100644 index 0655518ca..000000000 --- a/kos/src/metrics/toolbar.css +++ /dev/null @@ -1,36 +0,0 @@ -.toolbar{ - padding:10px; - user-select: none; -} -.toolbar .control{display: inline-block} -.toolbar .separator{ - width: 1px; - background: #aaa; - display: inline-block; - height: 12px; - margin: 0px 5px; -} - -.toolbar .button{ - display:inline-block; - width: auto; - border:1px solid #CCC; - border-radius:4px; - padding:5px 8px; - margin:2px; - cursor:pointer; - transition: all 0.2s ease-out; - color:#171717 -} - -.toolbar .button:hover { - background-color: #f6f6f6; - transform-origin: center center; - transform: scale(1.12); -} -.toolbar .button:has(input:checked){ - background-color: #efefef; - border-color: #aaa; - color: #000; -} -.toolbar .button input{display:none;} diff --git a/kos/src/metrics/toolbar.rs b/kos/src/metrics/toolbar.rs deleted file mode 100644 index 41fe8c2a5..000000000 --- a/kos/src/metrics/toolbar.rs +++ /dev/null @@ -1,356 +0,0 @@ -#![allow(dead_code)] - -use crate::imports::*; -use crate::result::Result; -use std::{collections::HashMap, sync::MutexGuard}; - -use kaspa_metrics_core::Metric; -use web_sys::{Document, Element, MouseEvent}; -use workflow_d3::graph::GraphDuration; -#[allow(unused_imports)] -use workflow_d3::{container::Container, graph::Graph}; -use workflow_dom::inject::inject_css; - -#[derive(Clone, Debug)] -pub struct Count(usize, String); - -impl Count { - pub fn cols() -> [Count; 4] { - [Count(1, "L".into()), Count(2, "M".into()), Count(3, "S".into()), Count(4, "T".into())] - } - - pub fn rows() -> [Count; 5] { - [Count(1, "F".into()), Count(2, "L".into()), Count(4, "M".into()), Count(6, "S".into()), Count(8, "T".into())] - } - - fn get_cols(&self) -> String { - let w = 100.0 / self.0 as f64; - format!("width: calc({w}vw - 10px);") - } - - fn get_rows(&self) -> String { - let h = 100.0 / self.0 as f64; - format!("height: {h}vh;") - } -} - -type Rows = Count; -type Cols = Count; - -#[derive(Debug)] -pub enum Action { - Duration(Duration), - Cols(Count), - Rows(Count), -} - -pub struct ToolbarInner { - pub document: Document, - pub element: Element, - pub callbacks: CallbackMap, - pub container: Arc>>>, - pub graphs: Arc>>>, - pub controls: Arc>>>, - pub layout: Arc>, -} - -unsafe impl Send for ToolbarInner {} -unsafe impl Sync for ToolbarInner {} - -const STYLE: &str = include_str!("toolbar.css"); -static mut DOM_INIT: bool = false; - -#[derive(Clone)] -pub struct Toolbar { - inner: Arc, -} - -impl Toolbar { - pub fn try_new( - window: &web_sys::Window, - container: &Arc>>>, - graphs: &Arc>>>, - ) -> Result { - if !unsafe { DOM_INIT } { - inject_css(Some("toolbar-style"), STYLE)?; - unsafe { - DOM_INIT = true; - } - } - - let document = window.document().unwrap(); - let element = document.create_element("div").unwrap(); - element.set_class_name("toolbar"); - let body = document.query_selector("body").unwrap().expect("Toolbar unable to get body element"); - body.append_child(&element).unwrap(); - - Ok(Self { - inner: Arc::new(ToolbarInner { - document, - element, - container: container.clone(), - graphs: graphs.clone(), - callbacks: CallbackMap::default(), - controls: Arc::new(Mutex::new(Vec::new())), - layout: Arc::new(Mutex::new((Count::cols().get(2).unwrap().clone(), Count::rows().get(3).unwrap().clone()))), - }), - }) - } - - pub fn document(&self) -> &Document { - &self.inner.document - } - - pub fn element(&self) -> &Element { - &self.inner.element - } - - pub fn layout(&self) -> MutexGuard<(Cols, Rows)> { - self.inner.layout.lock().unwrap() - } - - pub fn controls(&self) -> MutexGuard>> { - self.inner.controls.lock().unwrap() - } - - pub fn push(&self, control: impl Control + Send + Sync + 'static) { - let control = Arc::new(control); - self.controls().push(control); - } - - pub fn try_init(&self) -> Result<()> { - let durations = vec![ - ("1m", "1 Minute"), - ("5m", "1 Minutes"), - ("15m", "15 Minutes"), - ("30m", "30 Minutes"), - ("1H", "1 Hour"), - ("2H", "2 Hours"), - ("4H", "4 Hours"), - ("8H", "8 Hours"), - ("12H", "12 Hours"), - ("24H", "24 Hours"), - ("36H", "36 Hours"), - ("48H", "48 Hours"), - ("72H", "72 Hours"), - ]; - - for (html, tip) in durations { - let this = self.clone(); - let duration = GraphDuration::parse(html.to_lowercase()).unwrap(); - self.push(RadioButton::try_new( - self, - self.element(), - "duration", - html, - &format!("Set graph time range to {tip}"), - Arc::new(move |btn| this.action(btn, Action::Duration(duration))), - )?); - } - - Separator::try_new(self)?; - - for cols in Count::cols() { - let this = self.clone(); - self.push(RadioButton::try_new( - self, - self.element(), - "cols", - // &format!("{}", width.1), - &cols.1.to_string(), - &format!("Set graph layout to {} columns", cols.0), - Arc::new(move |btn| this.action(btn, Action::Cols(cols.clone()))), - )?); - } - Separator::try_new(self)?; - - for rows in Count::rows() { - let this = self.clone(); - self.push(RadioButton::try_new( - self, - self.element(), - "rows", - // &format!("{}", height.1), - &rows.1.to_string(), - &format!("Set graph layout to {} rows", rows.0), - Arc::new(move |btn| this.action(btn, Action::Rows(rows.clone()))), - )?); - } - - let this = self.clone(); - spawn(async move { - // sleep(Duration::from_millis(100)).await; - this.select("duration", "5m").expect("unable to locate duration element"); - this.select("cols", "S").expect("unable to locate width element"); - this.select("rows", "S").expect("unable to locate height element"); - this.update_layout(this.inner.layout.lock().unwrap().clone()); - }); - - Ok(()) - } - - pub fn select(&self, name: &str, value: &str) -> Result<()> { - let el = self.document().query_selector(&format!("input[name='{}'][value='{}']", name, value))?.unwrap(); - let event = MouseEvent::new("click").unwrap(); - el.dispatch_event(&event).unwrap(); - Ok(()) - } - - pub fn action(&self, _btn: &dyn Control, action: Action) { - // log_info!("action: {:?}", action); - match action { - Action::Duration(duration) => { - let graphs = self.inner.graphs.lock().unwrap(); - for graph in (*graphs).values() { - graph.set_duration(duration).unwrap_or_else(|err| { - log_error!("unable to set graph duration: {}", err); - }); - } - } - Action::Cols(cols) => { - let layout = { - let mut layout = self.layout(); - layout.0 = cols; - layout.clone() - }; - self.update_layout(layout); - } - Action::Rows(rows) => { - let layout = { - let mut layout = self.layout(); - layout.1 = rows; - layout.clone() - }; - self.update_layout(layout); - } - } - } - - fn update_layout(&self, layout: (Cols, Rows)) { - dispatch(async move { - let style = Graph::default_style().await.expect("unable to get graph style"); - // let re = Regex::new(r"(min|max)?-?(width|height)\s*:\d+(vw|vh);").unwrap(); - // let style = re.replace_all(style.as_str(), ""); - let new_style = format!( - r#"{} - .graph {{ {}{} }} - "#, - style, - layout.0.get_cols(), - layout.1.get_rows() - ); - Graph::replace_graph_style("graph", &new_style).await.unwrap_or_else(|err| { - log_error!("unable to replace graph style: {}", err); - }) - }) - } -} - -type ButtonCallback = dyn Fn(&Button) + Send + Sync + 'static; - -#[derive(Clone)] -pub struct Button { - pub callbacks: CallbackMap, - pub element: Element, -} - -impl Button { - pub fn try_new(toolbar: &Toolbar, parent: &Element, html: &str, tooltip: &str, callback: Arc) -> Result { - let element = toolbar.document().create_element("div").unwrap(); - element.set_class_name("button"); - element.set_attribute("title", tooltip)?; - element.set_inner_html(html); - parent.append_child(&element).unwrap(); - let callbacks = CallbackMap::default(); - let button = Self { callbacks, element }; - let this = button.clone(); - let callback = Arc::new(callback); - let click = callback!(move || { - callback(&this); - }); - - button.element.add_event_listener_with_callback("click", click.get_fn())?; - button.callbacks.retain(click)?; - - Ok(button) - } -} - -type RadioButtonCallback = dyn Fn(&RadioButton) + Send + Sync + 'static; - -#[derive(Clone)] -pub struct RadioButton { - pub callbacks: CallbackMap, - pub element: Element, -} - -unsafe impl Send for RadioButton {} -unsafe impl Sync for RadioButton {} - -impl RadioButton { - pub fn try_new( - toolbar: &Toolbar, - parent: &Element, - name: &str, - html: &str, - tooltip: &str, - callback: Arc, - ) -> Result { - let element = toolbar.document().create_element("label").unwrap(); - element.set_class_name("button"); - element.set_attribute("title", tooltip)?; - element.set_inner_html(html); - let radio = toolbar.document().create_element("input").unwrap(); - radio.set_attribute("name", name)?; - radio.set_attribute("type", "radio")?; - radio.set_attribute("value", html)?; - element.append_child(&radio)?; - parent.append_child(&element).unwrap(); - let callbacks = CallbackMap::default(); - let button = Self { callbacks, element }; - let this = button.clone(); - let callback = Arc::new(callback); - let click = callback!(move || { - callback(&this); - }); - - button.element.add_event_listener_with_callback("click", click.get_fn())?; - button.callbacks.retain(click)?; - - Ok(button) - } -} - -pub struct Caption { - pub element: Element, -} - -impl Caption { - pub fn try_new(toolbar: &Toolbar, html: &str) -> Result { - let element = toolbar.document().create_element("div").unwrap(); - element.set_class_name("caption"); - element.set_inner_html(html); - toolbar.element().append_child(&element).unwrap(); - - Ok(Self { element }) - } -} - -pub struct Separator { - pub element: Element, -} - -impl Separator { - pub fn try_new(toolbar: &Toolbar) -> Result { - let element = toolbar.document().create_element("div").unwrap(); - element.set_class_name("separator"); - toolbar.element().append_child(&element).unwrap(); - - Ok(Self { element }) - } -} - -pub trait Control {} - -impl Control for Button {} -impl Control for RadioButton {} diff --git a/kos/src/modules/exit.rs b/kos/src/modules/exit.rs deleted file mode 100644 index 795792e54..000000000 --- a/kos/src/modules/exit.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::imports::*; - -#[derive(Default, Handler)] -#[help("Exit this application")] -pub struct Exit; - -impl Exit { - async fn main(self: Arc, ctx: &Arc, _argv: Vec, _cmd: &str) -> Result<()> { - let ctx = ctx.clone().downcast_arc::()?; - ctx.wallet().select(None).await?; - // ctx.term().refresh_prompt(); - // tprintln!(ctx, "{}", style("System is going down ...").blue()); - ctx.shutdown().await?; - tprintln!(ctx, "bye!"); - - // workflow_core::task::sleep(Duration::from_secs(10)).await; - - Ok(()) - } -} diff --git a/kos/src/modules/metrics.rs b/kos/src/modules/metrics.rs deleted file mode 100644 index 28d76e3cc..000000000 --- a/kos/src/modules/metrics.rs +++ /dev/null @@ -1,91 +0,0 @@ -use crate::imports::*; -use kaspa_cli_lib::modules::metrics::Metrics as Inner; -use kaspa_metrics_core::MetricsSinkFn; - -pub struct Metrics { - inner: Arc, - core: Arc, -} - -impl Metrics { - pub fn new(core: &Arc) -> Self { - Self { core: core.clone(), inner: Arc::new(Inner::default()) } - } -} - -#[async_trait] -impl Handler for Metrics { - fn verb(&self, ctx: &Arc) -> Option<&'static str> { - self.inner.verb(ctx) - } - - fn help(&self, ctx: &Arc) -> &'static str { - self.inner.help(ctx) - } - - async fn start(self: Arc, ctx: &Arc) -> cli::Result<()> { - self.inner.clone().start(ctx).await - } - - async fn stop(self: Arc, ctx: &Arc) -> cli::Result<()> { - self.inner.clone().stop(ctx).await - } - - async fn handle(self: Arc, ctx: &Arc, argv: Vec, cmd: &str) -> cli::Result<()> { - let ctx = ctx.clone().downcast_arc::()?; - self.main(ctx, argv, cmd).await.map_err(|e| e.to_string())?; - Ok(()) - } -} - -impl Metrics { - pub fn register_sink(&self, target: MetricsSinkFn) { - self.inner.register_sink(target); - } - - pub fn unregister_sink(&self) { - self.inner.unregister_sink(); - } - - async fn main(self: Arc, ctx: Arc, mut argv: Vec, _cmd: &str) -> Result<()> { - if argv.is_empty() { - self.inner.display_help(ctx, argv).await?; - return Ok(()); - } - match argv.remove(0).as_str() { - "open" => { - self.core.metrics_open().await?; - } - "close" => { - self.core.metrics_close().await?; - } - "retention" => { - if argv.is_empty() { - tprintln!(ctx, "missing retention value"); - return Ok(()); - } else { - let retention = argv.remove(0).parse::().map_err(|e| e.to_string())?; - if !(1..=168).contains(&retention) { - tprintln!(ctx, "retention value must be between 1 and 168 hours"); - return Ok(()); - } - self.core.metrics_ctl(MetricsCtl::Retention(retention)).await?; - } - } - v => { - tprintln!(ctx, "unknown command: '{v}'\r\n"); - - self.display_help(ctx, argv).await?; - return Ok(()); - } - } - - Ok(()) - } - - pub async fn display_help(self: &Arc, ctx: Arc, _argv: Vec) -> Result<()> { - ctx.term().help(&[("open", "Open metrics window"), ("close", "Close metrics window")], None)?; - - Ok(()) - } -} diff --git a/kos/src/modules/mod.rs b/kos/src/modules/mod.rs deleted file mode 100644 index 3d5613808..000000000 --- a/kos/src/modules/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod exit; -pub mod metrics; - -// pub use metrics::Metrics as MetricsModule; - -use crate::imports::*; - -pub fn register_cli_handlers(cli: &Arc) -> Result<()> { - register_handlers!(cli, cli.handlers(), [exit]); - - Ok(()) -} diff --git a/kos/src/result.rs b/kos/src/result.rs deleted file mode 100644 index 5c3ef710b..000000000 --- a/kos/src/result.rs +++ /dev/null @@ -1 +0,0 @@ -pub type Result = std::result::Result; diff --git a/kos/src/terminal/ipc.rs b/kos/src/terminal/ipc.rs deleted file mode 100644 index 70e320348..000000000 --- a/kos/src/terminal/ipc.rs +++ /dev/null @@ -1,69 +0,0 @@ -use crate::imports::*; - -#[derive(Debug, Clone, PartialEq, Eq, Hash, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum TermOps { - TestTerminal, - FontCtl, - EditCtl, - DaemonEvent, - MetricsCtl, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum FontCtl { - IncreaseSize, - DecreaseSize, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum EditCtl { - Copy, - Paste, -} - -#[derive(Debug, Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] -pub enum MetricsSinkCtl { - Activate, - Deactivate, -} - -#[derive(Debug, Clone)] -pub struct TerminalIpc { - target: IpcTarget, -} - -impl TerminalIpc { - pub fn new(target: IpcTarget) -> TerminalIpc { - TerminalIpc { target } - } - - pub async fn clipboard_copy(&self) -> Result<()> { - self.target.call::<_, _, ()>(TermOps::EditCtl, EditCtl::Copy).await?; - Ok(()) - } - - pub async fn clipboard_paste(&self) -> Result<()> { - self.target.call::<_, _, ()>(TermOps::EditCtl, EditCtl::Paste).await?; - Ok(()) - } - - pub async fn increase_font_size(&self) -> Result<()> { - self.target.call::<_, _, ()>(TermOps::FontCtl, FontCtl::IncreaseSize).await?; - Ok(()) - } - - pub async fn decrease_font_size(&self) -> Result<()> { - self.target.call::<_, _, ()>(TermOps::FontCtl, FontCtl::DecreaseSize).await?; - Ok(()) - } - - pub async fn relay_event(&self, event: DaemonEvent) -> Result<()> { - self.target.notify(TermOps::DaemonEvent, event).await?; - Ok(()) - } - - pub async fn metrics_ctl(&self, ctl: MetricsSinkCtl) -> Result<()> { - self.target.notify(TermOps::MetricsCtl, ctl).await?; - Ok(()) - } -} diff --git a/kos/src/terminal/mod.rs b/kos/src/terminal/mod.rs deleted file mode 100644 index 193663c21..000000000 --- a/kos/src/terminal/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod ipc; -#[allow(clippy::module_inception)] -mod terminal; -pub use ipc::*; -mod settings; -pub use settings::*; diff --git a/kos/src/terminal/settings.rs b/kos/src/terminal/settings.rs deleted file mode 100644 index 5cd32d2be..000000000 --- a/kos/src/terminal/settings.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::imports::*; - -#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[serde(rename_all = "lowercase")] -pub enum TerminalSettings { - Greeting, - Scrollback, - FontSize, -} - -#[async_trait] -impl DefaultSettings for TerminalSettings { - async fn defaults() -> Vec<(Self, Value)> { - vec![] - } -} diff --git a/kos/src/terminal/terminal.rs b/kos/src/terminal/terminal.rs deleted file mode 100644 index 1410acb78..000000000 --- a/kos/src/terminal/terminal.rs +++ /dev/null @@ -1,285 +0,0 @@ -use crate::imports::*; -use kaspa_metrics_core::MetricsSnapshot; - -static mut TERMINAL: Option> = None; -static mut SHUTDOWN_ATTEMPTS: usize = 0; - -#[derive(Clone)] -pub struct Terminal { - pub inner: Arc, - pub ipc: Arc>, - pub core: Arc, - pub cli: Arc, - pub window: Arc, - pub callbacks: CallbackMap, - pub settings: Arc>, - pub layout: Arc>>, - pub metrics: Arc>>>, -} - -impl Terminal { - pub async fn try_new() -> Result> { - log_info!("-> core ipc binding"); - let core_ipc_target = get_ipc_target(Modules::Core).await?.expect("Unable to acquire background window"); - let core = Arc::new(CoreIpc::new(core_ipc_target)); - log_info!("-> creating daemon interface"); - let daemons = Arc::new(Daemons::new().with_kaspad(core.clone()).with_cpu_miner(core.clone())); - - log_info!("-> loading settings"); - let settings = Arc::new(SettingsStore::::try_new("terminal")?); - settings.try_load().await?; - let font_size = settings.get::(TerminalSettings::FontSize); - settings.set::(TerminalSettings::Scrollback, 40000).await?; - let scrollback = settings.get::(TerminalSettings::Scrollback); - log_info!("-> terminal cli init"); - let terminal_options = TerminalOptions { font_size, scrollback, ..TerminalOptions::default() }; - let options = KaspaCliOptions::new(terminal_options, Some(daemons)); - let cli = KaspaCli::try_new_arc(options).await?; - - log_info!("-> getting local nw window"); - let window = Arc::new(nw_sys::window::get()); - log_info!("-> init window layout manager"); - let layout = Arc::new(Layout::try_new(&window, &settings).await?); - - log_info!("-> creating terminal application instance"); - let app = Arc::new(Self { - inner: Application::new()?, - ipc: Ipc::try_new_window_binding(&window, Modules::Terminal)?, - core, - cli, - window, - callbacks: CallbackMap::default(), - settings, - layout, - metrics: Arc::new(Mutex::new(None)), - }); - - unsafe { - TERMINAL = Some(app.clone()); - }; - - Ok(app) - } - - fn register_ipc_handlers(self: &Arc) -> Result<()> { - self.ipc.method( - TermOps::TestTerminal, - Method::new(move |args: TestReq| { - Box::pin(async move { - let resp: TestResp = TestResp { resp: args.req + " - response from terminal!" }; - Ok(resp) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - TermOps::FontCtl, - Method::new(move |args: FontCtl| { - let this = this.clone(); - Box::pin(async move { - match args { - FontCtl::IncreaseSize => { - this.cli.term().increase_font_size().map_err(|e| e.to_string())?; - if let Some(font_size) = this.cli.term().get_font_size().unwrap() { - this.settings - .set(TerminalSettings::FontSize, font_size) - .await - .expect("Unable to store application settings"); - } - } - FontCtl::DecreaseSize => { - this.cli.term().decrease_font_size().map_err(|e| e.to_string())?; - if let Some(font_size) = this.cli.term().get_font_size().unwrap() { - this.settings - .set(TerminalSettings::FontSize, font_size) - .await - .expect("Unable to store application settings"); - } - } - } - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.method( - TermOps::EditCtl, - Method::new(move |args: EditCtl| { - let this = this.clone(); - Box::pin(async move { - match args { - EditCtl::Copy => { - this.cli.term().clipboard_copy().map_err(|e| e.to_string())?; - } - EditCtl::Paste => { - this.cli.term().clipboard_paste().map_err(|e| e.to_string())?; - } - } - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.notification( - TermOps::MetricsCtl, - Notification::new(move |args: MetricsSinkCtl| { - let this = this.clone(); - Box::pin(async move { - let metrics = this.cli.handlers().get("metrics").expect("MetricsCtlSink: missing metrics module"); - let metrics = - metrics.downcast_arc::().expect("MetricsCtlSink: invalid metrics module"); - match args { - MetricsSinkCtl::Activate => { - let ipc = get_ipc_target(Modules::Metrics) - .await - .expect("Error acquiring ipc for the metrics window") - .expect("Unable to locate ipc for the metrics window"); - - this.metrics.lock().unwrap().replace(Arc::new(ipc)); - metrics.register_sink(Arc::new(Box::new(move |data: MetricsSnapshot| { - let this = this.clone(); - - Some(Box::pin(async move { - let ipc = this.metrics.lock().unwrap().as_ref().unwrap().clone(); - ipc.notify(MetricsOps::MetricsSnapshot, data).await.unwrap_or_else(|err| { - log_error!("error posting metrics data to metrics window: {:?}", err); - }); - - Ok(()) - })) - }))) - } - MetricsSinkCtl::Deactivate => { - this.metrics.lock().unwrap().take(); - metrics.unregister_sink(); - } - } - Ok(()) - }) - }), - ); - - let this = self.clone(); - self.ipc.notification( - TermOps::DaemonEvent, - Notification::new(move |event: DaemonEvent| { - let this = this.clone(); - Box::pin(async move { - this.cli - .handle_daemon_event(event) - .await - .unwrap_or_else(|err| log_error!("error handling child process stdio (cli term relay): `{err}`")); - Ok(()) - }) - }), - ); - - Ok(()) - } - - fn register_cli_handlers(&self) -> Result<()> { - self.cli.register_handlers()?; - - self.cli.handlers().register(&self.cli, crate::modules::metrics::Metrics::new(&self.core)); - - Ok(()) - } - - fn register_window_handlers(self: &Arc) -> Result<()> { - let this = self.clone(); - let close = callback!(move || { - unsafe { - SHUTDOWN_ATTEMPTS += 1; - if SHUTDOWN_ATTEMPTS >= 3 { - nw_sys::app::quit(); - } - } - - let this = this.clone(); - spawn(async move { - this.cli.shutdown().await.unwrap_or_else(|err| log_error!("Error during shutdown: `{err}`")); - }); - }); - - self.window.on("close", close.as_ref()); - self.callbacks.retain(close)?; - - Ok(()) - } - - async fn main(self: &Arc) -> Result<()> { - log_info!("-> register window handlers"); - self.register_window_handlers()?; - log_info!("-> register ipc handlers"); - self.register_ipc_handlers()?; - log_info!("-> register cli handlers"); - self.register_cli_handlers()?; - log_info!("-> register local cli handlers"); - crate::modules::register_cli_handlers(&self.cli)?; - - // cli starts notification->term trace pipe task - log_info!("-> cli start"); - self.cli.start().await?; - - log_info!("-> signal terminal ready"); - self.core.terminal_ready().await?; - - log_info!("-> greeting"); - let kos_current_version = env!("CARGO_PKG_VERSION").to_string(); - let kos_last_version = self.settings.get::(TerminalSettings::Greeting).unwrap_or_default(); - - if kos_last_version != kos_current_version { - let greeting = r" -Hello Kaspian! - -If you have any questions, please join us on discord at https://discord.gg/kaspa - -If you are a first-time user, you can type 'guide' or 'help' to get started. - -Please note, this is an alpha software release of the Kaspa-OS; expect some bugs! - -"; - - self.cli.term().writeln(greeting.crlf()); - self.settings.set(TerminalSettings::Greeting, &kos_current_version).await?; - } - let framework_version = self.cli.version(); - let version = if framework_version == kos_current_version { - kos_current_version - } else { - format!("{} Rust Core v{}", kos_current_version, framework_version) - }; - let banner = format!("Kaspa OS v{} (type 'help' for list of commands)", version); - self.cli.term().writeln(banner); - - log_info!("-> cli run ..."); - // terminal blocks async execution, delivering commands to the cli - self.cli.run().await?; - - log_info!("-> cli stop"); - // stop notification->term trace pipe task - self.cli.stop().await?; - - log_info!("-> core shutdown"); - self.core.shutdown().await?; - - log_info!("-> terminal close"); - self.window.close_impl(true); - - Ok(()) - } -} - -#[wasm_bindgen] -pub async fn init_application() -> Result<()> { - kaspa_core::log::set_log_level(LevelFilter::Info); - workflow_log::set_colors_enabled(true); - - let terminal = Terminal::try_new().await?; - terminal.main().await?; - - Ok(()) -} diff --git a/mining/src/mempool/model/pool.rs b/mining/src/mempool/model/pool.rs index 1f9ff1552..5ad6970eb 100644 --- a/mining/src/mempool/model/pool.rs +++ b/mining/src/mempool/model/pool.rs @@ -36,6 +36,7 @@ pub(crate) trait Pool { /// Returns an index over either high or low priority transaction ids which can /// in turn be topologically ordered. + #[allow(dead_code)] fn index(&self, priority: Priority) -> PoolIndex { let transactions: TransactionIdSet = self.all().iter().filter_map(|(id, tx)| if tx.priority == priority { Some(*id) } else { None }).collect(); diff --git a/protocol/p2p/src/convert/error.rs b/protocol/p2p/src/convert/error.rs index 15783cb4d..14b2cec1a 100644 --- a/protocol/p2p/src/convert/error.rs +++ b/protocol/p2p/src/convert/error.rs @@ -1,3 +1,4 @@ +use kaspa_consensus_core::subnets::SubnetworkConversionError; use thiserror::Error; #[derive(Clone, Debug, Error)] @@ -20,9 +21,12 @@ pub enum ConversionError { #[error("Integer parsing error: {0}")] IntCastingError(#[from] std::num::TryFromIntError), - #[error("{0}")] + #[error(transparent)] AddressParsingError(#[from] std::net::AddrParseError), - #[error("{0}")] + #[error(transparent)] IdentityError(#[from] uuid::Error), + + #[error(transparent)] + SubnetParsingError(#[from] SubnetworkConversionError), } diff --git a/rpc/core/Cargo.toml b/rpc/core/Cargo.toml index f196ef68e..cfa4895f2 100644 --- a/rpc/core/Cargo.toml +++ b/rpc/core/Cargo.toml @@ -53,3 +53,6 @@ workflow-wasm.workspace = true [dev-dependencies] serde_json.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/rpc/core/src/error.rs b/rpc/core/src/error.rs index e52769e85..59f6b910e 100644 --- a/rpc/core/src/error.rs +++ b/rpc/core/src/error.rs @@ -1,4 +1,4 @@ -use kaspa_consensus_core::tx::TransactionId; +use kaspa_consensus_core::{subnets::SubnetworkConversionError, tx::TransactionId}; use kaspa_utils::networking::IpAddress; use std::{net::AddrParseError, num::TryFromIntError}; use thiserror::Error; @@ -116,6 +116,9 @@ pub enum RpcError { #[error("transaction query must either not filter transactions or include orphans")] InconsistentMempoolTxQuery, + #[error(transparent)] + SubnetParsingError(#[from] SubnetworkConversionError), + #[error(transparent)] WasmError(#[from] workflow_wasm::error::Error), diff --git a/rpc/core/src/model/address.rs b/rpc/core/src/model/address.rs index 7ea382705..720cb4f86 100644 --- a/rpc/core/src/model/address.rs +++ b/rpc/core/src/model/address.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; pub type RpcAddress = kaspa_addresses::Address; -/// +/// Represents a UTXO entry of an address returned by the `GetUtxosByAddresses` RPC. #[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] #[serde(rename_all = "camelCase")] pub struct RpcUtxosByAddressesEntry { @@ -13,7 +13,7 @@ pub struct RpcUtxosByAddressesEntry { pub utxo_entry: RpcUtxoEntry, } -/// +/// Represents a balance of an address returned by the `GetBalancesByAddresses` RPC. #[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] #[serde(rename_all = "camelCase")] pub struct RpcBalancesByAddressesEntry { diff --git a/rpc/wrpc/client/src/client.rs b/rpc/wrpc/client/src/client.rs index 8d528859e..4e9fffc0c 100644 --- a/rpc/wrpc/client/src/client.rs +++ b/rpc/wrpc/client/src/client.rs @@ -509,9 +509,9 @@ impl KaspaRpcClient { // or 1.2.3.4:port where port is based on the network type. // if (parse_output.scheme.is_some() || !path_str.is_empty()) && parse_output.port.is_none() { - Ok(format!("{}://{}{}", scheme, parse_output.host.to_string(), path_str)) + Ok(format!("{}://{}{}", scheme, parse_output.host, path_str)) } else { - Ok(format!("{}://{}:{}{}", scheme, parse_output.host.to_string(), port, path_str)) + Ok(format!("{}://{}:{}{}", scheme, parse_output.host, port, path_str)) } } diff --git a/rpc/wrpc/client/src/parse.rs b/rpc/wrpc/client/src/parse.rs index 6928ad650..35db2c768 100644 --- a/rpc/wrpc/client/src/parse.rs +++ b/rpc/wrpc/client/src/parse.rs @@ -15,7 +15,7 @@ impl Display for ParseHostOutput<'_> { if let Some(scheme) = self.scheme { write!(f, "{}://", scheme)?; } - write!(f, "{}", self.host.to_string())?; + write!(f, "{}", self.host)?; if let Some(port) = self.port { write!(f, ":{}", port)?; } @@ -31,13 +31,13 @@ pub enum Host<'a> { Ipv6(Ipv6Addr), } -impl ToString for Host<'_> { - fn to_string(&self) -> String { +impl Display for Host<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Host::Domain(domain) => domain.to_string(), - Host::Hostname(hostname) => hostname.to_string(), - Host::Ipv4(ipv4) => ipv4.to_string(), - Host::Ipv6(ipv6) => format!("[{}]", ipv6), + Host::Domain(domain) => write!(f, "{}", domain), + Host::Hostname(hostname) => write!(f, "{}", hostname), + Host::Ipv4(ipv4) => write!(f, "{}", ipv4), + Host::Ipv6(ipv6) => write!(f, "[{}]", ipv6), } } } diff --git a/rpc/wrpc/wasm/Cargo.toml b/rpc/wrpc/wasm/Cargo.toml index a6113f362..83c78d26f 100644 --- a/rpc/wrpc/wasm/Cargo.toml +++ b/rpc/wrpc/wasm/Cargo.toml @@ -40,3 +40,6 @@ js-sys.workspace = true wasm-bindgen-futures.workspace = true workflow-core.workspace = true futures.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/utils/benches/bench.rs b/utils/benches/bench.rs index d726fa257..15617134d 100644 --- a/utils/benches/bench.rs +++ b/utils/benches/bench.rs @@ -45,6 +45,7 @@ trait RwLockTrait { type WriteGuard; fn new(value: T) -> Self; async fn read_(&self) -> Self::ReadGuard; + #[allow(dead_code)] async fn write_(&self) -> Self::WriteGuard; } diff --git a/wallet/core/Cargo.toml b/wallet/core/Cargo.toml index c523624af..fb31afb31 100644 --- a/wallet/core/Cargo.toml +++ b/wallet/core/Cargo.toml @@ -124,3 +124,6 @@ serde_repr.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/wallet/core/src/storage/local/collection.rs b/wallet/core/src/storage/local/collection.rs index 85cfb6aec..53c740710 100644 --- a/wallet/core/src/storage/local/collection.rs +++ b/wallet/core/src/storage/local/collection.rs @@ -44,7 +44,7 @@ where } pub fn insert(&mut self, id: Id, data: Arc) -> Result<()> { - if self.map.get(&id).is_some() { + if self.map.contains_key(&id) { self.map.remove(&id); self.vec.retain(|d| d.id() != &id); } @@ -84,7 +84,7 @@ where pub fn store_multiple(&mut self, data: Vec) -> Result<()> { for data in data.into_iter() { let id = data.id().clone(); - if self.map.get(&id).is_some() { + if self.map.contains_key(&id) { self.map.remove(&id); self.vec.retain(|d| d.id() != &id); } @@ -98,7 +98,7 @@ where pub fn store_single(&mut self, data: &Data) -> Result<()> { let id = data.id(); - if self.map.get(id).is_some() { + if self.map.contains_key(id) { self.map.remove(id); self.vec.retain(|d| d.id() != id); } diff --git a/wallet/core/src/tx/generator/test.rs b/wallet/core/src/tx/generator/test.rs index b58d53e73..1368c51f2 100644 --- a/wallet/core/src/tx/generator/test.rs +++ b/wallet/core/src/tx/generator/test.rs @@ -63,6 +63,7 @@ impl FeesExpected { } trait PendingTransactionExtension { + #[allow(dead_code)] fn tuple(self) -> (PendingTransaction, Transaction); fn expect(self, expected: &Expected) -> Self where @@ -297,7 +298,7 @@ impl Harness { Rc::new(Harness { generator, accumulator: RefCell::new(Accumulator::default()) }) } - pub fn fetch>(self: &Rc, expected: &Expected) -> Rc + pub fn fetch(self: &Rc, expected: &Expected) -> Rc where SOMPI: Into + Debug + Copy, { diff --git a/wallet/core/src/utxo/processor.rs b/wallet/core/src/utxo/processor.rs index fb0e8137b..e788272f2 100644 --- a/wallet/core/src/utxo/processor.rs +++ b/wallet/core/src/utxo/processor.rs @@ -136,7 +136,7 @@ impl UtxoProcessor { } pub async fn bind_rpc(&self, rpc: Option) -> Result<()> { - *self.inner.rpc.lock().unwrap() = rpc.clone(); + self.inner.rpc.lock().unwrap().clone_from(&rpc); let rpc_api = rpc.as_ref().map(|rpc| rpc.rpc_api().clone()); self.metrics().bind_rpc(rpc_api); self.sync_proc().bind_rpc(rpc).await?; diff --git a/wallet/keys/Cargo.toml b/wallet/keys/Cargo.toml index c42eee802..7300c1de5 100644 --- a/wallet/keys/Cargo.toml +++ b/wallet/keys/Cargo.toml @@ -45,3 +45,6 @@ zeroize.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/wasm/core/Cargo.toml b/wasm/core/Cargo.toml index 73d58aaef..a8a49e0aa 100644 --- a/wasm/core/Cargo.toml +++ b/wasm/core/Cargo.toml @@ -14,4 +14,7 @@ wasm32-sdk = [] [dependencies] wasm-bindgen.workspace = true js-sys.workspace = true -faster-hex.workspace = true \ No newline at end of file +faster-hex.workspace = true + +[lints.clippy] +empty_docs = "allow"