--- /dev/null
+/target
+/heaptrack
+src/main-tui.rs
+jotter.txt
+test.log
+terminalizer/
+junk*/
+api*/
+
--- /dev/null
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "addr2line"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
+name = "ahash"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
+dependencies = [
+ "getrandom",
+ "once_cell",
+ "version_check",
+]
+
+[[package]]
+name = "ahash"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72832d73be48bac96a5d7944568f305d829ed55b0ce3b483647089dfaf6cf704"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "version_check",
+ "zerocopy",
+]
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "allocator-api2"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
+
+[[package]]
+name = "android-tzdata"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "anstream"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
+dependencies = [
+ "anstyle",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "arrayvec"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi 0.1.19",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "backtrace"
+version = "0.3.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
+name = "base64"
+version = "0.21.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
+
+[[package]]
+name = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitvec"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
+dependencies = [
+ "funty",
+ "radium",
+ "tap",
+ "wyz",
+]
+
+[[package]]
+name = "borsh"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667"
+dependencies = [
+ "borsh-derive",
+ "cfg_aliases",
+]
+
+[[package]]
+name = "borsh-derive"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd"
+dependencies = [
+ "once_cell",
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+ "syn_derive",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
+
+[[package]]
+name = "byte-unit"
+version = "5.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33ac19bdf0b2665407c39d82dbc937e951e7e2001609f0fb32edd0af45a2d63e"
+dependencies = [
+ "rust_decimal",
+ "serde",
+ "utf8-width",
+]
+
+[[package]]
+name = "bytecheck"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627"
+dependencies = [
+ "bytecheck_derive",
+ "ptr_meta",
+ "simdutf8",
+]
+
+[[package]]
+name = "bytecheck_derive"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "bytes"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
+
+[[package]]
+name = "cassowary"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
+
+[[package]]
+name = "cc"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "cfg_aliases"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
+
+[[package]]
+name = "chrono"
+version = "0.4.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
+dependencies = [
+ "android-tzdata",
+ "iana-time-zone",
+ "js-sys",
+ "num-traits",
+ "serde",
+ "wasm-bindgen",
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "clap"
+version = "2.34.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
+dependencies = [
+ "ansi_term",
+ "atty",
+ "bitflags 1.3.2",
+ "strsim 0.8.0",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
+]
+
+[[package]]
+name = "colorchoice"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
+
+[[package]]
+name = "core-foundation"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
+dependencies = [
+ "cfg-if",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "crossterm"
+version = "0.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
+dependencies = [
+ "bitflags 2.4.1",
+ "crossterm_winapi",
+ "libc",
+ "mio",
+ "parking_lot",
+ "signal-hook",
+ "signal-hook-mio",
+ "winapi",
+]
+
+[[package]]
+name = "crossterm_winapi"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "darling"
+version = "0.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
+dependencies = [
+ "darling_core",
+ "darling_macro",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
+dependencies = [
+ "fnv",
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim 0.10.0",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
+dependencies = [
+ "darling_core",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "deranged"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3"
+dependencies = [
+ "powerfmt",
+ "serde",
+]
+
+[[package]]
+name = "either"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
+
+[[package]]
+name = "encoding_rs"
+version = "0.8.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "env_filter"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
+dependencies = [
+ "log",
+ "regex",
+]
+
+[[package]]
+name = "env_logger"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "env_filter",
+ "humantime",
+ "log",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
+
+[[package]]
+name = "errno"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
+dependencies = [
+ "libc",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
+
+[[package]]
+name = "filetime"
+version = "0.2.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall 0.3.5",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "fs2"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "funty"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
+
+[[package]]
+name = "futures"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-executor",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
+
+[[package]]
+name = "futures-executor"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-io"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
+
+[[package]]
+name = "futures-macro"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "futures-sink"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
+
+[[package]]
+name = "futures-util"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-macro",
+ "futures-sink",
+ "futures-task",
+ "memchr",
+ "pin-project-lite",
+ "pin-utils",
+ "slab",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "gimli"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
+
+[[package]]
+name = "glob"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
+
+[[package]]
+name = "h2"
+version = "0.3.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http",
+ "indexmap 2.1.0",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+dependencies = [
+ "ahash 0.7.7",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
+dependencies = [
+ "ahash 0.8.4",
+ "allocator-api2",
+]
+
+[[package]]
+name = "heck"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "heck"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
+
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+
+[[package]]
+name = "http"
+version = "0.2.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
+[[package]]
+name = "http-body"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
+dependencies = [
+ "bytes",
+ "http",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "httparse"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
+
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "humantime"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
+
+[[package]]
+name = "hyper"
+version = "0.14.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.24.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
+dependencies = [
+ "futures-util",
+ "http",
+ "hyper",
+ "rustls",
+ "tokio",
+ "tokio-rustls",
+]
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.58"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "ident_case"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
+
+[[package]]
+name = "idna"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown 0.12.3",
+ "serde",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.14.2",
+ "serde",
+]
+
+[[package]]
+name = "indoc"
+version = "2.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
+
+[[package]]
+name = "inotify"
+version = "0.9.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
+dependencies = [
+ "bitflags 1.3.2",
+ "inotify-sys",
+ "libc",
+]
+
+[[package]]
+name = "inotify-sys"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "ipnet"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
+
+[[package]]
+name = "itertools"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
+
+[[package]]
+name = "js-sys"
+version = "0.3.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
+dependencies = [
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "kqueue"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c"
+dependencies = [
+ "kqueue-sys",
+ "libc",
+]
+
+[[package]]
+name = "kqueue-sys"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
+dependencies = [
+ "bitflags 1.3.2",
+ "libc",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.149"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
+
+[[package]]
+name = "linemux"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "feb035c7806bd7982a317d8d66815021e91f7ab14a5fbedee22b06f608f11b43"
+dependencies = [
+ "futures-util",
+ "notify",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
+
+[[package]]
+name = "lock_api"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
+
+[[package]]
+name = "lru"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
+dependencies = [
+ "hashbrown 0.14.2",
+]
+
+[[package]]
+name = "memchr"
+version = "2.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
+
+[[package]]
+name = "mime"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "notify"
+version = "5.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486"
+dependencies = [
+ "bitflags 1.3.2",
+ "crossbeam-channel",
+ "filetime",
+ "inotify",
+ "kqueue",
+ "libc",
+ "mio",
+ "walkdir",
+ "windows-sys 0.45.0",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+dependencies = [
+ "hermit-abi 0.3.3",
+ "libc",
+]
+
+[[package]]
+name = "object"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
+
+[[package]]
+name = "parking_lot"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall 0.4.1",
+ "smallvec",
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
+[[package]]
+name = "powerfmt"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+
+[[package]]
+name = "proc-macro-crate"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284"
+dependencies = [
+ "toml_edit",
+]
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "ptr_meta"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1"
+dependencies = [
+ "ptr_meta_derive",
+]
+
+[[package]]
+name = "ptr_meta_derive"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "radium"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
+
+[[package]]
+name = "rand"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "ratatui"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb"
+dependencies = [
+ "bitflags 2.4.1",
+ "cassowary",
+ "crossterm",
+ "indoc",
+ "itertools",
+ "lru",
+ "paste",
+ "serde",
+ "stability",
+ "strum",
+ "unicode-segmentation",
+ "unicode-width",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
+[[package]]
+name = "regex"
+version = "1.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
+
+[[package]]
+name = "rend"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd"
+dependencies = [
+ "bytecheck",
+]
+
+[[package]]
+name = "reqwest"
+version = "0.11.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
+dependencies = [
+ "base64",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-rustls",
+ "ipnet",
+ "js-sys",
+ "log",
+ "mime",
+ "once_cell",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls",
+ "rustls-pemfile",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "system-configuration",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "webpki-roots",
+ "winreg",
+]
+
+[[package]]
+name = "ring"
+version = "0.17.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74"
+dependencies = [
+ "cc",
+ "getrandom",
+ "libc",
+ "spin",
+ "untrusted",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "rkyv"
+version = "0.7.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5"
+dependencies = [
+ "bitvec",
+ "bytecheck",
+ "bytes",
+ "hashbrown 0.12.3",
+ "ptr_meta",
+ "rend",
+ "rkyv_derive",
+ "seahash",
+ "tinyvec",
+ "uuid",
+]
+
+[[package]]
+name = "rkyv_derive"
+version = "0.7.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "rust_decimal"
+version = "1.33.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4"
+dependencies = [
+ "arrayvec",
+ "borsh",
+ "bytes",
+ "num-traits",
+ "rand",
+ "rkyv",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
+
+[[package]]
+name = "rustix"
+version = "0.38.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0"
+dependencies = [
+ "bitflags 2.4.1",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "rustls"
+version = "0.21.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
+dependencies = [
+ "log",
+ "ring",
+ "rustls-webpki",
+ "sct",
+]
+
+[[package]]
+name = "rustls-pemfile"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
+dependencies = [
+ "base64",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.101.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
+
+[[package]]
+name = "ryu"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "sct"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
+name = "seahash"
+version = "4.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
+
+[[package]]
+name = "serde"
+version = "1.0.192"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.192"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_urlencoded"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
+dependencies = [
+ "form_urlencoded",
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_with"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23"
+dependencies = [
+ "base64",
+ "chrono",
+ "hex",
+ "indexmap 1.9.3",
+ "indexmap 2.1.0",
+ "serde",
+ "serde_json",
+ "serde_with_macros",
+ "time",
+]
+
+[[package]]
+name = "serde_with_macros"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788"
+dependencies = [
+ "darling",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "signal-hook"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
+dependencies = [
+ "libc",
+ "signal-hook-registry",
+]
+
+[[package]]
+name = "signal-hook-mio"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af"
+dependencies = [
+ "libc",
+ "mio",
+ "signal-hook",
+]
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "simdutf8"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
+
+[[package]]
+name = "slab"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
+
+[[package]]
+name = "socket2"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
+dependencies = [
+ "libc",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+
+[[package]]
+name = "stability"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce"
+dependencies = [
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "strfmt"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a8348af2d9fc3258c8733b8d9d8db2e56f54b2363a4b5b81585c7875ed65e65"
+
+[[package]]
+name = "strsim"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+
+[[package]]
+name = "strsim"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+
+[[package]]
+name = "structopt"
+version = "0.3.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
+dependencies = [
+ "clap",
+ "lazy_static",
+ "structopt-derive",
+]
+
+[[package]]
+name = "structopt-derive"
+version = "0.4.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
+dependencies = [
+ "heck 0.3.3",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "strum"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
+dependencies = [
+ "strum_macros",
+]
+
+[[package]]
+name = "strum_macros"
+version = "0.25.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
+dependencies = [
+ "heck 0.4.1",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn_derive"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"
+dependencies = [
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "system-configuration"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "tap"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+
+[[package]]
+name = "tempfile"
+version = "3.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "redox_syscall 0.3.5",
+ "rustix",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "time"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5"
+dependencies = [
+ "deranged",
+ "itoa",
+ "powerfmt",
+ "serde",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
+
+[[package]]
+name = "time-macros"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20"
+dependencies = [
+ "time-core",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
+dependencies = [
+ "tinyvec_macros",
+]
+
+[[package]]
+name = "tinyvec_macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+
+[[package]]
+name = "tokio"
+version = "1.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653"
+dependencies = [
+ "backtrace",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "pin-project-lite",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
+dependencies = [
+ "rustls",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
+
+[[package]]
+name = "toml_edit"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
+dependencies = [
+ "indexmap 2.1.0",
+ "toml_datetime",
+ "winnow",
+]
+
+[[package]]
+name = "tower-service"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
+
+[[package]]
+name = "tracing"
+version = "0.1.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
+dependencies = [
+ "pin-project-lite",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
+
+[[package]]
+name = "unicode-bidi"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
+[[package]]
+name = "unicode-width"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "url"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+]
+
+[[package]]
+name = "utf8-width"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
+
+[[package]]
+name = "uuid"
+version = "1.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"
+
+[[package]]
+name = "vdash"
+version = "0.19.3"
+dependencies = [
+ "bincode",
+ "byte-unit",
+ "chrono",
+ "crossterm",
+ "env_logger",
+ "fs2",
+ "futures",
+ "glob",
+ "linemux",
+ "log",
+ "rand",
+ "ratatui",
+ "regex",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "serde_with",
+ "strfmt",
+ "structopt",
+ "tempfile",
+ "time",
+ "tokio",
+ "tokio-macros",
+ "tokio-stream",
+]
+
+[[package]]
+name = "vec_map"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+
+[[package]]
+name = "version_check"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "walkdir"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "want"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
+dependencies = [
+ "try-lock",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
+dependencies = [
+ "cfg-if",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
+dependencies = [
+ "bumpalo",
+ "log",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
+
+[[package]]
+name = "web-sys"
+version = "0.3.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "0.25.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows-core"
+version = "0.51.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64"
+dependencies = [
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.45.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets 0.42.2",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.0",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
+dependencies = [
+ "windows_aarch64_gnullvm 0.42.2",
+ "windows_aarch64_msvc 0.42.2",
+ "windows_i686_gnu 0.42.2",
+ "windows_i686_msvc 0.42.2",
+ "windows_x86_64_gnu 0.42.2",
+ "windows_x86_64_gnullvm 0.42.2",
+ "windows_x86_64_msvc 0.42.2",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
+dependencies = [
+ "windows_aarch64_gnullvm 0.52.0",
+ "windows_aarch64_msvc 0.52.0",
+ "windows_i686_gnu 0.52.0",
+ "windows_i686_msvc 0.52.0",
+ "windows_x86_64_gnu 0.52.0",
+ "windows_x86_64_gnullvm 0.52.0",
+ "windows_x86_64_msvc 0.52.0",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
+
+[[package]]
+name = "winnow"
+version = "0.5.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "winreg"
+version = "0.50.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
+dependencies = [
+ "cfg-if",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "wyz"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
+dependencies = [
+ "tap",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.38",
+]
--- /dev/null
+[package]
+name = "vdash"
+description = "Autonomi node Dashboard"
+version = "0.19.3"
+authors = ["Mark <git@happybeing.com>"]
+license = "GPL-3.0"
+homepage = "https://github.com/happybeing/vdash"
+repository = "https://github.com/happybeing/vdash"
+readme = "README.md"
+exclude = [".github"]
+keywords = ["utility", "logfile", "monitor", "cli", "safenetwork"]
+categories = ["command-line-utilities"]
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+tokio = { version = "1.15.0", features = ["sync", "macros", "rt-multi-thread"] }
+tokio-stream = "0.1.8"
+tokio-macros = "2.1.0"
+linemux = "0.3.0"
+structopt = "~0.3.15"
+futures = "0.3.19"
+ratatui = { version = "0.25.0", features = ["serde"] }
+crossterm = { version = "0.27.0" }
+regex = "1.3.9"
+tempfile = "3.1.0"
+time = "0.3.29"
+chrono = { version = "0.4.31", features = ["serde"] }
+bincode = "1.3.1"
+byte-unit = "5.1.4"
+fs2 = "0.4.3"
+rand = "0.8.5"
+log = "0.4.11"
+env_logger = "0.11.1"
+strfmt = "0.2.4"
+glob = "0.3.1"
+serde = {version = "1.0.192", features = ["derive"] }
+serde_json = "1.0.108"
+serde_with = { version = "3.4.0", features = ["chrono_0_4"] }
+reqwest = { version = "0.11.23", default_features = false, features = ["rustls-tls"] }
+
+[[bin]]
+name = "vdash"
+path = "src/bin/vdash.rs"
--- /dev/null
+ GNU Affero General PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
--- /dev/null
+# Autonomi node Dashboard
+
+`vdash` is a terminal based dashboard for monitoring Autonomi nodes. It is written in
+Rust, the terminal GUI is implemented using [ratatui](https://github.com/ratatui-org/ratatui) and it monitors one or more node logfiles using [linemux](https://github.com/jmagnuson/linemux).
+
+**Status:** working on Windows, MacOS and Linux with public and local test networks.
+
+`vdash` can monitor multiple logfiles on the local machine, showing multiple metrics for each node including number of PUTS (records stored), current price being charged for storage, and node earnings. Many metrics appear both as numeric values and can be viewed in real-time graphical charts over time.
+
+## Discussion and Bug Reports
+A forum topic is the main place for discussion of `vdash`: [Vdash - Node dashboard for Autonomi nodes](https://forum.autonomi.community/t/vdash-dashboard-for-autonomi-nodes/32630?u=happybeing)
+
+Bug reports and feature requests can be made in [github issues](https://github.com/happybeing/vdash/issues).
+
+## Remote Monitoring
+Remote logfiles could be monitored by using `rsyslog` to mirror them to the machine running `vdash`. This would allow multiple remote machines to be monitored from one machine.
+ I have not tried using `rsylog` but have monitored nodes on a remote machine by using `tail` over `ssh` to mirror a remote logfile to the machine running `vdash`.
+
+Here's an early `vdash` (v0.2.0) working with a local testnet node:
+<img src="./screenshots/vdash-v.0.2.4.gif" alt="screenshot of vdash v0.2.0">
+
+## Features
+`vdash` will load historic metrics from one or more Autonomi node
+logfiles and display these with live updates in the terminal (see above). A list of keyboard commands is available by pressing '?', some of which are described below for the *Summary* and *Node Status* screens.
+
+### Summary of Monitored Nodes
+**'arrow keys':** The up and down arrows select a row, containing data for one particular node. The left and right arrows select a column heading and sorts rows by the values in the selected column.
+
+**'space':** Pressing the space bar toggles sort of the selected column between ascending and descending.
+
+**'enter':** Switches the display to show *Node Status* of the node of the highlighted row.
+
+**'q':** Press 'q' to quit.
+
+**'?':** Shows help.
+
+### Node Status
+**'enter'** Switches the display back to the *Summary of Monitored Nodes*.
+
+**'arrow keys':** The left and right arrows shift the single node display between different nodes.
+
+**'i' and 'o':** Zoom the timeline scale in/out using 'i' and 'o' (or '+' and '-').
+
+**'t' and 'T':** If some timelines are not displayed due to lack of vertical space you can cycle
+through the timelines to bring them into view by pressing 't' (forward) and 'T'
+(backward).
+
+**'m' or 'M':** The Storage Cost timeline displays minimum, mean and maximum
+values in each time-slot. To cycle through the min, mean and max displays
+press 'm' or 'M'.
+
+**'q':** Press 'q' to quit.
+
+**'?':** Shows help.
+
+## Operating Systems
+- **Linux:** works on Linux (tested on Ubuntu).
+- **Windows:** works on Windows 10 and 11. Not tested recently.
+- **MacOS:** works on MacOS. Not tested recently.
+
+## Install using Linux package manager
+
+`vdash` has been packaged as `safe-vdash` for debian and is now available for install in Ubuntu and other debian based Linux distros. My thanks go to the generous efforts of Jonas Smedegaard for this.
+
+From 2024 `safe-vdash` became available in many downstream Linux distributions, but due to the pace of updates the packaged version may be behind the version published at crates.io which is always up to date. You can check the status of package `safe-vdash` in your distribution and choose whether to install from there or get the most recent version as explained below.
+
+## Install from crates.io
+
+You must first install Rust. This applies to Windows, Linux and Mac so start with step 1 and then select the subsequent section for your operating system.
+
+1 Install **Rust** via https://doc.rust-lang.org/cargo/getting-started/installation.html
+
+2a. **Linux (Ubuntu)**
+
+ sudo apt-get install build-essential
+
+2b. **Linux/MacOS** install **vdash:**
+
+ cargo install vdash
+ vdash --help
+
+2c. **Windows** install **vdash:**
+
+To install `vdash` on Windows 10 and 11 from crates.io you will need to install the Microsoft Visual C++ Redistributables for Visual Studio. If you have Visual Studio installed this will already be installed, but if you are using Visual Studio Code you still need to install the following.
+
+- Got to https://visualstudio.microsoft.com/downloads/
+- scroll down to "All Downloads" and click "Other Tools, Frameworks, and Redistributables"
+- click on "Build Tools for Visual Studio"
+- under "Microsoft Visual C++ Redistributable for Visual Studio" choose from x64, ARM64 and x86
+- Click download and then run the VC 'Redist' installer
+
+Finally to install `vdash`:
+
+ cargo install vdash
+ vdash --help
+
+## Using vdash - a node Dashboard for Autonomi
+`vdash` provides a terminal based graphical dashboard of Autonomi node activity on the local machine. It parses input from one or more node logfiles to gather live node metrics which are displayed using terminal graphics.
+
+
+## Get Autonomi pre-requisites
+1. **Get the Autonomi Node Applications:** There various ways to start and run nodes, including two helper apps by Autonomi. The `node-launchpad` is a simple terminal based UI (TUI) and `antctl` is command line program for 'power users', although the community can help you use either. See https://autonomi.com for details of how to obtain these apps.
+
+2. **Start your Autonomi Nodes:** See https://docs.autonomi.com for documentation and join the [forum](https://forum.autonomi.community) if you need help.
+
+If you have also installed `vdash` you can test it by running it on the same machine you are using to run nodes on the Autonomi beta network.
+
+## vdash Usage:
+
+For help:
+
+ vdash --help
+
+Typically you can just pass the paths of one or more node logfiles you want to monitor. For example, to run `vdash` first start your Autonomi node(s) with on of the Autonomi Node Applications (see above).
+
+Then, start `vdash`. You can give a path to one or more logfiles. You can also use `-g` to specify a glob path. When you provide a glob path you can press 'r' to re-scan the path for logfiles after starting more nodes.
+
+The path to logfiles vary depending on which Autonomi Node Application you are using, and also on your operating system. The following are just examples so you will need to provide paths for your particular setup.
+
+**Linux:**
+
+ vdash -g "/home/<USERNAME>/.local/share/autonomi/node/*/logs/antnode.log"
+
+**Mac:**
+
+ vdash "/Users/<USERNAME>/Library/Application Support/autonomi/node/*/logs/antnode.log"
+
+**Windows:**
+
+When running nodes with `node-launchpad`:
+
+ vdash C:\ProgramData\autonomi\node\*\logs\antnode.log
+
+Or if running `antnode` binary directly:
+
+ vdash C:\Users\<USERNAME>\AppData\Roaming\autonomi\node\*\logs\antnode.log
+
+
+Keyboard commands for `vdash` are summarised in the introduction above.
+
+### vdash and 'glob' paths
+
+`vdash` accepts one or more file paths, but you can also specify one or more 'glob' paths which can scan a directory tree for matching files. This enables you to pick up new nodes added after `vdash` starts, either using the 'r' (re-scan) keyboard command, or automatically by giving a re-scanning period using the `--glob-scan` option on the command line.
+
+`vdash` scans all 'glob' paths provided on start-up and again whenever you press 'r'.
+
+Note that unlike a file path you must use quotation marks around a 'glob' path to prevent the shell from trying to expand it. In the examples you will need to replace `<USER>` with the appropriate home directory name for your account.
+
+Example for Linux:
+
+ vdash --glob-path "$HOME/.local/share/autonomi/node/*/logs/antnode.log"
+
+Using double rather than single quotes enables you to use '$HOME' in the path instead of giving the home directory explicitly.
+
+The path to logfiles vary depending on which Autonomi Node Application you are using, and also on your operating system. The following are just examples so you will need to provide paths for your particular setup.
+
+### Display of Token values
+`vdash` shows node earnings and storage cost in terms of Autonomi tokens as 'nanos' or billionths of a token. It can though
+be made to display token values in a local currency (e.g. U.S. dollar, British pound etc). For this it needs
+a way to obtain the conversion rate for the currency and be told what symbol to use in the
+display (e.g. "$", "£" etc.).
+
+You can do this by passing fixed values on the command line, or have
+`vdash` obtain live values using one of the supported web APIs.
+
+### Currency on the Command Line
+Two options allow you to specify the conversion rate and symbol for your chosen currency.
+
+For example, for a token value of 1.23 U.S. dollars you would use the following command line options:
+
+```
+--currency-symbol "$" --currency-token-rate 1.23
+```
+
+You can use the above to provide a default conversion and have live prices override this when available.
+
+For more type `vdash --help`.
+
+### Live Prices via Web API
+`vdash` can obtain the Autonomi token price in a specified currency from the
+Coingecko.com or Coinmarketcap.com web APIs provided you have an access key for the corresponding API. At this time, both offer both paid and free/demo API
+keys which you obtain by signing up for an account with those websites.
+
+If you have keys for one or both of these services you must pass them to `vdash` on the command line as shown below.
+
+In both cases a default polling interval is set by `vdash` that will not exceed the advertised number of API requests for a free API key, although this polling interval can be shortened by specifying the polling interval on the command line.
+
+For more type `vdash --help`.
+
+#### Coingecko.com
+To have `vdash` obtain the token rate from Coingecko.com include the following on the command line and replace `YOUR-API-KEY` with the API key you obtained from the service.
+
+```sh
+--currency-apiname "GBP" --currency-symbol "£" --coingecko-key "YOUR-API-KEY"
+```
+
+#### Coinmarketcap.com
+To have `vdash` obtain the token rate from Coinmarketcap.com include the following on the command line and replace `YOUR-API-KEY` with the API key you obtained from the service.
+
+```sh
+--currency-apiname "GBP" --currency-symbol "£" --coinmarketcap-key "YOUR-API-KEY"
+```
+
+### Using vdash to Monitor Autonomi Nodes
+
+Start your nodes using an Autonomi Node Application.
+
+When your node or nodes have started, run `vdash`, typically in a different terminal:
+```sh
+vdash --glob-path "$HOME/.local/share/autonomi/node/*/antnode.log"
+```
+Modify the above example for your setup, and include any additional command line options as required.
+
+For example, to enable display of earnings and storage costs using local currency:
+```sh
+vdash --currency-apiname "USD" --currency-symbol "$" --glob-path "$HOME/.local/share/autonomi/node/*/logs/antnode.log"
+```
+### What to Expect
+When you start `vdash` it shows the main summary. This shows a list of all nodes being monitored with several statistics for each node. At the top is a summary for all those nodes.
+
+Use the left/right arrow keys and space-bar to sort by each column, up/down to select a node and enter to see details about a particular node. Use '?' to see all keyboard commands.
+
+### Are My Nodes Working?
+It won't be immediately obvious whether your nodes are working correctly, but things to look for are explained below.
+
+Firstly, don't worry about the number of Errors. You will have a lot and that is normal! What you should see fairly quickly are non-zero values for GETS, PUTS, Peers. RAM will tend to be 200-300MB but can rise and fall as node activity varies.
+
+Later you should also begin to see numbers of Records, but Earnings and Store Cost may stay at zero for quite some time depending on the amount of data being uploaded, and the number of other nodes competing to store that data. Eventually you should see Store Cost values for some nodes, and eventually some Earned Nanos.
+
+To start with it is wise to only run a couple of nodes until you are sure things are working. You can start more later and if the system becomes overloaded nodes status may indicate problems such as large amounts of 'shunning' or "INACTIVE" when a node has shut itself down to avoid overloading the CPU.
+
+### Using vdash With a Local Test Network
+
+First clone the Autonomi repository and change directory into the cloned copy and checkout branch `stable`:
+
+```sh
+git clone https://github.com/maidsafe/autonomi
+cd autonomi
+git checkout stable
+```
+
+Then start a local test network using the instructions [here](https://github.com/maidsafe/autonomi?tab=readme-ov-file#using-a-local-network).
+
+You can then start `vdash` to display the status of the nodes in that network as follows:
+
+```sh
+vdash --currency-apiname "USD" --currency-symbol "$" --glob-path "$HOME/.local/share/autonomi/node/*/logs/antnode.log"
+```
+
+If you return to the instructions [here](https://github.com/maidsafe/autonomi?tab=readme-ov-file#using-a-local-network) you can obtain some tokens to pay for your file uploads, and try uploading some files again using the instructions at that link, and monitor the activity of your test network nodes using `vdash`.
+
+## Build (for Developers Only)
+
+See [Get Autonomi Pre-requisites](#get-autonomi-pre-requisites).
+
+### Get code
+```
+git clone https://github.com/happybeing/vdash
+cd vdash
+```
+
+### Build - Linux / MacOS / Windows 10
+Note: MacOS and Windows are untested but may 'just work' - please report success or failure in an issue.
+```
+cargo build --release
+```
+If built for target 'musl' `vdash` uses considerably less memory:
+
+```sh
+rustup target add x86_64-unknown-linux-musl
+cargo build --release --target x86_64-unknown-linux-musl
+```
+Comparing memory use (using `htop` on Linux):
+```sh
+VIRT RES SHR
+803M 9372 4716 x13 threads (release)
+32768 6848 2440 x13 threads (release/musl)
+```
+Note: the above figures are out of date but illustrate the point.
+
+## LICENSE
+
+Everything is AGPL3.0 unless otherwise stated. Any contributions are accepted on the condition they conform to this license.
+
+See also [./LICENSE](./LICENSE)
\ No newline at end of file
--- /dev/null
+edition = "2018"
+hard_tabs = true
+tab_spaces = 2
\ No newline at end of file
--- /dev/null
+//! This app monitors logfiles and displays status in the terminal
+//!
+//! It is based on logtail-dash, which is a basic logfile dashboard
+//! and also a framework for similar apps with customised dashboard
+//! displays.
+//!
+//! Custom apps based on logtail can be created by creating a
+//! fork of logtail-dash and modifying the files in src/custom
+//!
+//! See README for more information.
+
+#![recursion_limit = "1024"] // Prevent select! macro blowing up
+
+#[path = "../custom/mod.rs"]
+pub mod custom;
+use self::custom::app::{OPT, App, DashViewMain};
+use self::custom::ui::draw_dashboard;
+
+#[macro_use]
+extern crate log;
+extern crate env_logger;
+
+///! logtail and its forks share code in src/
+#[path = "../mod.rs"]
+pub mod shared;
+
+use crossterm::{
+ event::{self, DisableMouseCapture, EnableMouseCapture, Event as CEvent},
+ execute,
+ terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
+};
+
+use std::{
+ error::Error,
+ io::stdout,
+ thread,
+ time::{Duration, Instant,SystemTime, UNIX_EPOCH},
+};
+
+use chrono::Utc;
+
+use ratatui::{backend::CrosstermBackend, Terminal};
+
+use futures::{
+ future::FutureExt, // for `.fuse()`
+ pin_mut,
+ select,
+};
+
+pub enum Event<I> {
+ Input(I),
+ Tick,
+}
+
+use tokio_stream::StreamExt;
+use tokio::sync::mpsc;
+
+#[tokio::main]
+pub async fn main() -> Result<(), Box<dyn Error>> {
+ let (opt_tick_rate, checkpoint_interval, opt_debug_window,
+ coingecho_api_key, coinmarketcap_api_key, currency_apiname) = {
+ let opt = OPT.lock().unwrap();
+ (opt.tick_rate, opt.checkpoint_interval, opt.debug_window,
+ opt.coingecko_key.clone(), opt.coinmarketcap_key.clone(), opt.currency_apiname.clone())
+ };
+
+ env_logger::init();
+ info!("Started");
+
+ let mut app = match App::new().await {
+ Ok(app) => app,
+ Err(_e) => return Ok(()),
+ };
+
+ let mut web_apis = crate::custom::web_requests::WebPriceAPIs::new(coingecho_api_key, coinmarketcap_api_key, ¤cy_apiname);
+
+ // Terminal initialization
+ enable_raw_mode()?;
+
+ let mut stdout = stdout();
+ execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
+ let backend = CrosstermBackend::new(stdout);
+ let mut terminal = Terminal::new(backend)?;
+ let mut rx = initialise_events(opt_tick_rate);
+ terminal.clear()?;
+
+ // Use futures of async functions to handle events
+ // concurrently with logfile changes.
+
+ let start = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .expect("Time went backwards");
+ let mut next_update = start - Duration::from_secs(2);
+ loop {
+ if next_update < SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .expect("Time went backwards") {
+ terminal.draw(|f| draw_dashboard(f, &mut app))?;
+ next_update += Duration::from_secs(1);
+ match web_apis.handle_web_requests().await {
+ Ok(Some(currency_per_token)) => {
+ app.dash_state.currency_per_token = Some(currency_per_token);
+ app.update_summary_window();
+ },
+ Ok(None) => {},
+ Err(e) => {
+ _ = reset_terminal(&mut terminal);
+ eprintln!("Web API error, {}", e);
+ return Ok(());
+ },
+ };
+ let prices = custom::app::WEB_PRICES.lock().unwrap();
+ if prices.snt_rate.is_some() {
+ app.dash_state.currency_per_token = prices.snt_rate;
+ }
+ }
+
+ let logfiles_future = app.logfiles_manager.linemux_files.next().fuse();
+ let events_future = rx.recv().fuse();
+
+ pin_mut!(logfiles_future, events_future);
+
+ select! {
+ e = events_future => {
+ match e {
+ Some(Event::Input(event)) => {
+ if !self::custom::ui_keyboard::handle_keyboard_event(&mut app, &event, opt_debug_window).await {
+ return reset_terminal(&mut terminal);
+ }
+ terminal.draw(|f| draw_dashboard(f, &mut app)).unwrap();
+ }
+
+ Some(Event::Tick) => {
+ app.update_timelines(&Utc::now());
+ app.scan_glob_paths(true, true).await;
+ terminal.draw(|f| draw_dashboard(f, &mut app)).unwrap();
+ // draw_dashboard(&mut f, &dash_state, &mut monitors).unwrap();
+ // draw_dashboard(f, &dash_state, &mut monitors)?;
+ }
+
+ None => {},
+ }
+ },
+ line = logfiles_future => {
+ match line {
+ Some(Ok(line)) => {
+ trace!("logfiles_future line");
+ let source_str = line.source().to_str().unwrap();
+ let source = String::from(source_str);
+ // app.dash_state._debug_window(format!("{}: {}", source, line.line()).as_str());
+
+ let mut checkpoint_result: Result<String, std::io::Error> = Ok("".to_string());
+ match app.get_monitor_for_file_path(&source) {
+ Some(monitor) => {
+ checkpoint_result = monitor.append_to_content(line.line(), checkpoint_interval);
+ if monitor.is_debug_dashboard_log {
+ app.dash_state._debug_window(line.line());
+ } else if app.dash_state.main_view == DashViewMain::DashSummary {
+ app.update_summary_window();
+ }
+ },
+ None => {
+ app.dash_state._debug_window(format!("NO MONITOR FOR: {}", source).as_str());
+ },
+ }
+ match checkpoint_result {
+ Ok(message) => {
+ if message.len() > 0 {
+ app.dash_state.vdash_status.message(&message, None);
+ }
+ },
+ Err(e) => {
+ app.dash_state.vdash_status.message(&e.to_string(), None);
+ }
+ }
+ },
+ Some(Err(e)) => {
+ app.dash_state._debug_window(format!("logfile error: {:#?}", e).as_str());
+ panic!("{}", e)
+ }
+ None => {
+ app.dash_state._debug_window(format!("logfile error: None").as_str());
+ ()
+ }
+ }
+ },
+ }
+ }
+}
+
+fn reset_terminal(terminal: &mut Terminal::<CrosstermBackend<std::io::Stdout>>) -> Result<(), Box<dyn Error>> {
+ disable_raw_mode()?;
+ execute!(
+ terminal.backend_mut(),
+ LeaveAlternateScreen,
+ DisableMouseCapture
+ )?;
+ terminal.show_cursor()?;
+ Ok(())
+}
+
+type Rx = tokio::sync::mpsc::UnboundedReceiver<Event<crossterm::event::KeyEvent>>;
+
+fn initialise_events(tick_rate: u64) -> Rx {
+ let tick_rate = Duration::from_millis(tick_rate);
+ let (tx, rx) = mpsc::unbounded_channel(); // Setup input handling
+
+ thread::spawn(move || {
+ let mut last_tick = Instant::now();
+ loop {
+ // poll for tick rate duration, if no events, sent tick event.
+ if event::poll(tick_rate - last_tick.elapsed()).unwrap() {
+ if let CEvent::Key(key) = event::read().unwrap() {
+ match tx.send(Event::Input(key)) {
+ Ok(()) => {},
+ Err(e) => eprintln!("send error: {}", e),
+
+ }
+ }
+ }
+ if last_tick.elapsed() >= tick_rate {
+ match tx.send(Event::Tick) {
+ Ok(()) => last_tick = Instant::now(),
+ Err(e) => eprintln!("send error: {}", e),
+
+ }
+ }
+
+ // TODO remove duplicate code!
+ if last_tick.elapsed() >= tick_rate {
+ match tx.send(Event::Tick) {
+ Ok(()) => last_tick = Instant::now(),
+ Err(e) => eprintln!("send error: {}", e),
+ }
+ }
+ }
+ });
+ rx
+}
+
--- /dev/null
+///! Application logic
+//
+// TODO consider colouring logfiles using regex's from https://github.com/bensadeh/tailspin
+use std::collections::HashMap;
+use std::fs::File;
+use std::io::{Error, ErrorKind, Write};
+use std::path::Path;
+use std::sync::LazyLock;
+
+use chrono::{DateTime, Duration, Utc};
+use serde::{Deserialize, Serialize};
+use structopt::StructOpt;
+use tempfile::NamedTempFile;
+
+use crate::shared::util::StatefulList;
+
+use super::app_timelines::{AppTimelines, APP_TIMELINES, TIMESCALES};
+use super::app_timelines::{
+ CONNECTIONS_TIMELINE_KEY, EARNINGS_TIMELINE_KEY, ERRORS_TIMELINE_KEY, GETS_TIMELINE_KEY,
+ PUTS_TIMELINE_KEY, RAM_TIMELINE_KEY, STORAGE_COST_TIMELINE_KEY,
+};
+use super::logfile_checkpoints::save_checkpoint;
+use super::logfiles_manager::LogfilesManager;
+use super::opt::{Opt, MIN_TIMELINE_STEPS};
+use super::timelines::{get_duration_text, MinMeanMax};
+
+pub const NODE_BINARY_NAME: &str = "safenode";
+pub static SUMMARY_WINDOW_NAME: &str = "Summary of Monitored Nodes";
+pub static HELP_WINDOW_NAME: &str = "Help";
+pub static DEBUG_WINDOW_NAME: &str = "Debug Window";
+
+use std::sync::Mutex;
+static DEBUG_LOGFILE: LazyLock<Mutex<Option<NamedTempFile>>> =
+ LazyLock::new(|| Mutex::<Option<NamedTempFile>>::new(None));
+
+#[macro_export]
+macro_rules! debug_log {
+ ($message:expr) => {
+ unsafe {
+ debug_log($message);
+ }
+ };
+}
+pub use crate::debug_log;
+
+pub unsafe fn debug_log(message: &str) {
+ // --debug-window - prints parser results for a single logfile
+ // to a temp logfile which is displayed in the adjacent window.
+ match &(*DEBUG_LOGFILE.lock().unwrap()) {
+ Some(f) => {
+ use std::io::Seek;
+ if let Ok(mut file) = f.reopen() {
+ file.seek(std::io::SeekFrom::End(0)).unwrap();
+ writeln!(file, "{}", message).unwrap();
+ }
+ }
+ None => (),
+ };
+}
+
+pub static OPT: LazyLock<Mutex<Opt>> = LazyLock::new(|| Mutex::<Opt>::new(Opt::from_args()));
+
+pub static WEB_PRICES: LazyLock<Mutex<super::web_requests::WebPrices>> = LazyLock::new(|| {
+ Mutex::<super::web_requests::WebPrices>::new(super::web_requests::WebPrices::new())
+});
+
+pub struct App {
+ pub dash_state: DashState,
+ pub monitors: HashMap<String, LogMonitor>,
+ pub logfile_with_focus: String,
+
+ pub logfiles_manager: LogfilesManager,
+ pub next_glob_scan: Option<DateTime<Utc>>,
+}
+
+impl App {
+ pub async fn new() -> Result<App, std::io::Error> {
+ let (
+ opt_files,
+ opt_globpaths,
+ opt_debug_window,
+ opt_timeline_steps,
+ opt_currency_token_rate,
+ opt_currency_symbol,
+ opt_currency_apiname,
+ ) = {
+ let opt = OPT.lock().unwrap();
+ (
+ opt.files.clone(),
+ opt.glob_paths.clone(),
+ opt.debug_window,
+ opt.timeline_steps,
+ opt.currency_token_rate,
+ opt.currency_symbol.clone(),
+ opt.currency_apiname.clone(),
+ )
+ };
+
+ let mut app = App {
+ dash_state: DashState::new(),
+ monitors: HashMap::new(),
+ logfile_with_focus: String::new(),
+
+ logfiles_manager: LogfilesManager::new(opt_globpaths.clone()),
+ next_glob_scan: None,
+ };
+
+ app.dash_state.currency_symbol = opt_currency_symbol.clone();
+ if opt_currency_token_rate > 0.0 {
+ app.dash_state.currency_per_token = Some(opt_currency_token_rate);
+ app.dash_state.ui_uses_currency = true;
+ }
+
+ let mut web_prices = WEB_PRICES.lock().unwrap();
+ web_prices.currency_symbol = opt_currency_symbol;
+ web_prices.currency_apiname = opt_currency_apiname;
+
+ if opt_files.is_empty() && opt_globpaths.is_empty() {
+ eprintln!(
+ "{}: no logfile(s) or 'glob' paths provided.",
+ Opt::clap().get_name()
+ );
+ return exit_with_usage("missing logfiles");
+ }
+
+ if opt_timeline_steps < MIN_TIMELINE_STEPS {
+ eprintln!(
+ "Timeline steps number is too small, minimum is {}",
+ MIN_TIMELINE_STEPS
+ );
+ return exit_with_usage("invalid parameter");
+ }
+
+ let mut dash_state = DashState::new();
+ dash_state.debug_window = opt_debug_window;
+ if opt_debug_window {
+ dash_state.main_view = DashViewMain::DashDebug;
+ }
+
+ let mut files_to_load = opt_files.clone();
+
+ if opt_debug_window {
+ if opt_files.len() == 0 {
+ eprint!("For debugging with --debug-window you must specify a logfile path.");
+ return exit_with_usage("missing logfile");
+ }
+
+ // For debug: only use first logfile, plus one for debug messages
+ files_to_load = opt_files[0..1].to_vec();
+ let debug_file = NamedTempFile::new()?;
+ let path = debug_file.path();
+ let path_str = path
+ .to_str()
+ .ok_or_else(|| Error::new(ErrorKind::Other, "invalid path"))?;
+ files_to_load.push(String::from(path_str));
+ *DEBUG_LOGFILE.lock().unwrap() = Some(debug_file);
+ }
+
+ if files_to_load.len() > 0 {
+ app
+ .logfiles_manager
+ .monitor_multi_paths(files_to_load, &mut app.monitors, &mut app.dash_state, false)
+ .await;
+ }
+
+ app.scan_glob_paths(false, false).await;
+
+ if app.logfiles_manager.logfiles_added.len() > 0 {
+ app.logfile_with_focus = app.logfiles_manager.logfiles_added[0].clone(); // Save to give focus
+ } else {
+ app.dash_state.vdash_status.message(
+ &"No files to monitor, please start a node and try again.".to_string(),
+ None,
+ );
+ return exit_with_usage("no files to monitor.");
+ }
+
+ app.update_timelines(&Utc::now());
+ app.update_summary_window();
+
+ if !app.logfile_with_focus.is_empty() {
+ app.dash_state.dash_node_focus = app.logfile_with_focus.clone();
+ }
+
+ app.set_logfile_with_focus(app.logfile_with_focus.clone());
+ app.dash_state.vdash_status.disable_to_console();
+ Ok(app)
+ }
+
+ pub async fn scan_glob_paths(&mut self, timed: bool, disable_status: bool) {
+ if self.logfiles_manager.globpaths.len() == 0 {
+ return;
+ }
+ let opt_globs_scan = OPT.lock().unwrap().glob_scan;
+
+ let mut do_scan = !timed;
+ if timed && opt_globs_scan > 0 {
+ let current_time = Utc::now();
+ if let Some(next_glob_scan) = self.next_glob_scan {
+ if current_time > next_glob_scan {
+ self.next_glob_scan = Some(current_time + Duration::seconds(opt_globs_scan));
+ do_scan = true;
+ }
+ } else {
+ self.next_glob_scan = Some(current_time + Duration::seconds(opt_globs_scan));
+ do_scan = true;
+ }
+ }
+
+ if do_scan {
+ let opt_glob_paths = OPT.lock().unwrap().glob_paths.clone();
+ self
+ .logfiles_manager
+ .scan_multi_globpaths(
+ opt_glob_paths,
+ &mut self.monitors,
+ &mut self.dash_state,
+ disable_status,
+ )
+ .await;
+ }
+ }
+
+ pub fn update_timelines(&mut self, now: &DateTime<Utc>) {
+ for (_monitor_file, monitor) in self.monitors.iter_mut() {
+ monitor.metrics.update_timelines(now);
+ }
+ }
+
+ pub fn get_monitor_for_file_path(&mut self, logfile: &String) -> Option<&mut LogMonitor> {
+ let mut monitor_for_path = None;
+ for (monitor_file, monitor) in self.monitors.iter_mut() {
+ if monitor_file.eq(logfile) {
+ monitor_for_path = Some(monitor);
+ break;
+ }
+ use std::env::current_dir;
+ if let Ok(current_dir) = current_dir() {
+ let logfile_path = Path::new(logfile.as_str());
+ if current_dir.join(monitor_file).eq(&logfile_path) {
+ monitor_for_path = Some(monitor);
+ break;
+ }
+ }
+ }
+ return monitor_for_path;
+ }
+
+ pub fn get_debug_dashboard_logfile(&mut self) -> Option<String> {
+ for (_logfile, monitor) in self.monitors.iter_mut() {
+ if monitor.is_debug_dashboard_log {
+ return Some(monitor.logfile.clone());
+ }
+ }
+ None
+ }
+
+ pub fn get_logfile_with_focus(&mut self) -> Option<String> {
+ match (&mut self.monitors).get_mut(&self.logfile_with_focus) {
+ Some(monitor) => Some(monitor.logfile.clone()),
+ None => None,
+ }
+ }
+
+ pub fn get_monitor_with_focus(&mut self) -> Option<&mut LogMonitor> {
+ match (&mut self.monitors).get_mut(&self.logfile_with_focus) {
+ Some(monitor) => Some(monitor),
+ None => None,
+ }
+ }
+
+ pub fn set_logfile_with_focus(&mut self, logfile_name: String) {
+ if logfile_name.len() == 0 {
+ return;
+ }
+
+ match self.get_monitor_with_focus() {
+ Some(fading_monitor) => {
+ fading_monitor.has_focus = false;
+ self.logfile_with_focus = String::new();
+ }
+ None => (),
+ }
+
+ if logfile_name == DEBUG_WINDOW_NAME {
+ self.dash_state.debug_window_has_focus = true;
+ self.logfile_with_focus = logfile_name.clone();
+ return;
+ } else {
+ self.dash_state.debug_window_has_focus = false;
+ }
+
+ if let Some(focus_monitor) = (&mut self.monitors).get_mut(&logfile_name) {
+ focus_monitor.has_focus = true;
+ self.logfile_with_focus = logfile_name.clone();
+ } else {
+ error!("Unable to focus UI on: {}", logfile_name);
+ };
+ }
+
+ pub fn change_focus_next(&mut self) {
+ if self.logfiles_manager.logfiles_added.len() == 0 {
+ return;
+ }
+
+ let opt_debug_window = {
+ let opt = OPT.lock().unwrap();
+ opt.debug_window
+ };
+
+ if self.dash_state.main_view == DashViewMain::DashDebug {
+ return;
+ }
+
+ if self.dash_state.main_view == DashViewMain::DashSummary {
+ if self.dash_state.summary_window_heading_selected
+ < self.dash_state.summary_window_headings.items.len() - 1
+ {
+ self.dash_state.summary_window_heading_selected += 1;
+ self.update_summary_window();
+ }
+ }
+
+ let mut next_i = 0;
+ for (i, name) in self.logfiles_manager.logfiles_added.iter().enumerate() {
+ if name == &self.logfile_with_focus {
+ if i < self.logfiles_manager.logfiles_added.len() - 1 {
+ next_i = i + 1;
+ }
+ break;
+ }
+ }
+
+ if next_i == 0 && opt_debug_window && self.logfile_with_focus != DEBUG_WINDOW_NAME {
+ self.set_logfile_with_focus(DEBUG_WINDOW_NAME.to_string());
+ return;
+ }
+
+ let logfile = self.logfiles_manager.logfiles_added[next_i].to_string();
+ self.set_logfile_with_focus(logfile.clone());
+
+ if let Some(debug_logfile) = self.get_debug_dashboard_logfile() {
+ if logfile.eq(&debug_logfile) {
+ self.change_focus_next();
+ }
+ }
+ }
+
+ pub fn change_focus_previous(&mut self) {
+ if self.logfiles_manager.logfiles_added.len() == 0 {
+ return;
+ }
+
+ let opt_debug_window = {
+ let opt = OPT.lock().unwrap();
+ opt.debug_window
+ };
+
+ if self.dash_state.main_view == DashViewMain::DashDebug {
+ return;
+ }
+
+ if self.dash_state.main_view == DashViewMain::DashSummary {
+ if self.dash_state.summary_window_heading_selected > 0 {
+ self.dash_state.summary_window_heading_selected -= 1;
+ self.update_summary_window();
+ }
+ }
+
+ let len = self.logfiles_manager.logfiles_added.len();
+ let mut previous_i = len - 1;
+ for (i, name) in self.logfiles_manager.logfiles_added.iter().enumerate() {
+ if name == &self.logfile_with_focus {
+ if i > 0 {
+ previous_i = i - 1;
+ }
+ break;
+ }
+ }
+
+ if opt_debug_window && previous_i == len - 1 && self.logfile_with_focus != DEBUG_WINDOW_NAME {
+ self.set_logfile_with_focus(DEBUG_WINDOW_NAME.to_string());
+ return;
+ }
+
+ let logfile = self.logfiles_manager.logfiles_added[previous_i].to_string();
+ self.set_logfile_with_focus(logfile.clone());
+
+ if let Some(debug_logfile) = self.get_debug_dashboard_logfile() {
+ if logfile.eq(&debug_logfile) {
+ self.change_focus_previous();
+ }
+ }
+ }
+
+ pub fn change_focus_to(&mut self, logfile_index: usize) {
+ if logfile_index < self.logfiles_manager.logfiles_added.len() {
+ self.set_logfile_with_focus(self.logfiles_manager.logfiles_added[logfile_index].clone());
+ self.dash_state.main_view = DashViewMain::DashNode;
+ }
+ }
+
+ pub fn handle_arrow_up(&mut self) {
+ self.handle_arrow(false);
+ }
+
+ pub fn handle_arrow_down(&mut self) {
+ self.handle_arrow(true);
+ }
+
+ pub fn handle_arrow(&mut self, is_down: bool) {
+ if self.logfiles_manager.logfiles_added.len() == 0 {
+ return;
+ }
+
+ let opt_debug_window = {
+ let opt = OPT.lock().unwrap();
+ opt.debug_window
+ };
+
+ let list = match self.dash_state.main_view {
+ DashViewMain::DashSummary => Some(&mut self.dash_state.summary_window_rows),
+ DashViewMain::DashNode => {
+ if let Some(monitor) = self.get_monitor_with_focus() {
+ Some(&mut monitor.content)
+ } else if opt_debug_window {
+ Some(&mut self.dash_state.debug_window_list)
+ } else {
+ None
+ }
+ }
+ DashViewMain::DashHelp => None,
+ DashViewMain::DashDebug => {
+ if opt_debug_window {
+ Some(&mut self.dash_state.debug_window_list)
+ } else {
+ None
+ }
+ }
+ };
+
+ if let Some(list) = list {
+ do_bracketed_next_previous(list, is_down);
+ }
+ }
+
+ pub fn preserve_node_selection(&mut self) {
+ if self.logfiles_manager.logfiles_added.len() == 0 {
+ return;
+ }
+
+ if self.dash_state.main_view == DashViewMain::DashSummary {
+ if let Some(selected_index) = self.dash_state.summary_window_rows.state.selected() {
+ let selected_logfile = &self.dash_state.logfile_names_sorted[selected_index];
+ if let Some(node_index) = self
+ .logfiles_manager
+ .logfiles_added
+ .iter()
+ .position(|s| s == selected_logfile.as_str())
+ {
+ self.change_focus_to(node_index);
+ }
+ }
+ } else if self.dash_state.main_view == DashViewMain::DashNode {
+ for index in 0..self.dash_state.logfile_names_sorted.len() {
+ if self.dash_state.logfile_names_sorted[index] == self.logfile_with_focus {
+ self
+ .dash_state
+ .summary_window_rows
+ .state
+ .select(Some(index));
+ break;
+ }
+ }
+
+ if let Some(monitor) = self.get_monitor_with_focus() {
+ let selected_logfile = monitor.logfile.clone();
+ if let Some(node_index) = self
+ .dash_state
+ .logfile_names_sorted
+ .iter()
+ .position(|s| s == selected_logfile.as_str())
+ {
+ self
+ .dash_state
+ .summary_window_rows
+ .state
+ .select(Some(node_index));
+ }
+ }
+ }
+ }
+
+ // TODO this regenerates every line. May be worth just updating the line for the updated node/monitor
+ // Needs to be on the app to manage focus for DashSummary and DashNode through sorting of summary table
+ pub fn update_summary_window(&mut self) {
+ let current_selection = self.dash_state.summary_window_rows.state.selected();
+
+ self.dash_state.summary_window_rows = StatefulList::new();
+
+ // TODO could avoid this repeated copy by ensuring both are modified at the same time
+ self.dash_state.logfile_names_sorted = self
+ .logfiles_manager
+ .logfiles_added
+ .iter()
+ .map(|f| f.clone())
+ .collect();
+
+ super::ui_summary_table::sort_nodes_by_column(&mut self.dash_state, &mut self.monitors);
+
+ for i in 0..self.dash_state.logfile_names_sorted.len() {
+ let filepath = self.dash_state.logfile_names_sorted[i].clone();
+ if let Some(monitor) = self.monitors.get_mut(&filepath) {
+ if !monitor.is_debug_dashboard_log {
+ monitor.metrics.update_node_status_string();
+ let node_summary = super::ui_summary_table::format_table_row(&self.dash_state, monitor);
+ self.append_to_summary_window(&node_summary);
+ }
+ }
+ }
+
+ self
+ .dash_state
+ .summary_window_rows
+ .state
+ .select(current_selection);
+ }
+
+ fn append_to_summary_window(&mut self, text: &str) {
+ self
+ .dash_state
+ .summary_window_rows
+ .items
+ .push(text.to_string());
+
+ let len = self.dash_state.summary_window_rows.items.len();
+
+ if len > self.dash_state.max_summary_window {
+ self.dash_state.summary_window_rows.items = self
+ .dash_state
+ .summary_window_rows
+ .items
+ .split_off(len - self.dash_state.max_summary_window);
+ } else {
+ self
+ .dash_state
+ .summary_window_rows
+ .state
+ .select(Some(len - 1));
+ }
+ }
+
+ pub fn toggle_logfile_area(&mut self) {
+ self.dash_state.node_logfile_visible = !self.dash_state.node_logfile_visible;
+ }
+
+ pub fn scale_timeline_up(&mut self) {
+ if self.dash_state.active_timescale == 0 {
+ return;
+ }
+ self.dash_state.active_timescale -= 1;
+ }
+
+ pub fn scale_timeline_down(&mut self) {
+ if self.dash_state.active_timescale == TIMESCALES.len() - 1 {
+ return;
+ }
+ self.dash_state.active_timescale += 1;
+ }
+
+ pub fn top_timeline_next(&mut self) {
+ if self.dash_state.top_timeline < APP_TIMELINES.len() {
+ self.dash_state.top_timeline += 1;
+ } else {
+ self.dash_state.top_timeline = 0;
+ }
+ }
+
+ pub fn top_timeline_previous(&mut self) {
+ if self.dash_state.top_timeline > 0 {
+ self.dash_state.top_timeline -= 1;
+ } else {
+ self.dash_state.top_timeline = APP_TIMELINES.len() - 1;
+ }
+ }
+
+ // Rotate UI display state through Min, Mean, Max values
+ pub fn bump_mmm_ui_mode(&mut self) {
+ self.dash_state.bump_mmm_ui_mode();
+ }
+
+ pub fn mmm_ui_mode(&mut self) -> &MinMeanMax {
+ return self.dash_state.mmm_ui_mode();
+ }
+}
+
+/// Move selection forward or back without wrapping at start or end
+fn do_bracketed_next_previous(list: &mut StatefulList<String>, next: bool) {
+ if next {
+ if let Some(selected) = list.state.selected() {
+ if selected != list.items.len() - 1 {
+ list.next();
+ }
+ } else {
+ list.previous();
+ }
+ } else {
+ if let Some(selected) = list.state.selected() {
+ if selected != 0 {
+ list.previous();
+ }
+ } else {
+ list.previous();
+ }
+ }
+}
+
+fn exit_with_usage(reason: &str) -> Result<App, std::io::Error> {
+ eprintln!(
+ "Try '{} --help' for more information.",
+ Opt::clap().get_name()
+ );
+ return Err(Error::new(ErrorKind::Other, reason));
+}
+
+const NODE_INACTIVITY_TIMEOUT_S: i64 = 20; // Seconds with no log message before node becomes 'inactive'
+
+pub struct LogMonitor {
+ pub index: usize,
+ pub content: StatefulList<String>,
+ max_content: usize, // Limit number of lines in content
+ pub has_focus: bool,
+ pub logfile: String,
+ pub metrics: NodeMetrics,
+ pub metrics_status: StatefulList<String>,
+ pub is_debug_dashboard_log: bool,
+ pub latest_checkpoint_time: Option<DateTime<Utc>>,
+}
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+static NEXT_MONITOR: AtomicUsize = AtomicUsize::new(0);
+
+fn next_unused_index(monitors: &mut HashMap<String, LogMonitor>) -> usize {
+ let mut next_index = 0;
+
+ let mut index_unused = false;
+ while !index_unused {
+ next_index = NEXT_MONITOR.fetch_add(1, Ordering::Relaxed);
+
+ index_unused = true;
+ for (_logfile, monitor) in monitors.iter() {
+ if next_index == monitor.index {
+ index_unused = false;
+ }
+ }
+ }
+
+ next_index
+}
+
+use super::logfile_checkpoints::LogfileCheckpoint;
+
+impl LogMonitor {
+ pub fn new(logfile_path: String) -> LogMonitor {
+ let mut is_debug_dashboard_log = false;
+ if let Some(debug_logfile) = &*DEBUG_LOGFILE.lock().unwrap() {
+ if let Some(debug_logfile_path) = debug_logfile.path().to_str() {
+ is_debug_dashboard_log = logfile_path.eq(debug_logfile_path);
+ }
+ }
+
+ let opt_lines_max = { OPT.lock().unwrap().lines_max };
+ LogMonitor {
+ index: 0,
+ logfile: logfile_path,
+ max_content: opt_lines_max,
+ metrics: NodeMetrics::new(),
+ content: StatefulList::with_items(vec![]),
+ has_focus: false,
+ metrics_status: StatefulList::with_items(vec![]),
+ is_debug_dashboard_log,
+ latest_checkpoint_time: None,
+ }
+ }
+
+ /// Resolve any clash between self.index and index of other monitors which may happen
+ /// when mixing creation of new monitors with initialisation by restoring a checkpoint.
+ ///
+ /// For a restored checkpoint the metrics should be set, so if one has metrics and the other
+ /// doesn't, the former is treated as older and given the lower index.
+ pub fn canonicalise_monitor_index(&mut self, monitors: &mut HashMap<String, LogMonitor>) {
+ if self.index == 0 {
+ self.index = NEXT_MONITOR.fetch_add(1, Ordering::Relaxed);
+ }
+
+ let existing_index = NEXT_MONITOR.fetch_add(0, Ordering::Relaxed);
+ let next_index = next_unused_index(monitors);
+
+ let mut clash_monitor = None;
+ for (other_logfile, other) in monitors.iter_mut() {
+ if self.index == other.index && &self.logfile != other_logfile {
+ clash_monitor = Some(other);
+ }
+ }
+
+ if let Some(other) = clash_monitor {
+ let mut lower_index = self.index;
+ let mut higher_index = next_index;
+ if lower_index > higher_index {
+ lower_index = next_index;
+ higher_index = self.index;
+ }
+
+ // Default
+ self.index = higher_index;
+ other.index = lower_index;
+
+ // If we know the earlier of the two metrics, use that to order the index in self and other
+ if let Some(self_start_time) = self.metrics.node_started {
+ let flip = if let Some(other_start_time) = other.metrics.node_started {
+ self_start_time < other_start_time
+ } else {
+ true
+ };
+ if flip {
+ self.index = lower_index;
+ other.index = higher_index;
+ }
+ }
+ } else {
+ // next_index not used so restore state to avoid unnecessary increments
+ NEXT_MONITOR.store(existing_index, Ordering::Relaxed);
+ }
+ }
+
+ pub fn is_node(&self) -> bool {
+ return !self.is_debug_dashboard_log;
+ }
+
+ pub fn from_checkpoint(&mut self, checkpoint: &LogfileCheckpoint) {
+ self.index = checkpoint.monitor_index;
+ self.latest_checkpoint_time = checkpoint.latest_entry_time;
+ self.metrics = checkpoint.monitor_metrics.clone();
+ }
+
+ pub fn to_checkpoint(&mut self, checkpoint: &mut LogfileCheckpoint) {
+ checkpoint.latest_entry_time = self.latest_checkpoint_time;
+ checkpoint.monitor_index = self.index;
+ checkpoint.monitor_metrics = self.metrics.clone();
+ }
+
+ // TODO if speed is an issue look at speeding up:
+ // TODO - LogEntry::decode_metadata()
+ // TODO - finding first log entry to decode using a bisection search
+ pub fn load_logfile_from_time(
+ &mut self,
+ dash_state: &mut DashState,
+ after_time: Option<DateTime<Utc>>,
+ ) -> std::io::Result<()> {
+ if let Some(after_time) = after_time {
+ dash_state.vdash_status.message(
+ &format!("loading logfile after time: {}", after_time).to_string(),
+ None,
+ );
+ }
+
+ use std::io::{BufRead, BufReader};
+
+ let f = File::open(self.logfile.to_string());
+ let f = match f {
+ Ok(file) => file,
+ Err(_e) => return Ok(()), // It's ok for a logfile not to exist yet
+ };
+
+ let f = BufReader::new(f);
+
+ for line in f.lines() {
+ let line = line.expect("Unable to read line");
+ self.append_to_content_from_time(dash_state, &line, after_time)?;
+ if self.is_debug_dashboard_log {
+ dash_state._debug_window(&line);
+ }
+ }
+
+ if self.content.items.len() > 0 {
+ self
+ .content
+ .state
+ .select(Some(self.content.items.len() - 1));
+ }
+
+ Ok(())
+ }
+
+ pub fn append_to_content(
+ &mut self,
+ line: &str,
+ checkpoint_interval: u64,
+ ) -> Result<String, std::io::Error> {
+ self.metrics.parser_output = format!("LogMeta::decode_metadata() failed on: {}", line); // For debugging
+ // debug_log!(&self.parser_output.clone());
+
+ self.metrics.entry_metadata = LogEntry::decode_metadata(line);
+
+ if self.metrics.entry_metadata.is_none() {
+ // debug_log!("gather_metrics() - skipping bec. metadata missing");
+ return Ok("".to_string()); // Skip until start of first log message
+ }
+
+ self._append_to_content(line)?; // Show in TUI
+ if self.is_debug_dashboard_log {
+ return Ok("".to_string());
+ }
+
+ self.metrics.gather_metrics(&line)?;
+
+ if checkpoint_interval > 0 {
+ // Checkpoints disabled by zero interval
+ return self.update_checkpoint(checkpoint_interval);
+ }
+
+ Ok("".to_string())
+ }
+
+ pub fn update_checkpoint(&mut self, checkpoint_interval: u64) -> Result<String, Error> {
+ if let Some(metadata) = &self.metrics.entry_metadata {
+ if self.latest_checkpoint_time.is_none() {
+ return save_checkpoint(self);
+ } else {
+ if let Some(latest_checkpoint_time) = self.latest_checkpoint_time {
+ if latest_checkpoint_time + Duration::seconds(checkpoint_interval as i64)
+ < metadata.message_time
+ {
+ return save_checkpoint(self);
+ }
+ }
+ }
+ }
+
+ Ok("".to_string())
+ }
+
+ pub fn append_to_content_from_time(
+ &mut self,
+ _dash_state: &mut DashState,
+ line: &str,
+ after_time: Option<DateTime<Utc>>,
+ ) -> Result<(), std::io::Error> {
+ self.metrics.parser_output = format!("LogMeta::decode_metadata() failed on: {}", line); // For debugging
+ // debug_log!(&self.parser_output.clone());
+
+ if let Some(entry_metadata) = LogEntry::decode_metadata(line) {
+ if let Some(after_time) = after_time {
+ if !entry_metadata.message_time.gt(&after_time) {
+ return Ok(());
+ }
+ }
+
+ self.metrics.entry_metadata = Some(entry_metadata);
+ } else {
+ // debug_log!("gather_metrics() - skipping bec. metadata missing");
+ if after_time.is_some() {
+ return Ok(());
+ }
+ }
+
+ self._append_to_content(line)?; // Show in TUI
+ if self.is_debug_dashboard_log {
+ return Ok(());
+ }
+
+ self.metrics.gather_metrics(&line)?;
+
+ Ok(())
+ }
+
+ pub fn _append_to_content(&mut self, text: &str) -> Result<(), std::io::Error> {
+ self.content.items.push(text.to_string());
+ let len = self.content.items.len();
+ if len > self.max_content {
+ self.content.items = self.content.items.split_off(len - self.max_content);
+ } else {
+ self.content.state.select(Some(len - 1));
+ }
+ Ok(())
+ }
+}
+
+use regex::Regex;
+pub static LOG_LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
+ Regex::new(
+ r"\[(?P<time_string>[^ ]{27}) (?P<category>[A-Z]{4,6}) (?P<source>[^\]]*)\] (?P<message>.*)",
+ )
+ .expect("The regex failed to compile. This is a bug.")
+});
+
+#[derive(PartialEq, Clone, Default, Debug, Serialize, Deserialize)]
+pub enum NodeStatus {
+ Started,
+ Connected,
+ #[default]
+ Stopped,
+ Shunned,
+}
+
+pub fn node_status_as_string(node_status: &NodeStatus) -> String {
+ match node_status {
+ NodeStatus::Connected => "Connected".to_string(),
+ NodeStatus::Stopped => "Stopped".to_string(),
+ NodeStatus::Started => "Started".to_string(),
+ NodeStatus::Shunned => "SHUNNED".to_string(),
+ }
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct MmmStat {
+ sample_count: u64,
+
+ pub most_recent: u64,
+ pub total: u64,
+ pub min: u64,
+ pub mean: u64,
+ pub max: u64,
+}
+
+impl MmmStat {
+ pub fn new() -> MmmStat {
+ MmmStat {
+ sample_count: 0,
+ most_recent: 0,
+ total: 0,
+ min: u64::MAX,
+ mean: 0,
+ max: 0,
+ }
+ }
+
+ pub fn add_sample(&mut self, value: u64) {
+ self.most_recent = value;
+ self.sample_count += 1;
+ self.total += value;
+ self.mean = self.total / self.sample_count;
+
+ if self.min > value || self.min == u64::MAX {
+ self.min = value;
+ }
+ if self.max < value {
+ self.max = value;
+ }
+ }
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct NodeMetrics {
+ pub node_started: Option<DateTime<Utc>>,
+ pub running_message: Option<String>,
+ pub running_version: Option<String>,
+ pub node_process_id: Option<u64>,
+ pub node_peer_id: Option<String>,
+ pub category_count: HashMap<String, usize>,
+
+ pub app_timelines: AppTimelines,
+
+ pub entry_metadata: Option<LogMeta>,
+ pub node_status: NodeStatus,
+ pub node_bad_behaviour: String,
+ pub node_status_string: String,
+ pub node_inactive: bool,
+
+ pub activity_gets: MmmStat,
+ pub activity_puts: MmmStat,
+ pub activity_errors: MmmStat,
+ pub attos_earned: MmmStat,
+ pub storage_cost: MmmStat,
+ pub peers_connected: MmmStat,
+ pub memory_used_mb: MmmStat,
+
+ pub wallet_balance: u64,
+ pub latest_earning: u64,
+
+ pub records_stored: u64,
+ pub records_max: u64,
+
+ pub shun_notifications: u64,
+
+ pub system_cpu: f32,
+ pub system_memory: f32,
+ pub system_memory_used_mb: f32,
+ pub system_memory_usage_percent: f32,
+
+ pub interface_name: String,
+ pub bytes_received: u64,
+ pub bytes_transmitted: u64,
+ pub total_mb_received: f32,
+ pub total_mb_transmitted: f32,
+
+ pub cpu_usage_percent: f32,
+ pub cpu_usage_percent_max: f32,
+ pub bytes_read: u64,
+ pub bytes_written: u64,
+ pub total_mb_read: f32,
+ pub total_mb_written: f32,
+
+ pub parser_output: String,
+}
+
+impl NodeMetrics {
+ pub fn new() -> NodeMetrics {
+ let mut metrics = NodeMetrics {
+ // Start
+ node_started: None,
+ running_message: None,
+ running_version: None,
+ node_process_id: None,
+ node_peer_id: None,
+
+ // Logfile entries
+ entry_metadata: None,
+
+ // A predefined set of Timelines (Sparklines)
+ app_timelines: AppTimelines::new(),
+
+ // Counts
+ category_count: HashMap::new(),
+ activity_gets: MmmStat::new(),
+ activity_puts: MmmStat::new(),
+ activity_errors: MmmStat::new(),
+
+ // Storage Payments
+ attos_earned: MmmStat::new(),
+ storage_cost: MmmStat::new(),
+ peers_connected: MmmStat::new(),
+
+ // State (node)
+ node_status: NodeStatus::Stopped,
+ node_bad_behaviour: String::from(""),
+ node_status_string: String::from(""),
+ node_inactive: false,
+
+ // State (network)
+
+ // Wallet event:
+ wallet_balance: 0,
+ latest_earning: 0,
+
+ // Storage use:
+ records_stored: 0,
+ records_max: 0,
+
+ shun_notifications: 0,
+
+ system_cpu: 0.0,
+ system_memory: 0.0,
+ system_memory_used_mb: 0.0,
+ system_memory_usage_percent: 0.0,
+
+ interface_name: String::from("unknown"),
+ bytes_received: 0,
+ bytes_transmitted: 0,
+ total_mb_received: 0.0,
+ total_mb_transmitted: 0.0,
+
+ memory_used_mb: MmmStat::new(),
+ cpu_usage_percent: 0.0,
+ cpu_usage_percent_max: 0.0,
+ bytes_read: 0,
+ bytes_written: 0,
+ total_mb_read: 0.0,
+ total_mb_written: 0.0,
+
+ // Debug
+ parser_output: String::from("-"),
+ };
+ metrics.update_timelines(&Utc::now());
+ metrics
+ }
+
+ pub fn is_node_active(&self) -> bool {
+ return !self.node_inactive;
+ }
+
+ pub fn update_node_status_string(&mut self) {
+ let node_inactive_timeout = Duration::seconds(NODE_INACTIVITY_TIMEOUT_S);
+
+ let mut node_status_string = node_status_as_string(&self.node_status);
+
+ if self.node_status == NodeStatus::Shunned {
+ node_status_string = format!(
+ "Shunned x{} ({})",
+ self.shun_notifications, self.node_bad_behaviour
+ );
+ } else if let Some(metadata) = &self.entry_metadata {
+ let idle_time = Utc::now() - metadata.system_time;
+ if idle_time > node_inactive_timeout {
+ self.node_inactive = true;
+ node_status_string = format!("INACTIVE ({})", get_duration_text(idle_time));
+ } else {
+ self.node_inactive = false;
+ }
+ }
+
+ self.node_status_string = node_status_string;
+ }
+
+ fn reset_metrics(&mut self) {
+ self.node_status = NodeStatus::Started;
+ self.activity_gets = MmmStat::new();
+ self.activity_puts = MmmStat::new();
+ self.activity_errors = MmmStat::new();
+ self.storage_cost = MmmStat::new();
+ self.peers_connected = MmmStat::new();
+ self.memory_used_mb = MmmStat::new();
+ }
+
+ ///! Process a line from a Node logfile.
+ ///! Use a created LogMeta to update metrics.
+ pub fn gather_metrics(&mut self, line: &str) -> Result<(), std::io::Error> {
+ let entry = LogEntry {
+ logstring: String::from(line),
+ };
+ let entry_metadata = self.entry_metadata.as_ref().unwrap().clone();
+ let entry_time = entry_metadata.message_time;
+
+ debug_log!(format!("gather_metrics() entry_time: {:?}", entry_time).as_str());
+
+ self.update_timelines(&entry_time);
+ self.parser_output = entry_metadata.parser_output.clone();
+ self.process_logfile_entry(&entry.logstring, &entry_metadata); // May overwrite self.parser_output
+
+ // --debug-dashboard - prints parser results for a single logfile
+ // to a temp logfile which is displayed in the adjacent window.
+ debug_log!(&self.parser_output.clone());
+
+ Ok(())
+ }
+
+ pub fn update_timelines(&mut self, now: &DateTime<Utc>) {
+ self.app_timelines.update_timelines(now);
+ }
+
+ ///! Return a LogMeta and capture metadata for logfile node start:
+ ///! 'Running safenode v0.98.32'
+ pub fn parse_start(&mut self, line: &String, entry_metadata: &LogMeta) -> bool {
+ let running_prefix = String::from("Running safenode ");
+
+ if line.starts_with(&running_prefix) {
+ self.set_node_status(NodeStatus::Started);
+ let message = line.to_string();
+ let version = String::from(line[running_prefix.len()..].to_string());
+ self.node_started = Some(entry_metadata.message_time);
+ self.parser_output = format!(
+ "START node {} at {}",
+ String::from(version.clone()),
+ self
+ .node_started
+ .map_or(String::from("None"), |m| format!("{}", m))
+ );
+
+ self.running_message = Some(message);
+ self.running_version = Some(version);
+ self.reset_metrics();
+ return true;
+ }
+
+ let process_id_prefix = "Node (PID: ";
+ if line.contains(&process_id_prefix) {
+ self.node_process_id = self.parse_u64(process_id_prefix, line);
+ let process_id = match &self.node_process_id {
+ Some(process_id) => process_id.to_string(),
+ None => String::from("unknown"),
+ };
+
+ if let Some(peer_id) = self.parse_string("PeerId: ", line) {
+ self.parser_output = format!(
+ "Node pid: {} peer_id: {}",
+ String::from(process_id.clone()),
+ peer_id
+ );
+ self.node_peer_id = Some(peer_id);
+ }
+ return true;
+ }
+
+ false
+ }
+
+ ///! Process a logfile entry
+ ///! Returns true if node is being shunned, or the line has been processed and can be discarded
+ pub fn process_logfile_entry(&mut self, line: &String, entry_metadata: &LogMeta) -> bool {
+ return self.parse_timed_data(&line, &entry_metadata.message_time)
+ || self.parse_states(&line, &entry_metadata)
+ || self.parse_start(&line, &entry_metadata);
+ }
+
+ fn parse_timed_data(&mut self, line: &String, entry_time: &DateTime<Utc>) -> bool {
+ if line.contains("Retrieved record from disk") {
+ self.count_get(&entry_time);
+ self.set_node_status(NodeStatus::Connected);
+ return true;
+ } else if line.contains("Wrote record") || line.contains("ValidSpendRecordPutFromNetwork") {
+ self.count_put(&entry_time);
+ self.set_node_status(NodeStatus::Connected);
+ return true;
+ } else if line.contains("Editing Register success") {
+ // TODO: no longer present, find new log message
+ self.count_put(&entry_time);
+ self.set_node_status(NodeStatus::Connected);
+ return true;
+ } else if line.contains("Cost is now") {
+ if let Some(storage_cost) = self.parse_u64("Cost is now ", line) {
+ // Ignore storage cost of zero as that means the record is already paid for
+ if storage_cost > 0 {
+ self.count_storage_cost(entry_time, storage_cost);
+ self.parser_output = format!("Storage cost: {}", storage_cost);
+ }
+ };
+ return false; // Continue processing for records stored (parse_states())
+ } else if line.contains("Total payment of") {
+ if let Some(attos_earned) = self.parse_u64("Total payment of", line) {
+ self.count_attos_earned(entry_time, attos_earned);
+ self.parser_output = format!("Payment received: {}", attos_earned);
+ return true;
+ };
+ } else if line.contains("PeersInRoutingTable") {
+ let mut parser_output = String::from("connected peers:");
+ if let Some(peers_connected) = self.parse_u64("PeersInRoutingTable(", line) {
+ self.count_peers_connected(entry_time, peers_connected);
+ parser_output = format!("{} {}", &parser_output, peers_connected);
+ };
+ self.parser_output = parser_output;
+ return true;
+ } else if line.contains("consider us as BAD") {
+ let mut parser_output = String::from("Node being SHUNNED");
+ self.set_node_status(NodeStatus::Shunned);
+ self.shun_notifications = self.shun_notifications + 1;
+ if let Some(bad_behaviour) = self.parse_string("due to \"", line) {
+ self.node_bad_behaviour = bad_behaviour.clone();
+ parser_output = format!("Shunned due to '{}'", bad_behaviour);
+ };
+ self.parser_output = parser_output;
+ return true;
+ }
+ return false;
+ }
+
+ // Set status unless currently shunned
+ fn set_node_status(&mut self, new_status: NodeStatus) {
+ if self.node_status != NodeStatus::Shunned {
+ self.node_status = new_status;
+ }
+ }
+
+ ///! Update data metrics from a handler response logfile entry
+ ///! Returns true if the line has been processed and can be discarded
+ fn parse_string(&mut self, prefix: &str, line: &String) -> Option<String> {
+ let mut string = "";
+ if let Some(mut string_start) = line.find(prefix) {
+ string_start += prefix.len();
+
+ if let Some(string_end) = line[string_start..].find("\"") {
+ string = line.as_str()[string_start..string_start + string_end].as_ref()
+ } else {
+ string = line.as_str()[string_start..].as_ref()
+ }
+ if string.is_empty() {
+ self.parser_output = format!("failed to parse string after {} in: {}", prefix, line);
+ }
+ };
+
+ if string.len() > 0 {
+ Some(String::from(string))
+ } else {
+ None
+ }
+ }
+
+ ///! Capture state updates from a logfile entry
+ ///! Returns true if the line has been processed and can be discarded
+ fn parse_states(&mut self, line: &String, entry_metadata: &LogMeta) -> bool {
+ if entry_metadata.category.eq("ERROR") {
+ self.count_error(&entry_metadata.message_time);
+ }
+
+ let &content = &line.as_str();
+
+ // Node Status
+ if content.contains("Node events channel closed") {
+ self.set_node_status(NodeStatus::Stopped);
+ self.parser_output = String::from("Node status: Disconnected");
+ return true;
+ }
+
+ if content.contains("Created payment quote for") {
+ if let Some(records_stored) = self.parse_u64("records_stored: ", line) {
+ self.records_stored = records_stored;
+ self.parser_output = format!("Records stored: {}", records_stored);
+ };
+ if let Some(records_max) = self.parse_u64("max_records: ", line) {
+ self.records_max = records_max;
+ self.parser_output = format!("{}, Max records: {}", self.parser_output, records_max);
+ };
+ return true;
+ }
+
+ // if content.contains("Skipping ") {
+ // let mut parser_output = String::from("Connected ({} lag)");
+ // if let Some(events_skipped) = self.parse_usize("Skipping ", content) {
+ // parser_output = format!("{} ({})", &parser_output, events_skipped);
+ // };
+ // self.parser_output = parser_output;
+ // return true;
+ // }
+
+ // Metrics
+ if content.contains("ant_logging::metrics") {
+ // System
+ let mut parser_output = String::from("system_cpu_usage_percent:");
+ if let Some(system_cpu) = self.parse_float32("system_cpu_usage_percent\":", content) {
+ self.system_cpu = system_cpu;
+ parser_output = format!("{} gl_cpu: {}", &parser_output, system_cpu);
+ };
+ if let Some(system_memory) = self.parse_float32("system_total_memory_mb\":", content) {
+ self.system_memory = system_memory;
+ parser_output = format!("{} , System Memory: {}", &parser_output, system_memory);
+ };
+ if let Some(system_memory_used_mb) = self.parse_float32("system_memory_used_mb\":", content) {
+ self.system_memory_used_mb = system_memory_used_mb;
+ parser_output = format!(
+ "{} , System Memory Use (MB): {}",
+ &parser_output, system_memory_used_mb
+ );
+ };
+ if let Some(system_memory_usage_percent) =
+ self.parse_float32("system_memory_usage_percent\":", content)
+ {
+ self.system_memory_usage_percent = system_memory_usage_percent;
+ parser_output = format!(
+ "{} , System Memory Use (%): {}",
+ &parser_output, system_memory_usage_percent
+ );
+ };
+
+ // Networking
+ if let Some(interface_name) = self.parse_word("interface_name\":", content) {
+ self.interface_name = String::from(interface_name.clone());
+ parser_output = format!("{} , interface_name: {}", &parser_output, interface_name);
+ };
+ if let Some(bytes_received) = self.parse_u64("bytes_received\":", content) {
+ self.bytes_received = bytes_received;
+ parser_output = format!("{} , bytes_received: {}", &parser_output, bytes_received);
+ };
+ if let Some(bytes_transmitted) = self.parse_u64("bytes_transmitted\":", content) {
+ self.bytes_transmitted = bytes_transmitted;
+ parser_output = format!(
+ "{} , bytes_transmitted: {}",
+ &parser_output, bytes_transmitted
+ );
+ };
+ if let Some(total_mb_received) = self.parse_float32("total_mb_received\":", content) {
+ self.total_mb_received = total_mb_received;
+ parser_output = format!(
+ "{} , total_mb_received: {}",
+ &parser_output, total_mb_received
+ );
+ };
+ if let Some(total_mb_transmitted) = self.parse_float32("total_mb_transmitted\":", content) {
+ self.total_mb_transmitted = total_mb_transmitted;
+ parser_output = format!(
+ "{} , total_mb_transmitted: {}",
+ &parser_output, total_mb_transmitted
+ );
+ };
+
+ // Node Resources
+ if let Some(cpu_usage_percent) = self.parse_float32("\"cpu_usage_percent\":", content) {
+ self.cpu_usage_percent = cpu_usage_percent;
+ if cpu_usage_percent > self.cpu_usage_percent_max {
+ self.cpu_usage_percent_max = cpu_usage_percent;
+ }
+ parser_output = format!(
+ "{} cpu: {}, cpu_max {}",
+ &parser_output, cpu_usage_percent, self.cpu_usage_percent_max
+ );
+ };
+ if let Some(memory_used_mb) = self.parse_float32("\"memory_used_mb\":", content) {
+ self.count_memory_used_mb(&entry_metadata.message_time, memory_used_mb as u64);
+ parser_output = format!("{} , memory: {}", &parser_output, memory_used_mb);
+ };
+ if let Some(bytes_read) = self.parse_u64("bytes_read\":", content) {
+ self.bytes_read = bytes_read;
+ parser_output = format!("{} , bytes_read: {}", &parser_output, bytes_read);
+ };
+ if let Some(bytes_written) = self.parse_u64("bytes_written\":", content) {
+ self.bytes_written = bytes_written;
+ parser_output = format!("{} , bytes_written: {}", &parser_output, bytes_written);
+ };
+ if let Some(total_mb_read) = self.parse_float32("total_mb_read\":", content) {
+ self.total_mb_read = total_mb_read;
+ parser_output = format!("{} , total_mb_read: {}", &parser_output, total_mb_read);
+ };
+ if let Some(total_mb_written) = self.parse_float32("total_mb_written\":", content) {
+ self.total_mb_written = total_mb_written;
+ parser_output = format!(
+ "{} , total_mb_written: {}",
+ &parser_output, total_mb_written
+ );
+ };
+
+ self.parser_output = parser_output;
+ return true;
+ }
+
+ // Misc stats
+ if content.contains("The new wallet balance is") {
+ let mut parser_output = String::from("");
+
+ if let Some(wallet_balance) = self.parse_u64("wallet balance is ", content) {
+ self.wallet_balance = wallet_balance;
+ parser_output = format!("{} , wallet_balance: {}", &parser_output, wallet_balance);
+ };
+ if let Some(latest_earning) = self.parse_u64("after earning ", content) {
+ self.latest_earning = latest_earning;
+ parser_output = format!("{} , latest_earning: {}", &parser_output, latest_earning);
+ };
+ self.parser_output = parser_output;
+ return true;
+ }
+ false
+ }
+
+ // fn parse_usize(&mut self, prefix: &str, content: &str) -> Option<usize> {
+ // if let Some(position) = content.find(prefix) {
+ // let word: Vec<&str> = content[position + prefix.len()..]
+ // .trim()
+ // .splitn(2, |c| c == ' ' || c == ',' || c== '}')
+ // .collect();
+ // if word.len() > 0 {
+ // match word[0].parse::<usize>() {
+ // Ok(value) => return Some(value),
+ // Err(_e) => self.parser_output = format!("failed to parse '{}' as usize from: '{}'", word[0], &content[position + prefix.len()..]),
+ // }
+ // }
+ // }
+ // None
+ // }
+
+ fn parse_u64(&mut self, prefix: &str, content: &str) -> Option<u64> {
+ if let Some(position) = content.find(prefix) {
+ let word: Vec<&str> = content[position + prefix.len()..]
+ .trim()
+ .splitn(2, |c| c == ' ' || c == ',' || c == '}' || c == ')')
+ .collect();
+ if word.len() > 0 {
+ match word[0].parse::<u64>() {
+ Ok(value) => return Some(value),
+ Err(_e) => {
+ self.parser_output = format!(
+ "failed to parse '{}' as u64 from: '{}'",
+ word[0],
+ &content[position + prefix.len()..]
+ )
+ }
+ }
+ }
+ }
+ None
+ }
+
+ fn parse_float32(&mut self, prefix: &str, content: &str) -> Option<f32> {
+ if let Some(position) = content.find(prefix) {
+ let word: Vec<&str> = content[position + prefix.len()..]
+ .trim()
+ .splitn(2, |c| c == ' ' || c == ',' || c == '}')
+ .collect();
+ if word.len() > 0 {
+ match word[0].parse::<f32>() {
+ Ok(value) => return Some(value),
+ Err(_e) => {
+ self.parser_output = format!(
+ "failed to parse '{}' as float from: '{}'",
+ word[0],
+ &content[position + prefix.len()..]
+ )
+ }
+ }
+ }
+ }
+ None
+ }
+
+ fn parse_word(&mut self, prefix: &str, content: &str) -> Option<String> {
+ if let Some(start) = content.find(prefix) {
+ let word: Vec<&str> = content[start + prefix.len()..]
+ .trim_start()
+ .splitn(2, |c| c == ' ' || c == ',' || c == '}')
+ .collect();
+ if word.len() > 0 {
+ return Some(word[0].to_string());
+ } else {
+ self.parser_output = format!("failed to parse word at: '{}'", &content[start..]);
+ }
+ }
+ None
+ }
+
+ fn count_get(&mut self, time: &DateTime<Utc>) {
+ self.activity_gets.add_sample(1);
+ self.apply_timeline_sample(GETS_TIMELINE_KEY, time, 1);
+ }
+
+ fn count_put(&mut self, time: &DateTime<Utc>) {
+ self.activity_puts.add_sample(1);
+ self.apply_timeline_sample(PUTS_TIMELINE_KEY, time, 1);
+ }
+
+ fn count_error(&mut self, time: &DateTime<Utc>) {
+ self.activity_errors.add_sample(1);
+ self.apply_timeline_sample(ERRORS_TIMELINE_KEY, time, 1);
+ }
+
+ fn count_attos_earned(&mut self, time: &DateTime<Utc>, attos_earned: u64) {
+ self.attos_earned.add_sample(attos_earned);
+ self.apply_timeline_sample(EARNINGS_TIMELINE_KEY, time, attos_earned);
+ }
+
+ fn count_storage_cost(&mut self, time: &DateTime<Utc>, storage_cost: u64) {
+ self.storage_cost.add_sample(storage_cost);
+ self.apply_timeline_sample(STORAGE_COST_TIMELINE_KEY, time, storage_cost);
+ }
+
+ fn count_peers_connected(&mut self, time: &DateTime<Utc>, connections: u64) {
+ self.peers_connected.add_sample(connections);
+ self.apply_timeline_sample(CONNECTIONS_TIMELINE_KEY, time, connections);
+ }
+
+ fn count_memory_used_mb(&mut self, time: &DateTime<Utc>, memory_used_mb: u64) {
+ self.memory_used_mb.add_sample(memory_used_mb);
+ self.apply_timeline_sample(RAM_TIMELINE_KEY, time, memory_used_mb);
+ }
+
+ fn apply_timeline_sample(&mut self, timeline_key: &str, time: &DateTime<Utc>, value: u64) {
+ if let Some(timeline) = self.app_timelines.get_timeline_by_key(timeline_key) {
+ timeline.update_value(time, value);
+ }
+ }
+}
+
+///! Metadata for a logfile line
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct LogMeta {
+ pub category: String, // First word ('INFO', 'WARN' etc.)
+ pub message_time: DateTime<Utc>,
+ pub system_time: DateTime<Utc>,
+ pub source: String,
+ pub message: String,
+
+ pub parser_output: String,
+}
+
+impl LogMeta {
+ pub fn clone(&self) -> LogMeta {
+ LogMeta {
+ category: self.category.clone(),
+ message_time: self.message_time,
+ system_time: self.system_time,
+ source: self.source.clone(),
+ message: self.message.clone(),
+ parser_output: self.parser_output.clone(),
+ }
+ }
+}
+
+///! Used to build a history of what is in the log, one LogMeta per line
+pub struct LogEntry {
+ pub logstring: String, // One line of raw text from the logfile
+}
+
+impl LogEntry {
+ ///! Decode metadata from logfile line when present. Example input lines:
+ ///! " INFO 2022-01-15T20:21:02.659471Z [sn/src/node/routing/core/mod.rs:L211]:"
+ ///! " ➤ Writing our latest PrefixMap to disk"
+ ///! " ERROR 2022-01-15T20:21:07.643598Z [sn/src/node/routing/api/dispatcher.rs:L450]:"
+ fn decode_metadata(line: &str) -> Option<LogMeta> {
+ if line.is_empty() {
+ return None;
+ }
+
+ if let Some(captures) = LOG_LINE_PATTERN.captures(line) {
+ let category = captures.name("category").map_or("", |m| m.as_str());
+ let time_string = captures.name("time_string").map_or("", |m| m.as_str());
+ let source = captures.name("source").map_or("", |m| m.as_str());
+ let message = captures.name("message").map_or("", |m| m.as_str());
+ let time_str: String;
+
+ let time_utc: DateTime<Utc>;
+
+ match DateTime::parse_from_str(time_string, "%+") {
+ Ok(time) => {
+ time_utc = time.with_timezone(&Utc);
+ time_str = format!("{}", time);
+ }
+ Err(e) => {
+ debug_log!(format!("ERROR parsing logfile time: {}", e).as_str());
+ return None;
+ }
+ };
+ let parser_output = format!(
+ "c: {}, t: {}, s: {}, m: {}",
+ category, time_str, source, message
+ );
+
+ return Some(LogMeta {
+ category: String::from(category),
+ message_time: time_utc,
+ system_time: Utc::now(),
+ source: String::from(source),
+ message: String::from(message),
+ parser_output,
+ });
+ }
+ None
+ }
+}
+
+///! Active UI at top level
+#[derive(PartialEq, Clone, Copy)]
+pub enum DashViewMain {
+ DashSummary,
+ DashNode,
+ DashHelp,
+ DashDebug,
+}
+
+pub struct DashState {
+ pub vdash_status: StatusMessage,
+ pub main_view: DashViewMain,
+ pub previous_main_view: DashViewMain,
+ pub logfile_names_sorted: Vec<String>,
+ pub logfile_names_sorted_ascending: bool,
+
+ pub currency_symbol: String,
+ pub currency_per_token: Option<f64>,
+ pub ui_uses_currency: bool,
+
+ pub active_timescale: usize,
+ pub node_logfile_visible: bool,
+ pub dash_node_focus: String,
+ pub mmm_ui_mode: MinMeanMax,
+ pub top_timeline: usize, // Timeline to show at top of UI
+
+ pub summary_window_heading: String, // TODO delete in favour of...
+ pub summary_window_headings: StatefulList<String>,
+ pub summary_window_heading_selected: usize,
+ pub summary_window_rows: StatefulList<String>,
+ max_summary_window: usize,
+
+ pub help_status: StatefulList<String>,
+
+ // For --debug-window option
+ pub debug_window_list: StatefulList<String>,
+ pub debug_window: bool,
+ pub debug_window_has_focus: bool,
+ max_debug_window: usize,
+}
+
+const UI_STATUS_DEFAULT_MESSAGE: &str = "Press '?' for Help";
+const UI_STATUS_DEFAULT_DURATION_S: i64 = 5;
+use super::ui_status::StatusMessage;
+
+impl DashState {
+ pub fn new() -> DashState {
+ let mut new_dash = DashState {
+ vdash_status: StatusMessage::new(
+ &String::from(UI_STATUS_DEFAULT_MESSAGE),
+ &Duration::seconds(UI_STATUS_DEFAULT_DURATION_S),
+ ),
+
+ main_view: DashViewMain::DashSummary,
+ previous_main_view: DashViewMain::DashSummary,
+ logfile_names_sorted: Vec::<String>::new(), // Sorted by column
+ logfile_names_sorted_ascending: true,
+
+ currency_symbol: String::from(""),
+ currency_per_token: None,
+ ui_uses_currency: false,
+
+ active_timescale: 0,
+ node_logfile_visible: true,
+ dash_node_focus: String::new(),
+ mmm_ui_mode: MinMeanMax::Mean,
+ top_timeline: 0,
+
+ summary_window_heading: String::from(""),
+ summary_window_headings: StatefulList::new(),
+ summary_window_heading_selected: 0,
+ summary_window_rows: StatefulList::new(),
+ max_summary_window: 1000,
+
+ help_status: StatefulList::with_items(vec![]),
+
+ debug_window: false,
+ debug_window_has_focus: false,
+ debug_window_list: StatefulList::new(),
+ max_debug_window: 100,
+ };
+ super::ui_summary_table::initialise_summary_headings(&mut new_dash);
+ new_dash
+ }
+
+ pub fn _debug_window(&mut self, text: &str) {
+ self.debug_window_list.items.push(text.to_string());
+ let len = self.debug_window_list.items.len();
+
+ if len > self.max_debug_window {
+ self.debug_window_list.items = self
+ .debug_window_list
+ .items
+ .split_off(len - self.max_debug_window);
+ } else {
+ self.debug_window_list.state.select(Some(len - 1));
+ }
+ }
+
+ pub fn get_active_timescale_name(&self) -> Option<&'static str> {
+ return match TIMESCALES.get(self.active_timescale) {
+ None => {
+ // debug_log!("ERROR getting active timescale name");
+ return None;
+ }
+ Some((name, _)) => Some(name),
+ };
+ }
+
+ // Rotate UI display state through Min, Mean, Max values
+ pub fn bump_mmm_ui_mode(&mut self) {
+ match &self.mmm_ui_mode {
+ MinMeanMax::Min => self.mmm_ui_mode = MinMeanMax::Mean,
+ MinMeanMax::Mean => self.mmm_ui_mode = MinMeanMax::Max,
+ MinMeanMax::Max => self.mmm_ui_mode = MinMeanMax::Min,
+ }
+ }
+
+ pub fn top_timeline_index(&self) -> usize {
+ return self.top_timeline;
+ }
+ pub fn mmm_ui_mode(&self) -> &MinMeanMax {
+ &self.mmm_ui_mode
+ }
+}
+
+pub struct DashVertical {
+ _active_view: usize,
+}
+
+impl DashVertical {
+ pub fn new() -> Self {
+ DashVertical { _active_view: 0 }
+ }
+}
+
+pub fn set_main_view(view: DashViewMain, app: &mut App) {
+ if app.dash_state.main_view == view {
+ return;
+ }
+
+ app.dash_state.previous_main_view = app.dash_state.main_view;
+ save_focus(app);
+ app.dash_state.main_view = view;
+ restore_focus(app);
+}
+
+pub fn save_focus(app: &mut App) {
+ match app.dash_state.main_view {
+ DashViewMain::DashHelp => {}
+
+ DashViewMain::DashSummary | DashViewMain::DashNode => {
+ if let Some(focus) = app.get_logfile_with_focus() {
+ app.dash_state.dash_node_focus = focus;
+ }
+ }
+ DashViewMain::DashDebug => {}
+ }
+}
+
+pub fn restore_focus(app: &mut App) {
+ match app.dash_state.main_view {
+ DashViewMain::DashHelp => {}
+
+ DashViewMain::DashSummary | DashViewMain::DashNode => {
+ app.set_logfile_with_focus(app.dash_state.dash_node_focus.clone())
+ }
+ DashViewMain::DashDebug => {
+ if let Some(debug_logfile) = app.get_debug_dashboard_logfile() {
+ app.set_logfile_with_focus(debug_logfile);
+ }
+ }
+ }
+}
+#[cfg(test)]
+mod tests {
+
+ mod log_parsing {
+ use std::str::FromStr;
+
+ use chrono::{DateTime, Utc};
+
+ use crate::custom::app::LogEntry;
+
+ #[test]
+ fn it_parses() {
+ let message_time = "2024-03-23T19:38:32.350118Z";
+ let source = "sn_networking::event";
+ let category = "WARN";
+ let message = "MsgReceivedError: InternalMsgChannelDropped";
+ let line = format!("[{} {} {}] {}", message_time, category, source, message);
+ let metadata = LogEntry::decode_metadata(&line).unwrap();
+
+ let message_time: DateTime<Utc> = DateTime::from_str(message_time).unwrap();
+
+ assert_eq!(metadata.category, category);
+ assert_eq!(metadata.message_time, message_time);
+ assert_eq!(metadata.source, source);
+ assert_eq!(metadata.message, message);
+ }
+ }
+}
--- /dev/null
+use std::collections::HashMap;
+
+use chrono::{DateTime, Duration, Utc};
+use ratatui::style::Color;
+use serde::{Deserialize, Serialize};
+
+use super::app::OPT;
+use super::timelines::{Buckets, Timeline};
+use std::sync::LazyLock;
+
+pub static TIMESCALES: LazyLock<std::vec::Vec<(&'static str, Duration)>> = LazyLock::new(|| {
+ vec![
+ ("1 second columns", Duration::seconds(1)),
+ ("1 minute columns", Duration::minutes(1)),
+ ("1 hour columns", Duration::hours(1)),
+ ("1 day columns", Duration::days(1)),
+ ("1 week columns", Duration::days(7)),
+ ("1 year columns", Duration::days(365)),
+ ]
+});
+
+pub const EARNINGS_UNITS_TEXT: &str = "attos";
+pub const STORAGE_COST_UNITS_TEXT: &str = "attos/MB";
+
+/// keys (used to access timelines)
+pub const EARNINGS_TIMELINE_KEY: &str = "earnings";
+pub const STORAGE_COST_TIMELINE_KEY: &str = "storage";
+pub const PUTS_TIMELINE_KEY: &str = "puts";
+pub const GETS_TIMELINE_KEY: &str = "gets";
+pub const CONNECTIONS_TIMELINE_KEY: &str = "connections";
+pub const RAM_TIMELINE_KEY: &str = "ram";
+pub const ERRORS_TIMELINE_KEY: &str = "errors";
+
+/// Defines the Timelines available for display
+pub const APP_TIMELINES: [(&str, &str, &str, bool, bool, Color); 7] = [
+ // (key, UI name, units_text, is_mmm, is_cumulative, colour)
+ (
+ EARNINGS_TIMELINE_KEY,
+ "Earnings",
+ EARNINGS_UNITS_TEXT,
+ false,
+ true,
+ Color::LightCyan,
+ ),
+ (
+ STORAGE_COST_TIMELINE_KEY,
+ "Storage Cost",
+ STORAGE_COST_UNITS_TEXT,
+ true,
+ false,
+ Color::LightBlue,
+ ),
+ (PUTS_TIMELINE_KEY, "PUTS", "", false, true, Color::Yellow),
+ (GETS_TIMELINE_KEY, "GETS", "", false, true, Color::Green),
+ (
+ CONNECTIONS_TIMELINE_KEY,
+ "Connections",
+ "",
+ true,
+ false,
+ Color::Blue,
+ ),
+ (RAM_TIMELINE_KEY, "RAM", "MB", true, false, Color::Magenta),
+ (ERRORS_TIMELINE_KEY, "ERRORS", "", false, true, Color::Red),
+];
+
+/// Holds the Timeline structs for a node, as used by this app
+#[derive(Clone, Default, Debug, Serialize, Deserialize)]
+pub struct AppTimelines {
+ timelines: HashMap<String, Timeline>,
+}
+
+impl AppTimelines {
+ pub fn new() -> AppTimelines {
+ let opt_timeline_steps = {
+ let opt = OPT.lock().unwrap();
+ opt.timeline_steps
+ };
+
+ let mut app_timelines = AppTimelines {
+ timelines: HashMap::<String, Timeline>::new(),
+ };
+
+ for (key, name, units_text, is_mmm, is_cumulative, colour) in APP_TIMELINES {
+ app_timelines.timelines.insert(
+ key.to_string(),
+ Timeline::new(
+ name.to_string(),
+ units_text.to_string(),
+ is_mmm,
+ is_cumulative,
+ colour,
+ ),
+ );
+ }
+
+ for (_, timeline) in app_timelines.timelines.iter_mut() {
+ for i in 0..TIMESCALES.len() {
+ if let Some(spec) = TIMESCALES.get(i) {
+ timeline.add_bucket_set(spec.0, spec.1, opt_timeline_steps);
+ }
+ }
+ }
+
+ return app_timelines;
+ }
+
+ pub fn update_timelines(&mut self, now: &DateTime<Utc>) {
+ for (_, timeline) in self.timelines.iter_mut() {
+ timeline.update_current_time(&now);
+ }
+ }
+
+ pub fn get_timeline_by_key(&mut self, key: &str) -> Option<&mut Timeline> {
+ return self.timelines.get_mut(key);
+ }
+
+ pub fn get_timeline_by_index(&self, index: usize) -> Option<&Timeline> {
+ let (key, _, _, _, _, _) = APP_TIMELINES[index];
+ return self.timelines.get(key);
+ }
+
+ // Gets the set of buckets for the index'th Timeline, selecting with Min, Mean, Max if appropriate
+ pub fn get_timeline_buckets(&mut self, index: usize, timescale_name: &str) -> Option<&Buckets> {
+ let (key, _, _, _, _, _) = APP_TIMELINES[index];
+ if let Some(timeline) = self.timelines.get_mut(key) {
+ return timeline.get_bucket_set(timescale_name);
+ }
+ return None;
+ }
+
+ pub fn get_num_timelines(self: &AppTimelines) -> usize {
+ return APP_TIMELINES.len();
+ }
+}
--- /dev/null
+
+use std::fs::{self};
+use std::io::{Error, ErrorKind};
+use std::path::PathBuf;
+
+use serde::{Serialize, Deserialize};
+use serde_json;
+use chrono::{DateTime, Utc};
+
+use super::app::{LogMonitor, NodeMetrics};
+
+const CHECKPOINT_EXT: &str = "vdash";
+const CHECKPOINT_TMP_EXT: &str = "vdash-tmp";
+
+pub fn save_checkpoint(monitor: &mut LogMonitor) -> Result<String, Error> {
+ let mut checkpoint_tmp_path = PathBuf::from(&monitor.logfile);
+ if !checkpoint_tmp_path.set_extension(CHECKPOINT_TMP_EXT) {
+ return Err(Error::new(ErrorKind::Other, "checkpoint set_extension() failed"));
+ }
+
+ let last_entry_time = if let Some(metadata) = &monitor.metrics.entry_metadata {
+ Some(metadata.message_time)
+ } else {
+ None
+ };
+
+ let mut checkpoint = LogfileCheckpoint::new();
+ monitor.to_checkpoint(&mut checkpoint);
+ checkpoint.latest_entry_time = last_entry_time;
+
+ let checkpoint_string = serde_json::to_string(&checkpoint).unwrap();
+ match fs::write(checkpoint_tmp_path.clone(), checkpoint_string) {
+ Ok(_) => {
+ let mut checkpoint_path = PathBuf::from(&monitor.logfile);
+ if checkpoint_path.set_extension(CHECKPOINT_EXT) && fs::rename(checkpoint_tmp_path, checkpoint_path.clone()).is_ok() {
+ monitor.latest_checkpoint_time = last_entry_time;
+ return Ok("Checkpoint updated".to_string());
+ } else {
+ return Err(Error::new(ErrorKind::Other, format!("FAILED to rename checkpoint to '{:?}'", checkpoint_path.as_os_str()).as_str()));
+ }
+ },
+ Err(e) => return Err(e),
+ };
+}
+
+/// Look for and attempt to update metrics from a checkpoint
+/// Returns Ok() if the checkpoint was found and restored
+pub fn restore_checkpoint(monitor: &mut LogMonitor) -> Result<String, Error> {
+ let mut checkpoint_path = PathBuf::from(&monitor.logfile);
+ if !checkpoint_path.set_extension(CHECKPOINT_EXT) {
+ return Err(Error::new(ErrorKind::Other, "checkpoint set_extension() failed"));
+ }
+
+ let mut checkpoint = LogfileCheckpoint::new();
+ monitor.to_checkpoint(&mut checkpoint);
+
+ match fs::read_to_string(&checkpoint_path) {
+ Ok(checkpoint_string) => {
+ match serde_json::from_str(checkpoint_string.as_str()) {
+ Ok(checkpoint) => monitor.from_checkpoint(&checkpoint),
+
+ // TODO could be versioning issue (e.g. any change in serialized structs)
+ // TODO maybe report so user can delete invalid checkpoint file
+ Err(e) => return Err(Error::new(ErrorKind::Other, e.to_string())),
+ };
+ },
+ // Suppress console error message when checkpoint file is not found
+ Err(_e) => return Err(Error::new(ErrorKind::Other, "")), // No checkpoint file found
+ }
+
+ Ok(format!("checkpoint restored from: {:?}", checkpoint_path.as_os_str()))
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct LogfileCheckpoint {
+ pub latest_entry_time: Option<DateTime<Utc>>,
+ pub monitor_index: usize,
+ pub monitor_metrics: NodeMetrics,
+}
+
+impl LogfileCheckpoint {
+ pub fn new() -> LogfileCheckpoint {
+ LogfileCheckpoint {
+ latest_entry_time: None,
+ monitor_index: 0,
+ monitor_metrics: NodeMetrics::new(),
+ }
+ }
+}
--- /dev/null
+use linemux::MuxedLines;
+use std::collections::HashMap;
+use glob::glob;
+
+use crate::custom::app::{LogMonitor, DashState};
+
+pub struct LogfilesManager {
+ pub logfiles_added: Vec<String>,
+ pub globpaths: Vec<String>,
+
+ pub logfiles_monitored: Vec<String>, // Paths to all logfiles being monitored
+ pub logfiles_failed: Vec<String>, // Paths to any files which failed to begin monitoring
+
+ pub linemux_files: MuxedLines,
+}
+
+// TODO maybe add UI for display of lists (paths/globpaths/failed paths)
+// TODO maybe add UI for adding paths/globpaths interactively
+impl LogfilesManager {
+ pub fn new(globpaths: Vec<String>) -> LogfilesManager {
+ match MuxedLines::new() {
+ Ok(linemux) => return LogfilesManager {
+ logfiles_added: Vec::new(),
+ globpaths: globpaths,
+
+ logfiles_monitored: Vec::new(),
+ logfiles_failed: Vec::new(),
+
+ linemux_files: linemux,
+ },
+
+ Err(e) => panic!("Initialisation failed at MuxedLines::new(): {}", e)
+ }
+ }
+
+ pub async fn monitor_multi_paths(&mut self, filepaths: Vec<String>, monitors: &mut HashMap<String, LogMonitor>, dash_state: &mut DashState, disable_status: bool) {
+ if !disable_status { dash_state.vdash_status.message(&format!("Loading {} files...", filepaths.len()), None); }
+ for f in &filepaths {
+ self.monitor_path(&f.to_string(), monitors, dash_state, disable_status).await;
+ }
+ }
+
+ pub async fn scan_multi_globpaths(&mut self, globpaths: Vec<String>, monitors: &mut HashMap<String, LogMonitor>, dash_state: &mut DashState, disable_status: bool) {
+ if !disable_status { dash_state.vdash_status.message(&format!("Scanning {} globpaths...", globpaths.len()), None); }
+ for f in &globpaths {
+ self.scan_globpath(f.to_string(), monitors, dash_state, disable_status).await;
+ }
+ }
+
+ // Attempts to setup a LogMonitor for the logfile at fullpath
+ pub async fn monitor_path(&mut self, fullpath: &String, monitors: &mut HashMap<String, LogMonitor>, dash_state: &mut DashState, disable_status: bool) {
+ if self.logfiles_added.contains(&fullpath) {
+ return;
+ }
+
+ if !disable_status { dash_state.vdash_status.message(&format!("file: {}", &fullpath), None); }
+
+ let mut monitor = LogMonitor::new( fullpath.to_string());
+
+ let checkpoint_result = super::logfile_checkpoints::restore_checkpoint(&mut monitor);
+
+ let checkpoint_was_restored = match checkpoint_result {
+ Ok(message) => {
+ if message.len() > 0 {
+ if !disable_status { dash_state.vdash_status.message(&format!("{}", &message), None); }
+ };
+ true
+ },
+ Err(e) => {
+ let message = &e.to_string();
+ if message.len() > 0 && !disable_status { dash_state.vdash_status.message(&format!("{}", message), None); }
+ false // TODO note: do I need to handle version errors in some way? (due to change in serialised struct)
+ }
+ };
+
+ let result = if super::app::OPT.lock().unwrap().ignore_existing {
+ self.linemux_files.add_file(fullpath).await
+ } else {
+ if checkpoint_was_restored {
+ match monitor.load_logfile_from_time(dash_state, monitor.latest_checkpoint_time) {
+ Ok(_) => self.linemux_files.add_file(fullpath).await,
+ Err(e) => Err(e),
+ }
+ } else {
+ match monitor.load_logfile_from_time(dash_state, None) {
+ Ok(_) => self.linemux_files.add_file(fullpath).await,
+ Err(e) => Err(e),
+ }
+
+ // // This method is 25% slower or worse
+ // self.linemux_files.add_file_from_start(fullpath).await
+ }
+ };
+
+ match result {
+ Ok(_) => {
+ monitor.canonicalise_monitor_index(monitors);
+ monitors.insert(fullpath.to_string(), monitor);
+ if !self.logfiles_added.contains(&fullpath) { self.logfiles_added.push(fullpath.to_string()); }
+ if let Some(index) = self.logfiles_failed.iter().position(|s| s == fullpath.as_str()) {
+ self.logfiles_failed.remove(index);
+ }
+ }
+ Err(e) => {
+ if !self.logfiles_failed.contains(&fullpath) { self.logfiles_failed.push(fullpath.to_string()); }
+ eprintln!("...load failed: {}", e);
+ eprintln!( "Note: it is ok for the file not to exist, but the file's parent directory must exist." );
+ }
+ }
+ }
+
+ /// Scans (or re-scans) the globpath and attempts to setup LogMonitors for any files found
+ pub async fn scan_globpath(&mut self, globpath: String, monitors: &mut HashMap<String, LogMonitor>, dash_state: &mut DashState, disable_status: bool) {
+ if !disable_status { dash_state.vdash_status.message(&format!("globpath: {}", globpath), None); }
+
+ let paths_to_scan = globpath.clone();
+ if !self.globpaths.contains(&globpath) { self.globpaths.push(globpath) }
+
+ for entry in glob(paths_to_scan.as_str()).unwrap() {
+ match entry {
+ Ok(path) => {
+ if let Some(filepath) = path.to_str() {
+ self.monitor_path(&filepath.to_string(), monitors, dash_state, disable_status).await
+ }
+ },
+ Err(e) => eprintln!("...globpath failed: {}", e),
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+pub mod app;
+pub mod app_timelines;
+pub mod logfile_checkpoints;
+pub mod logfiles_manager;
+pub mod opt;
+pub mod timelines;
+pub mod web_requests;
+pub mod ui;
+pub mod ui_debug;
+pub mod ui_help;
+pub mod ui_keyboard;
+pub mod ui_node;
+pub mod ui_summary_table;
+pub mod ui_summary;
+pub mod ui_status;
--- /dev/null
+///! Command line options and usage
+
+pub static MIN_TIMELINE_STEPS: usize = 10;
+
+pub use structopt::StructOpt;
+
+#[derive(StructOpt, Debug)]
+#[structopt(
+ about = "Monitor Autonomi Network nodes in the terminal.\nNavigate using tab and arrow keys."
+)]
+pub struct Opt {
+ /// Maximum number of lines to display for each logfile
+ #[structopt(short = "l", long, default_value = "100")]
+ pub lines_max: usize,
+
+ /// Event update tick in milliseconds (controls screen refresh rate)
+ #[structopt(long, default_value = "200")]
+ pub tick_rate: u64,
+
+ /// Steps in each timeline for timeline graphs the Node Status display. Timeline 'width' = (steps * time units).
+ #[structopt(short, long, default_value = "210")]
+ pub timeline_steps: usize,
+
+ /// Ignore any existing logfile content
+ #[structopt(short, long)]
+ pub ignore_existing: bool,
+
+ /// A *nix 'glob' path to match multiple files.
+ /// Can be provided multiple times as here:
+ ///
+ /// vdash -g "$HOME/.local/share/safe/node/**/safenode.log" -g "./remote-node-logs/*/logs/safenode.log"
+ #[structopt(name = "glob-path", short, long, multiple = true)]
+ pub glob_paths: Vec<String>,
+
+ /// Enable periodic scan of any glob paths every so many seconds. 0 to disable.
+ #[structopt(long, default_value = "0")]
+ pub glob_scan: i64,
+
+ /// Set checkpoint interval in seconds (0 will disable checkpoints). vdash saves node statistics every few seconds so that it doesn't lose data when restarted.
+ #[structopt(long, default_value = "300")]
+ pub checkpoint_interval: u64,
+
+ /// Token conversion rate as a positive floating point number (e.g. 3.345)
+ /// This will be used if the price APIs are not used or failing.
+ #[structopt(long, default_value = "-1")]
+ pub currency_token_rate: f64,
+
+ /// Fiat currency name for API
+ #[structopt(long, default_value = "USD")]
+ pub currency_apiname: String,
+
+ /// Single character symbol for currency (e.g. "£" or "€")
+ #[structopt(long, default_value = "$")]
+ pub currency_symbol: String,
+
+ /// Coingecko.com API key
+ #[structopt(long)]
+ pub coingecko_key: Option<String>,
+
+ /// Coingecko.com API polling interval (minutes)
+ #[structopt(long, default_value = "30")]
+ pub coingecko_interval: usize,
+
+ /// Coinmarketcap.com API key
+ #[structopt(long)]
+ pub coinmarketcap_key: Option<String>,
+
+ /// Coinmarketcap.com API polling interval (minutes)
+ #[structopt(long, default_value = "30")]
+ pub coinmarketcap_interval: usize,
+
+ /// One or more logfiles to monitor
+ #[structopt(name = "LOGFILE")]
+ pub files: Vec<String>,
+
+ /// Parses first logfile *only* and adds a debug output window (accessed with l/r arrow)
+ /// Also shows smaller debug output window to the right of the node view for the logfile
+ #[structopt(short, long)]
+ pub debug_window: bool,
+}
+
+pub fn get_app_name() -> String {
+ String::from(Opt::clap().get_name())
+}
+pub fn get_app_version() -> String {
+ String::from(structopt::clap::crate_version!())
+}
--- /dev/null
+use chrono::{DateTime, Duration, Utc};
+use ratatui::style::Color;
+use std::collections::HashMap;
+
+use crate::custom::app::debug_log;
+
+pub fn get_duration_text(duration: Duration) -> String {
+ return if duration.num_weeks() > 104 {
+ format!("{} years", duration.num_days() / 365)
+ } else if duration.num_weeks() > 4 {
+ format!("{} weeks", duration.num_weeks())
+ } else if duration.num_hours() > 48 {
+ format!("{} days", duration.num_days())
+ } else if duration.num_hours() > 2 {
+ format!("{} hrs", duration.num_hours())
+ } else if duration.num_minutes() > 5 {
+ format!("{} min", duration.num_minutes())
+ } else {
+ format!("{} sec", duration.num_seconds())
+ };
+}
+
+pub fn get_max_buckets_value(buckets: &Vec<u64>) -> u64 {
+ let mut max: u64 = 0;
+ for i in 0..buckets.len() - 1 {
+ if buckets[i] > max {
+ max = buckets[i];
+ }
+ }
+ return max;
+}
+
+pub fn get_min_buckets_value(buckets: &Vec<u64>) -> u64 {
+ let mut min: u64 = u64::MAX;
+ for i in 0..buckets.len() - 1 {
+ if buckets[i] > 0 && buckets[i] < min {
+ min = buckets[i];
+ }
+ }
+ return min;
+}
+
+///! Maintains one or more 'marching bucket' histories for
+///! a given metric, each with its own duration and granularity.
+///!
+///! A Buckets is used to hold the history of values with
+///! a given bucket_duration and maximum number of buckets.
+///!
+///! A Buckets begins with a single bucket of fixed
+///! duration holding the initial metric value. New buckets
+///! are added as time progresses until the number of buckets
+///! covers the total duration of the Buckets. At this
+///! point the oldest bucket is removed when a new bucket is
+///! added, so that the total duration remains constant and
+///! the specified maximum number of buckets is never
+///! exceeded.
+///!
+///! By adding more than one Buckets, a given metric can be
+///! recorded for different durations and with different
+///! granularities. E.g. 60 * 1s buckets covers a minute
+///! and 60 * 1m buckets covers an hour, and so on.
+///!
+///! TimelineMMM and BucketsMMM are similar structs which
+///! implement timelines of min, mean and max values for
+///! a given metric.
+
+/// Specify min, mean, max series (as opposed to value series)
+#[derive(Default)]
+pub enum MinMeanMax {
+ #[default]
+ Min = 1,
+ Mean = 2,
+ Max = 3,
+}
+
+use serde::{Deserialize, Serialize};
+use serde_with;
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct Timeline {
+ pub name: String,
+ pub units_text: String,
+ pub is_mmm: bool,
+ pub is_cumulative: bool,
+ pub colour: Color,
+
+ pub last_non_zero_value: u64,
+ buckets: HashMap<String, Buckets>,
+}
+
+impl Timeline {
+ pub fn new(
+ name: String,
+ units_text: String,
+ is_mmm: bool,
+ is_cumulative: bool,
+ colour: Color,
+ ) -> Timeline {
+ Timeline {
+ name,
+ units_text,
+ is_mmm,
+ is_cumulative,
+ buckets: HashMap::<String, Buckets>::new(),
+ last_non_zero_value: 0,
+ colour,
+ }
+ }
+
+ pub fn get_name(&self) -> &String {
+ &self.name
+ }
+
+ pub fn add_bucket_set(&mut self, name: &'static str, duration: Duration, num_buckets: usize) {
+ self.buckets.insert(
+ name.to_string(),
+ Buckets::new(duration, num_buckets, self.is_mmm),
+ );
+ }
+
+ pub fn get_bucket_set(&self, timescale_name: &str) -> Option<&Buckets> {
+ return self.buckets.get(timescale_name);
+ }
+
+ pub fn get_bucket_set_mut(&mut self, timescale_name: &str) -> Option<&mut Buckets> {
+ return self.buckets.get_mut(timescale_name);
+ }
+
+ pub fn get_buckets_mut(
+ &mut self,
+ timescale_name: &str,
+ mmm_ui_mode: Option<&MinMeanMax>,
+ ) -> Option<&Vec<u64>> {
+ if let Some(bucket_set) = self.buckets.get(timescale_name) {
+ return Some(bucket_set.buckets(mmm_ui_mode));
+ } else {
+ return None;
+ }
+ }
+
+ pub fn get_buckets(
+ &self,
+ timescale_name: &str,
+ mmm_ui_mode: Option<&MinMeanMax>,
+ ) -> Option<&Vec<u64>> {
+ if let Some(bucket_set) = self.buckets.get(timescale_name) {
+ return Some(bucket_set.buckets(mmm_ui_mode));
+ } else {
+ return None;
+ }
+ }
+
+ ///! Update all Buckets with new current time
+ ///!
+ ///! Call significantly more frequently than the smallest Buckets duration
+ pub fn update_current_time(&mut self, new_time: &DateTime<Utc>) {
+ // debug_log!(format!("timeline::update_current_time() new_time: {:?}", new_time).as_str());
+ for (_name, bs) in self.buckets.iter_mut() {
+ bs.update_current_time(new_time, self.is_cumulative);
+ }
+ }
+
+ pub fn update_value(&mut self, time: &DateTime<Utc>, value: u64) {
+ // debug_log!("update_value()");
+
+ if value > 0 {
+ self.last_non_zero_value = value;
+ }
+ for (_name, bs) in self.buckets.iter_mut() {
+ // debug_log!(format!("name : {}", _name).as_str());
+ let mut index = Some(bs.num_buckets() - 1);
+ // debug_log!(format!("time : {}", time).as_str());
+ if let Some(bucket_time) = bs.bucket_time {
+ // debug_log!(format!("bucket_time: {}", bucket_time).as_str());
+ if time.lt(&bucket_time) {
+ // Use the closest bucket to this time
+ // debug_log!("increment (closest bucket)");
+ let time_difference = (bucket_time - *time).num_nanoseconds();
+ let bucket_duration = bs.bucket_duration.num_nanoseconds();
+ if time_difference.and(bucket_duration).is_some() {
+ let buckets_behind = time_difference.unwrap() / bucket_duration.unwrap();
+ if buckets_behind as usize >= bs.num_buckets() {
+ debug_log!(
+ format!("increment DISCARDED buckets_behind: {}", buckets_behind).as_str()
+ );
+ index = None;
+ } else {
+ // debug_log!(format!("increment INCLUDED buckets_behind: {}", buckets_behind).as_str());
+ if bs.num_buckets() > 1 {
+ index = Some(bs.num_buckets() - 1 - buckets_behind as usize);
+ }
+ }
+ }
+ }
+ }
+ if let Some(index) = index {
+ // debug_log!(format!("increment index: {}", index).as_str());
+ bs.bucket_update_value(index, value, self.is_cumulative);
+ }
+ }
+ // debug_log!("update_value() DONE");
+ }
+}
+
+use serde_with::serde_as;
+use serde_with::DurationSeconds;
+
+/// Buckets operate as a value series (e.g. count per bucket), or
+/// if Some(stats_mmm) they maintain min, mean and max series.
+
+// I use the same impl code for is_mmm true or false to avoid polymorphic code
+#[serde_as]
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Buckets {
+ pub bucket_time: Option<DateTime<Utc>>, // Start time of the active buckets
+ pub earliest_time: Option<DateTime<Utc>>, // Earliest time passed to update_current_time()
+ pub latest_time: Option<DateTime<Utc>>, // Most recent time passed to update_current_time()
+
+ #[serde_as(as = "DurationSeconds<i64>")]
+ pub total_duration: Duration,
+ #[serde_as(as = "DurationSeconds<i64>")]
+ pub bucket_duration: Duration,
+ pub num_buckets: usize,
+ pub values_total: u64,
+ pub values_min: u64,
+ pub values_max: u64,
+
+ pub is_mmm: bool,
+
+ // if !is_mmm we only use buckets
+ pub buckets: Vec<u64>, // Value series
+
+ // if is_mmm use only the following
+ pub buckets_count: Vec<u64>, // Number of values added to a bucket (timeslot)
+ pub buckets_total: Vec<u64>, // Total of all values added to a given bucket (timeslot)
+ pub buckets_min: Vec<u64>, // Min of all values
+ pub buckets_mean: Vec<u64>, // Average
+ pub buckets_max: Vec<u64>, // Max
+
+ pub buckets_need_init: Vec<u64>, // Filled with 1 and set to 0 after init
+}
+
+impl Buckets {
+ pub fn new(bucket_duration: Duration, num_buckets: usize, is_mmm: bool) -> Buckets {
+ let value_buckets_size = if is_mmm { 1 } else { num_buckets };
+ let mmm_buckets_size = if is_mmm { num_buckets } else { 1 };
+
+ return Buckets {
+ bucket_time: None,
+ earliest_time: None,
+ latest_time: None,
+ bucket_duration,
+ num_buckets,
+ values_total: 0,
+ values_min: u64::MAX,
+ values_max: 0,
+ total_duration: bucket_duration * num_buckets as i32,
+
+ is_mmm: is_mmm,
+ buckets: vec![0; value_buckets_size],
+
+ buckets_count: vec![0; mmm_buckets_size],
+ buckets_total: vec![0; mmm_buckets_size],
+ buckets_min: vec![0; mmm_buckets_size],
+ buckets_mean: vec![0; mmm_buckets_size],
+ buckets_max: vec![0; mmm_buckets_size],
+
+ buckets_need_init: vec![1; mmm_buckets_size],
+ };
+ }
+
+ /// Update all buckets with current time
+ pub fn update_current_time(&mut self, new_time: &DateTime<Utc>, is_cumulative: bool) {
+ // debug_log!(format!("Buckets::update_current_time() new_time: {:?}", new_time).as_str());
+ // if let Some(earliest_time) = self.earliest_time {
+ // debug_log!(format!("self.earliest_time: {:?}", earliest_time).as_str());
+ // } else {
+ // debug_log!(format!("self.earliest_time: None").as_str());
+ // }
+ if let Some(mut bucket_time) = self.bucket_time {
+ let mut end_time = bucket_time + self.bucket_duration;
+ // debug_log!(format!("end_time : {}", end_time).as_str());
+ while end_time.lt(&new_time) {
+ // debug_log!("Start new bucket");
+ // Start new bucket
+ self.bucket_time = Some(end_time);
+ bucket_time = end_time;
+ end_time = bucket_time + self.bucket_duration;
+
+ if self.is_mmm {
+ for buckets in &mut vec![
+ &mut self.buckets_count,
+ &mut self.buckets_total,
+ &mut self.buckets_min,
+ &mut self.buckets_mean,
+ &mut self.buckets_max,
+ ]
+ .iter_mut()
+ {
+ buckets.push(0);
+ if buckets.len() > self.num_buckets {
+ buckets.remove(0);
+ }
+ }
+
+ self.buckets_need_init.push(1);
+ if self.buckets_need_init.len() > self.num_buckets {
+ self.buckets_need_init.remove(0);
+ }
+ } else {
+ self.buckets.push(0);
+ if self.buckets.len() > self.num_buckets {
+ if is_cumulative {
+ self.values_total -= self.buckets[0];
+ }
+ self.buckets.remove(0);
+ }
+ }
+ }
+ } else {
+ self.bucket_time = Some(*new_time);
+ }
+
+ if let Some(earliest_time) = self.earliest_time {
+ if new_time.lt(&earliest_time) {
+ self.earliest_time = Some(*new_time);
+ }
+ } else {
+ self.earliest_time = Some(*new_time);
+ };
+
+ if let Some(latest_time) = self.latest_time {
+ if new_time.gt(&latest_time) {
+ self.latest_time = Some(*new_time);
+ }
+ } else {
+ self.latest_time = Some(*new_time);
+ };
+ }
+
+ pub fn bucket_update_value(&mut self, index: usize, value: u64, is_cumulative: bool) {
+ // debug_log!(format!("bucket_update_value(index:{}, value:{}, is_cum:{}) is_mmm:{}", index, value, is_cumulative, self.is_mmm).as_str());
+ if self.is_mmm {
+ debug_log!(format!(
+ "is_mmm: bucket_update_value(index:{}, value:{}, is_cum:{})",
+ index, value, is_cumulative
+ )
+ .as_str());
+ if self.buckets_need_init[index] == 1 {
+ // debug_log!("is_mmm: doing init");
+
+ self.buckets_need_init[index] = 0;
+
+ self.buckets_count[index] = 0;
+ self.buckets_total[index] = 0;
+ self.buckets_min[index] = u64::MAX;
+ self.buckets_mean[index] = 0;
+ self.buckets_max[index] = 0;
+ }
+ self.buckets_count[index] += 1;
+ self.buckets_total[index] += value;
+ self.buckets_mean[index] = self.buckets_total[index] / self.buckets_count[index];
+
+ if value < self.buckets_min[index] {
+ self.buckets_min[index] = value
+ }
+ if value > self.buckets_max[index] {
+ self.buckets_max[index] = value
+ }
+
+ if value < self.values_min {
+ self.values_min = value
+ }
+ if value > self.values_max {
+ self.values_max = value
+ }
+ } else {
+ if is_cumulative {
+ self.buckets[index] += value;
+ if self.buckets[index] < self.values_min {
+ self.values_min = self.buckets[index]
+ }
+ if self.buckets[index] > self.values_max {
+ self.values_max = self.buckets[index]
+ }
+ self.values_total += value;
+ } else {
+ self.buckets[index] = value;
+ if value < self.values_min {
+ self.values_min = value
+ }
+ if value > self.values_max {
+ self.values_max = value
+ }
+ }
+ }
+ }
+
+ pub fn get_duration_text(&self) -> String {
+ let mut duration = self.total_duration;
+ if let Some(earliest_time) = self.earliest_time {
+ if let Some(latest_time) = self.latest_time {
+ // debug_log!(format!("get_duration_text() earliest_time: {:?} latest_time {:?}", earliest_time, latest_time).as_str());
+
+ if (latest_time - earliest_time).lt(&duration)
+ && (latest_time - earliest_time).num_seconds() > 0
+ {
+ duration = latest_time - earliest_time;
+ } else if latest_time.eq(&earliest_time) {
+ duration = self.bucket_duration;
+ }
+ };
+ return get_duration_text(duration);
+ };
+
+ return String::from("(zero duration)");
+ }
+
+ pub fn num_buckets(&self) -> usize {
+ return self.num_buckets;
+ }
+
+ pub fn buckets(&self, mmm_ui_mode: Option<&MinMeanMax>) -> &Vec<u64> {
+ if self.is_mmm {
+ return match mmm_ui_mode {
+ None => &self.buckets,
+ Some(MinMeanMax::Min) => &self.buckets_min,
+ Some(MinMeanMax::Mean) => &self.buckets_mean,
+ Some(MinMeanMax::Max) => &self.buckets_max,
+ };
+ } else {
+ return &self.buckets;
+ }
+ }
+}
--- /dev/null
+pub const ATTOS_PER_ANT: f64 = 1e18;
+
+/// Terminal based interface and dashboard
+///
+/// Edit src/custom/ui.rs to create a customised fork of logtail-dash
+use super::app::{App, DashState, DashViewMain};
+use super::ui_debug::draw_debug_dash;
+use super::ui_help::draw_help_dash;
+use super::ui_node::draw_node_dash;
+use super::ui_summary::draw_summary_dash;
+
+/// Provides string representation of an attos amount, in either attos or currency depending on dash_state
+pub fn monetary_string(dash_state: &DashState, attos: u64) -> String {
+ if dash_state.ui_uses_currency && dash_state.currency_per_token.is_some() {
+ let value = (dash_state.currency_per_token.unwrap() * (attos as f64)) / 2 as f64;
+ return if value >= 0.01 {
+ format!("{:<1}{:.2}", dash_state.currency_symbol, value)
+ } else {
+ format!("{:<1}{:.9}", dash_state.currency_symbol, value)
+ };
+ } else {
+ return format!("{}", attos);
+ }
+}
+
+/// Provides string representation of an ANT amount, in either attos or currency depending on dash_state
+pub fn monetary_string_ant(dash_state: &DashState, attos: u64) -> String {
+ if dash_state.ui_uses_currency && dash_state.currency_per_token.is_some() {
+ let value = dash_state.currency_per_token.unwrap() * attos_to_ant(attos);
+ return if value >= 0.01 {
+ format!("{:<1}{:.2}", dash_state.currency_symbol, value)
+ } else {
+ format!("{:<1}{:.9}", dash_state.currency_symbol, value)
+ };
+ } else {
+ return if attos >= 10000000000000000000 {
+ format!("{:.9}", attos_to_ant(attos))
+ } else {
+ format!("{:.9}", attos_to_ant(attos))
+ };
+ }
+}
+
+fn attos_to_ant(attos: u64) -> f64 {
+ attos as f64 / ATTOS_PER_ANT
+}
+
+#[path = "../widgets/mod.rs"]
+pub mod widgets;
+use self::widgets::sparkline::Sparkline2;
+
+use ratatui::{
+ layout::Rect,
+ style::{Color, Style},
+ text::Line,
+ widgets::{Block, ListItem},
+ Frame,
+};
+
+pub fn draw_dashboard(f: &mut Frame, app: &mut App) {
+ match app.dash_state.main_view {
+ DashViewMain::DashSummary => draw_summary_dash(f, &mut app.dash_state, &mut app.monitors),
+ DashViewMain::DashNode => draw_node_dash(f, &mut app.dash_state, &mut app.monitors),
+ DashViewMain::DashHelp => draw_help_dash(f, &mut app.dash_state),
+ DashViewMain::DashDebug => draw_debug_dash(f, &mut app.dash_state, &mut app.monitors),
+ }
+}
+
+pub fn push_subheading(items: &mut Vec<ListItem>, subheading: &String) {
+ items.push(
+ ListItem::new(vec![Line::from(subheading.clone())]).style(Style::default().fg(Color::Yellow)),
+ );
+}
+
+pub fn push_text(items: &mut Vec<ListItem>, subheading: &String, optional_style: Option<Style>) {
+ let style = match optional_style {
+ Some(style) => style,
+ None => Style::default().fg(Color::Green),
+ };
+
+ items.push(ListItem::new(vec![Line::from(subheading.clone())]).style(style));
+}
+
+pub fn push_blank(items: &mut Vec<ListItem>) {
+ push_text(items, &String::from(""), None);
+}
+
+pub fn push_multiline_text(mut items: &mut Vec<ListItem>, lines: &str) {
+ for line in lines.lines().into_iter() {
+ push_text(&mut items, &String::from(line), None);
+ }
+}
+
+pub fn push_metric(items: &mut Vec<ListItem>, metric: &String, value: &String) {
+ let s = format!("{:<12}: {:>12}", metric, value);
+ items.push(ListItem::new(vec![Line::from(s.clone())]).style(Style::default().fg(Color::Blue)));
+}
+
+pub fn push_price(items: &mut Vec<ListItem>, metric: &String, value: &String) {
+ let s = format!("{:<4} {:<15}", metric, value);
+ items.push(ListItem::new(vec![Line::from(s.clone())]).style(Style::default().fg(Color::Blue)));
+}
+
+pub fn push_metric_with_units(
+ items: &mut Vec<ListItem>,
+ metric: &String,
+ value: &String,
+ units: &String,
+) {
+ let s = format!("{:<12}: {:>12} {}", metric, value, units);
+ items.push(ListItem::new(vec![Line::from(s.clone())]).style(Style::default().fg(Color::Blue)));
+}
+
+pub fn draw_sparkline(
+ f: &mut Frame,
+ area: Rect,
+ buckets: &Vec<u64>,
+ title: &str,
+ fg_colour: ratatui::style::Color,
+) {
+ let sparkline = Sparkline2::default()
+ .block(Block::default().title(title))
+ .data(buckets_right_justify(&buckets, area.width))
+ .style(Style::default().fg(fg_colour));
+ f.render_widget(sparkline, area);
+}
+
+// Right justify and truncate (left) a set of buckets to width
+fn buckets_right_justify(buckets: &Vec<u64>, width: u16) -> &[u64] {
+ let width = width as usize;
+ if width < buckets.len() {
+ return &buckets[buckets.len() - width..];
+ }
+
+ buckets
+}
--- /dev/null
+///! Terminal based interface and dashboard
+///!
+use std::collections::HashMap;
+
+use super::app::{DashState, LogMonitor, DEBUG_WINDOW_NAME};
+use crate::custom::opt::{get_app_name, get_app_version};
+
+use ratatui::{
+ layout::Rect,
+ style::{Color, Modifier, Style},
+ text::Line,
+ widgets::{Block, Borders, List, ListItem},
+ Frame,
+};
+
+use super::ui_node::draw_logfile;
+
+pub fn draw_debug_dash(
+ f: &mut Frame,
+ _dash_state: &DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ for (logfile, monitor) in monitors.iter_mut() {
+ if monitor.is_debug_dashboard_log {
+ draw_logfile(f, f.size(), logfile, monitor);
+ }
+ }
+}
+
+pub fn draw_debug_window(f: &mut Frame, area: Rect, dash_state: &mut DashState) {
+ let highlight_style = match dash_state.debug_window_has_focus {
+ true => Style::default()
+ .bg(Color::LightGreen)
+ .add_modifier(Modifier::BOLD),
+ false => Style::default().add_modifier(Modifier::BOLD),
+ };
+
+ let items: Vec<ListItem> = dash_state
+ .debug_window_list
+ .items
+ .iter()
+ .map(|s| {
+ ListItem::new(vec![Line::from(s.clone())])
+ .style(Style::default().fg(Color::Black).bg(Color::White))
+ })
+ .collect();
+
+ let debug_window_widget = List::new(items)
+ .block(
+ Block::default()
+ .borders(Borders::ALL)
+ .title(format!("{} v{} - {}", get_app_name(), get_app_version(), String::from(DEBUG_WINDOW_NAME))),
+ )
+ .highlight_style(highlight_style);
+
+ f.render_stateful_widget(
+ debug_window_widget,
+ area,
+ &mut dash_state.debug_window_list.state,
+ );
+}
--- /dev/null
+///! Terminal based interface and dashboard
+///!
+use super::app::{DashState, HELP_WINDOW_NAME};
+use crate::custom::opt::{get_app_name, get_app_version};
+use crate::custom::ui::{push_blank, push_multiline_text, push_subheading, push_text};
+
+use ratatui::{
+ layout::Rect,
+ widgets::{Block, Borders, List, ListItem},
+ Frame,
+};
+
+pub fn draw_help_dash(f: &mut Frame, dash_state: &mut DashState) {
+ draw_help_window(f, f.size(), dash_state);
+}
+
+pub fn draw_help_window(f: &mut Frame, area: Rect, dash_state: &mut DashState) {
+ let mut items = Vec::<ListItem>::new();
+
+ push_blank(&mut items);
+ push_text(
+ &mut items,
+ &String::from(" For vdash command usage:"),
+ None,
+ );
+ push_text(&mut items, &String::from(" vdash --help"), None);
+
+ push_blank(&mut items);
+ push_subheading(&mut items, &String::from(" Keyboard Commands"));
+ push_multiline_text(
+ &mut items,
+ "
+ 'n' or 'enter' : Switch to Node Status where you can cycle through status of each node.\n
+ 's' or 'enter' : Switch to Summary of all monitored nodes.\n
+ 'r' : Re-scan any 'glob' paths to add new nodes.\n
+ '$' : Toggle between attos and a currency (if rate specified on the command line).
+
+ 'q' : Quit vdash.
+ 'h' or '?' : Shows this help. Press 'n' or 's' to exit help.",
+ );
+
+ push_blank(&mut items);
+ push_blank(&mut items);
+ push_subheading(
+ &mut items,
+ &String::from(" Node Status: selecting a node"),
+ );
+ push_blank(&mut items);
+
+ push_text(&mut items, &String::from(" Use right arrow and left arrow to cycle forward and backwards through multiple monitored nodes."), None);
+ push_blank(&mut items);
+
+ push_blank(&mut items);
+ push_blank(&mut items);
+ push_subheading(&mut items, &String::from(" Node Status: timelines"));
+
+ push_multiline_text(&mut items,"
+ 'o' or '-' : Zoom timeline out.
+ 'i' or '+' : Zoom timeline in.
+
+ 'm' : Cycle through min, mean, max values for non-cumulative timelines (e.g. Storage Cost).
+
+ 't': : Scroll timelines up if some are hidden due to lack of vertical space.
+ 'T': : Scroll timelines down.
+
+ 'l' : Toggle between show logfile plus 3 timelines and hide logfile to show more timelines.
+ ");
+
+ push_blank(&mut items);
+ push_subheading(&mut items, &String::from(" To exit Help press 'enter'"));
+
+ if dash_state.debug_window {
+ push_blank(&mut items);
+ push_blank(&mut items);
+ push_text(&mut items, &String::from(" 'g' for debug window"), None);
+ }
+
+ let help_title_text = format!(
+ "{} v{} - {}",
+ get_app_name(),
+ get_app_version(),
+ String::from(HELP_WINDOW_NAME)
+ );
+ let help_widget = List::new(items).block(
+ Block::default()
+ .borders(Borders::ALL)
+ .title(help_title_text),
+ );
+ f.render_stateful_widget(help_widget, area, &mut dash_state.help_status.state);
+}
--- /dev/null
+use crossterm::event::KeyCode;
+
+use crate::custom::app::{App, DashViewMain, set_main_view};
+
+/// Handle a keyboard event and return false to cause exit of app (vdash)
+pub async fn handle_keyboard_event(mut app: &mut App, event: &crossterm::event::KeyEvent, opt_debug_window: bool) -> bool {
+
+ match event.code {
+ // For debugging, ~ sends a line to the debug_window
+ KeyCode::Char('~') => app.dash_state._debug_window(format!("Event::Input({:#?})", event).as_str()),
+
+ KeyCode::Char('q')|
+ KeyCode::Char('Q') => {
+ return false;
+ },
+ KeyCode::Enter => {
+ if app.dash_state.main_view == DashViewMain::DashHelp {
+ set_main_view(app.dash_state.previous_main_view, &mut app);
+ } else {
+ if app.logfiles_manager.logfiles_added.len() > 0 {
+ if app.dash_state.main_view == DashViewMain::DashNode {
+ app.preserve_node_selection();
+ set_main_view(DashViewMain::DashSummary, &mut app);
+ } else if app.dash_state.main_view == DashViewMain::DashSummary {
+ app.preserve_node_selection();
+ set_main_view(DashViewMain::DashNode, &mut app);
+ }
+ }
+ }
+ }
+
+ KeyCode::Char(' ') => {
+ if app.dash_state.main_view == DashViewMain::DashSummary {
+ app.dash_state.logfile_names_sorted_ascending = !app.dash_state.logfile_names_sorted_ascending;
+ app.update_summary_window();
+ }
+ }
+
+ KeyCode::Char('$') => {
+ if app.dash_state.currency_per_token.is_some() {
+ app.dash_state.ui_uses_currency = !app.dash_state.ui_uses_currency;
+ app.update_summary_window();
+ }
+ }
+
+ KeyCode::Char('s')|
+ KeyCode::Char('S') => {
+ app.preserve_node_selection();
+ set_main_view(DashViewMain::DashSummary, &mut app);
+ },
+
+ KeyCode::Char('h')|
+ KeyCode::Char('H')|
+ KeyCode::Char('?') => set_main_view(DashViewMain::DashHelp, &mut app),
+ KeyCode::Char('n')|
+ KeyCode::Char('N') => {
+ if app.logfiles_manager.logfiles_added.len() > 0 {
+ app.preserve_node_selection();
+ set_main_view(DashViewMain::DashNode, &mut app);
+ }
+ },
+
+ KeyCode::Char('+')|
+ KeyCode::Char('i')|
+ KeyCode::Char('I') => app.scale_timeline_up(),
+ KeyCode::Char('-')|
+ KeyCode::Char('o')|
+ KeyCode::Char('O') => app.scale_timeline_down(),
+
+ KeyCode::Char('l')|
+ KeyCode::Char('L') => app.toggle_logfile_area(),
+
+ KeyCode::Char('m')|
+ KeyCode::Char('M') => app.bump_mmm_ui_mode(),
+
+ KeyCode::Char('r')|
+ KeyCode::Char('R') => app.scan_glob_paths(false, false).await,
+
+ KeyCode::Char('t') => app.top_timeline_next(),
+ KeyCode::Char('T') => app.top_timeline_previous(),
+
+ KeyCode::Down => app.handle_arrow_down(),
+ KeyCode::Up => app.handle_arrow_up(),
+ KeyCode::Right|
+ KeyCode::Tab => app.change_focus_next(),
+ KeyCode::Left => app.change_focus_previous(),
+
+ KeyCode::Char('g') => {
+ if opt_debug_window { set_main_view(DashViewMain::DashDebug, &mut app); }
+ },
+ _ => {}
+ };
+
+ return true;
+}
--- /dev/null
+///! Terminal based interface and dashboard
+///!
+use chrono::Utc;
+use std::collections::HashMap;
+
+#[path = "../widgets/mod.rs"]
+pub mod widgets;
+use self::widgets::gauge::Gauge2;
+
+use super::app::{DashState, LogMonitor};
+use super::timelines::Timeline;
+use crate::custom::app_timelines::EARNINGS_UNITS_TEXT;
+use crate::custom::timelines::{get_duration_text, get_max_buckets_value, get_min_buckets_value};
+
+use crate::custom::ui::{
+ draw_sparkline, monetary_string, monetary_string_ant, push_metric, push_metric_with_units,
+ push_subheading,
+};
+
+use ratatui::{
+ layout::{Constraint, Direction, Layout, Rect},
+ style::{Color, Modifier, Style},
+ text::Line,
+ widgets::{Block, Borders, List, ListItem},
+ Frame,
+};
+
+pub fn draw_node_dash(
+ f: &mut Frame,
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let size = f.size();
+ let chunks_with_3_bands = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(
+ [
+ Constraint::Length(12), // Stats summary and graphs
+ Constraint::Length(18), // Timelines
+ Constraint::Min(0), // Logfile panel
+ ]
+ .as_ref(),
+ )
+ .split(size);
+
+ let chunks_with_2_bands = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(
+ [
+ Constraint::Length(12), // Stats summary and graphs
+ Constraint::Min(0), // Timelines
+ ]
+ .as_ref(),
+ )
+ .split(size);
+
+ for entry in monitors.into_iter() {
+ let (logfile, mut monitor) = entry;
+ if monitor.has_focus {
+ if dash_state.node_logfile_visible {
+ // Stats and Graphs / Timelines / Logfile
+ draw_node(f, chunks_with_3_bands[0], dash_state, &mut monitor);
+ draw_timelines_panel(f, chunks_with_3_bands[1], dash_state, &mut monitor);
+ draw_bottom_panel(
+ f,
+ chunks_with_3_bands[2],
+ dash_state,
+ &logfile,
+ &mut monitor,
+ );
+ return;
+ } else {
+ // Stats and Graphs / Timelines
+ draw_node(f, chunks_with_2_bands[0], dash_state, &mut monitor);
+ draw_timelines_panel(f, chunks_with_2_bands[1], dash_state, &mut monitor);
+ return;
+ }
+ }
+ }
+
+ // In debug mode there's one node dash and this provide the debug dash
+ crate::custom::ui_debug::draw_debug_dash(f, dash_state, monitors);
+}
+
+fn draw_node(f: &mut Frame, area: Rect, dash_state: &mut DashState, monitor: &mut LogMonitor) {
+ // Columns:
+ let constraints = [
+ Constraint::Length(40), // Stats summary
+ Constraint::Min(10), // Graphs
+ ];
+
+ let chunks = Layout::default()
+ .direction(Direction::Horizontal)
+ .constraints(constraints.as_ref())
+ .split(area);
+
+ draw_node_stats(f, dash_state, chunks[0], monitor);
+ draw_node_storage(f, chunks[1], dash_state, monitor);
+}
+
+fn draw_node_stats(
+ f: &mut Frame,
+ dash_state: &mut DashState,
+ area: Rect,
+ monitor: &mut LogMonitor,
+) {
+ // TODO maybe add items to monitor.metrics_status and make items from that as in draw_logfile()
+ let mut items = Vec::<ListItem>::new();
+
+ let mut node_title_text = String::from(super::app::NODE_BINARY_NAME);
+
+ if let Some(node_running_version) = &monitor.metrics.running_version {
+ node_title_text += format!(" {}", node_running_version).as_str();
+ }
+
+ if let Some(node_process_id) = &monitor.metrics.node_process_id {
+ node_title_text += format!(" (PID: {})", node_process_id).as_str();
+ }
+
+ push_subheading(&mut items, &node_title_text);
+
+ let mut node_uptime_txt = String::from("Start time unknown");
+ if let Some(node_start_time) = monitor.metrics.node_started {
+ node_uptime_txt = get_duration_text(Utc::now() - node_start_time);
+ }
+ push_metric(&mut items, &"Node Uptime".to_string(), &node_uptime_txt);
+
+ push_metric(
+ &mut items,
+ &"Status".to_string(),
+ &monitor.metrics.node_status_string,
+ );
+
+ let units_text = if dash_state.ui_uses_currency {
+ ""
+ } else {
+ "ANT" // crate::custom::app_timelines::EARNINGS_UNITS_TEXT
+ };
+
+ let wallet_balance = monetary_string_ant(dash_state, monitor.metrics.wallet_balance);
+ push_metric_with_units(
+ &mut items,
+ &"Wallet".to_string(),
+ &wallet_balance,
+ &units_text.to_string(),
+ );
+
+ let storage_payments_txt = monetary_string_ant(dash_state, monitor.metrics.attos_earned.total);
+ push_metric_with_units(
+ &mut items,
+ &"Earnings".to_string(),
+ &storage_payments_txt,
+ &units_text.to_string(),
+ );
+
+ let chunk_fee_txt = if monitor.metrics.storage_cost.most_recent == 0 {
+ String::from("unknown")
+ } else {
+ format!(
+ "{} ({}-{}){} ",
+ monitor.metrics.storage_cost.most_recent.to_string(),
+ monitor.metrics.storage_cost.min.to_string(),
+ monitor.metrics.storage_cost.max.to_string(),
+ crate::custom::app_timelines::STORAGE_COST_UNITS_TEXT,
+ )
+ };
+
+ push_metric(&mut items, &"Storage Cost".to_string(), &chunk_fee_txt);
+
+ let connections_text = format!("{}", monitor.metrics.peers_connected.most_recent);
+ push_metric(&mut items, &"Connections".to_string(), &connections_text);
+
+ push_metric(
+ &mut items,
+ &"PUTS".to_string(),
+ &monitor.metrics.activity_puts.total.to_string(),
+ );
+
+ push_metric(
+ &mut items,
+ &"GETS".to_string(),
+ &monitor.metrics.activity_gets.total.to_string(),
+ );
+
+ push_metric(
+ &mut items,
+ &"ERRORS".to_string(),
+ &monitor.metrics.activity_errors.total.to_string(),
+ );
+
+ push_subheading(&mut items, &"".to_string());
+ let heading = format!("Node {:>2} Status", monitor.index + 1);
+ let monitor_widget = List::new(items).block(
+ Block::default()
+ .borders(Borders::ALL)
+ .title(heading.to_string()),
+ );
+ f.render_stateful_widget(monitor_widget, area, &mut monitor.metrics_status.state);
+}
+
+fn draw_timelines_panel(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ monitor: &mut LogMonitor,
+) {
+ if let Some(active_timescale_name) = dash_state.get_active_timescale_name() {
+ let window_widget = Block::default()
+ .borders(Borders::ALL)
+ .title(format!("Timeline - {}", active_timescale_name).to_string());
+ f.render_widget(window_widget, area);
+
+ // For debugging the bucket state
+ //
+ // if let Some(b_time) = monitor.metrics.sparkline_bucket_time {
+ // dash_state._debug_window(format!("sparkline_b_time: {}", b_time).as_str());
+ // dash_state._debug_window(
+ // format!(
+ // "sparkline_b_width: {}",
+ // monitor.metrics.sparkline_bucket_width
+ // )
+ // .as_str(),
+ // );
+ // }
+
+ // let mut i = 0;
+ // while i < monitor.metrics.puts_sparkline.len() {
+ // dash_state._debug_window(
+ // format!(
+ // "{:>2}: {:>2} puts, {:>2} gets",
+ // i, monitor.metrics.puts_sparkline[i], monitor.metrics.gets_sparkline[i]
+ // )
+ // .as_str(),
+ // );
+ // i += 1;
+ // }
+
+ const NUM_TIMELINES_VISIBLE: u16 = 3;
+ let num_timelines_visible = if dash_state.node_logfile_visible {
+ NUM_TIMELINES_VISIBLE
+ } else {
+ crate::custom::app_timelines::APP_TIMELINES.len() as u16
+ };
+
+ let chunks_slim = Layout::default()
+ .direction(Direction::Vertical)
+ .margin(1)
+ .constraints(
+ [
+ // Three timelines
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ ]
+ .as_ref(),
+ )
+ .split(area);
+
+ let chunks_fat = Layout::default()
+ .direction(Direction::Vertical)
+ .margin(1)
+ .constraints(
+ [
+ // Tailored to display all timelines in APP_TIMELINES (currently 7)
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ Constraint::Percentage(100 / num_timelines_visible),
+ ]
+ .as_ref(),
+ )
+ .split(area);
+
+ let mut index = dash_state.top_timeline_index() + 1;
+ for i in 1..=num_timelines_visible {
+ if index > monitor.metrics.app_timelines.get_num_timelines() {
+ index = 1;
+ }
+ let timeline_index = if dash_state.node_logfile_visible {
+ index
+ } else {
+ i as usize
+ };
+ if let Some(timeline) = monitor
+ .metrics
+ .app_timelines
+ .get_timeline_by_index(timeline_index - 1)
+ {
+ let chunk = if dash_state.node_logfile_visible {
+ &chunks_slim
+ } else {
+ &chunks_fat
+ };
+ draw_timeline(
+ f,
+ chunk[i as usize - 1],
+ dash_state,
+ timeline,
+ active_timescale_name,
+ );
+ }
+ index += 1;
+ }
+ }
+}
+
+fn draw_timeline(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ timeline: &Timeline,
+ active_timescale_name: &str,
+) {
+ use crate::custom::timelines::MinMeanMax;
+
+ let mmm_ui_mode = dash_state.mmm_ui_mode();
+ let mmm_text = if timeline.is_mmm {
+ match mmm_ui_mode {
+ MinMeanMax::Min => " Min ",
+ MinMeanMax::Mean => " Mean",
+ MinMeanMax::Max => " Max ",
+ }
+ } else {
+ ""
+ };
+
+ if let Some(bucket_set) = timeline.get_bucket_set(active_timescale_name) {
+ if let Some(buckets) = timeline.get_buckets(active_timescale_name, Some(mmm_ui_mode)) {
+ // dash_state._debug_window(format!("bucket[0-2 to max]: {},{},{},{} to {}, for {}", buckets[0], buckets[1], buckets[2], buckets[3], buckets[buckets.len()-1], display_name).as_str());
+ let duration_text = bucket_set.get_duration_text();
+
+ let mut max_bucket_value = get_max_buckets_value(buckets);
+ let mut min_bucket_value = get_min_buckets_value(buckets);
+ let label_stats = if timeline.is_cumulative {
+ if dash_state.ui_uses_currency && timeline.units_text == EARNINGS_UNITS_TEXT {
+ format!(
+ "{} in last {}",
+ monetary_string(dash_state, bucket_set.values_total),
+ duration_text
+ )
+ } else {
+ format!(
+ "{} {} in last {}",
+ bucket_set.values_total, timeline.units_text, duration_text
+ )
+ }
+ } else {
+ dash_state
+ ._debug_window(format!("min: {} max: {}", min_bucket_value, max_bucket_value).as_str());
+ if max_bucket_value == 0 {
+ max_bucket_value = timeline.last_non_zero_value;
+ }
+ if min_bucket_value == u64::MAX || min_bucket_value == 0 {
+ min_bucket_value = max_bucket_value;
+ }
+ format!(
+ "range {}-{} {} in last {}",
+ min_bucket_value, max_bucket_value, timeline.units_text, duration_text
+ )
+ };
+ let label_scale = if max_bucket_value > 0 {
+ format!(
+ " (vertical scale: 0-{} {})",
+ max_bucket_value, timeline.units_text
+ )
+ } else {
+ String::from("")
+ };
+ let timeline_label = format!(
+ "{}{}: {}{}",
+ timeline.name, mmm_text, label_stats, label_scale
+ );
+ draw_sparkline(f, area, &buckets, &timeline_label, timeline.colour);
+ };
+ };
+}
+
+fn draw_bottom_panel(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ logfile: &String,
+ monitor: &mut LogMonitor,
+) {
+ if dash_state.debug_window {
+ // Vertical split:
+ let constraints = [
+ Constraint::Percentage(50), // Logfile
+ Constraint::Percentage(50), // Debug window
+ ];
+
+ let chunks = Layout::default()
+ .direction(Direction::Horizontal)
+ .constraints(constraints.as_ref())
+ .split(area);
+
+ draw_logfile(f, chunks[0], &logfile, monitor);
+ crate::custom::ui_debug::draw_debug_window(f, chunks[1], dash_state);
+ } else {
+ draw_logfile(f, area, &logfile, monitor);
+ }
+}
+
+pub fn draw_logfile(f: &mut Frame, area: Rect, logfile: &String, monitor: &mut LogMonitor) {
+ let highlight_style = match monitor.has_focus {
+ true => Style::default()
+ .bg(Color::LightGreen)
+ .add_modifier(Modifier::BOLD),
+ false => Style::default().add_modifier(Modifier::BOLD),
+ };
+
+ let items: Vec<ListItem> = monitor
+ .content
+ .items
+ .iter()
+ .map(|s| {
+ ListItem::new(vec![Line::from(s.clone())])
+ .style(Style::default().fg(Color::Black).bg(Color::White))
+ })
+ .collect();
+
+ let node_log_title = format!("Node Log ({})", logfile);
+
+ let logfile_widget = List::new(items)
+ .block(
+ Block::default()
+ .borders(Borders::ALL)
+ .title(node_log_title.clone()),
+ )
+ .highlight_style(highlight_style);
+
+ f.render_stateful_widget(logfile_widget, area, &mut monitor.content.state);
+}
+
+// TODO split into two sub functions, one for gauges, one for text strings
+fn draw_node_storage(
+ f: &mut Frame,
+ area: Rect,
+ _dash_state: &mut DashState,
+ monitor: &mut LogMonitor,
+) {
+ let heading = format!("Node {:>2} Resources", monitor.index + 1);
+ let monitor_widget = List::new(Vec::<ListItem>::new())
+ .block(
+ Block::default()
+ .borders(Borders::ALL)
+ .title(heading.clone()),
+ )
+ .highlight_style(
+ Style::default()
+ .bg(Color::LightGreen)
+ .add_modifier(Modifier::BOLD),
+ );
+ f.render_stateful_widget(monitor_widget, area, &mut monitor.content.state);
+
+ // Two rows top=gauges / bottom=text
+ let rows = Layout::default()
+ .direction(Direction::Vertical)
+ .margin(1)
+ .constraints(
+ [
+ Constraint::Length(2), // Rows for storage gauges
+ Constraint::Min(8), // Rows for other metrics
+ ]
+ .as_ref(),
+ )
+ .split(area);
+
+ // Storage: two columns for label+value | bar
+ let columns = Layout::default()
+ .direction(Direction::Horizontal)
+ .margin(0)
+ .constraints([Constraint::Length(27), Constraint::Min(12)].as_ref())
+ .split(rows[0]);
+
+ let mut storage_items = Vec::<ListItem>::new();
+ push_storage_subheading(&mut storage_items, &"Storage".to_string());
+ let mut gauges_column = columns[1];
+ gauges_column.height = 1;
+
+ // One gauge gap for heading, and an extra gauge so the last one drawn doesn't expand to the bottom
+ let constraints = vec![Constraint::Length(1); 1 + 2];
+ let gauges = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints::<&[Constraint]>(constraints.as_ref())
+ .split(columns[1]);
+
+ let max_string = if monitor.metrics.records_max > 0 {
+ format!("/{}", monitor.metrics.records_max)
+ } else {
+ String::from("")
+ };
+ push_storage_metric(
+ &mut storage_items,
+ &"Records".to_string(),
+ &format!("{}{}", monitor.metrics.records_stored, max_string),
+ );
+
+ let denominator = if monitor.metrics.records_max > 0 {
+ monitor.metrics.records_max
+ } else {
+ 1
+ };
+ let gauge = Gauge2::default()
+ .block(Block::default())
+ .gauge_style(Style::default().fg(Color::Yellow))
+ .ratio(ratio(monitor.metrics.records_stored, denominator));
+ f.render_widget(gauge, gauges[1]);
+
+ // TODO lobby to re-instate in node logfile
+ // push_storage_metric(
+ // &mut storage_items,
+ // &"Space Avail".to_string(),
+ // &max_string
+ // );
+
+ // push_storage_metric(
+ // &mut storage_items,
+ // &"Space Free".to_string(),
+ // &device_limit_string
+ // );
+
+ let storage_text_widget = List::new(storage_items).block(Block::default().borders(Borders::NONE));
+ f.render_widget(storage_text_widget, columns[0]);
+
+ let mut text_items = Vec::<ListItem>::new();
+ // push_storage_subheading(&mut text_items, &"".to_string());
+ push_storage_subheading(&mut text_items, &"Network".to_string());
+
+ const UPDATE_INTERVAL: u64 = 5; // Match value in s from maidsafe/safe_network/sn_logging/metrics.rs
+
+ let current_rx_text = format!("{:9} B/s", monitor.metrics.bytes_written / UPDATE_INTERVAL,);
+
+ push_storage_metric(&mut text_items, &"Current Rx".to_string(), ¤t_rx_text);
+
+ let current_tx_text = format!("{:9} B/s", monitor.metrics.bytes_read / UPDATE_INTERVAL,);
+
+ push_storage_metric(&mut text_items, &"Current Tx".to_string(), ¤t_tx_text);
+
+ let total_rx_text = format!(
+ "{:<13}: {:.0} / {:.0} MB",
+ "Total Rx", monitor.metrics.total_mb_read, monitor.metrics.total_mb_received,
+ );
+
+ text_items.push(
+ ListItem::new(vec![Line::from(total_rx_text.clone())]).style(Style::default().fg(Color::Blue)),
+ );
+
+ let total_tx_text = format!(
+ "{:<13}: {:.0} / {:.0} MB",
+ "Total Tx", monitor.metrics.total_mb_written, monitor.metrics.total_mb_transmitted,
+ );
+
+ text_items.push(
+ ListItem::new(vec![Line::from(total_tx_text.clone())]).style(Style::default().fg(Color::Blue)),
+ );
+
+ push_storage_subheading(&mut text_items, &"Load".to_string());
+
+ let node_text = format!(
+ "{:<13}: CPU {:8.2} (MAX {:2.2}) MEM {}MB",
+ "Node",
+ monitor.metrics.cpu_usage_percent,
+ monitor.metrics.cpu_usage_percent_max,
+ monitor.metrics.memory_used_mb.most_recent,
+ );
+ text_items.push(
+ ListItem::new(vec![Line::from(node_text.clone())]).style(Style::default().fg(Color::Blue)),
+ );
+
+ let system_text = format!(
+ "{:<13}: CPU {:8.2} MEM {:.0} / {:.0} MB {:.1}%",
+ "System",
+ monitor.metrics.system_cpu,
+ monitor.metrics.system_memory_used_mb,
+ monitor.metrics.system_memory,
+ monitor.metrics.system_memory_usage_percent,
+ );
+ text_items.push(
+ ListItem::new(vec![Line::from(system_text.clone())]).style(Style::default().fg(Color::Blue)),
+ );
+
+ // Render text
+ let text_widget = List::new(text_items).block(Block::default().borders(Borders::NONE));
+ f.render_widget(text_widget, rows[1]);
+}
+
+// Return string representation in TB, MB, KB or bytes depending on magnitude
+// fn format_size(bytes: u64, fractional_digits: usize) -> String {
+// use::byte_unit::Byte;
+// let bytes = Byte::from_bytes(bytes as u128);
+// bytes.get_appropriate_unit(false).format(fractional_digits)
+// }
+
+// Return ratio from two u64
+fn ratio(numerator: u64, denomimator: u64) -> f64 {
+ let percent = numerator as f64 / denomimator as f64;
+ if percent.is_nan() || percent < 0.0 {
+ 0.0
+ } else if percent > 1.0 {
+ 1.0
+ } else {
+ percent
+ }
+}
+
+pub fn push_storage_subheading(items: &mut Vec<ListItem>, subheading: &String) {
+ items.push(
+ ListItem::new(vec![Line::from(subheading.clone())]).style(Style::default().fg(Color::Yellow)),
+ );
+}
+
+pub fn push_storage_metric(items: &mut Vec<ListItem>, metric: &String, value: &String) {
+ let s = format!("{:<11}:{:>11}", metric, value);
+ items.push(ListItem::new(vec![Line::from(s.clone())]).style(Style::default().fg(Color::Blue)));
+}
--- /dev/null
+///! Simple status message
+///!
+
+use chrono::{DateTime, Utc, Duration};
+
+pub struct StatusMessage {
+ pub current_message: Option<String>,
+ pub default_duration: Duration,
+ pub default_message: String,
+
+ clear_at_time: Option<DateTime<chrono::Utc>>,
+ to_console: bool,
+}
+
+/// Send a status message to the console, or store it for display with a duration (e.g. by terminal GUI)
+impl StatusMessage {
+ pub fn new(default_message: &String, default_duration: &Duration) -> StatusMessage {
+ StatusMessage {
+ current_message: None,
+ default_duration: *default_duration,
+ default_message: String::from(default_message),
+ clear_at_time: None,
+ to_console: true,
+ }
+ }
+
+ fn reset(&mut self) {
+ *self = StatusMessage::new(&self.default_message, &self.default_duration);
+ }
+
+ pub fn disable_to_console(&mut self) { self.reset(); self.to_console = false; }
+ pub fn enable_to_console(&mut self) { self.to_console = true; }
+
+ pub fn message(&mut self, new_message: &String, new_duration: Option<Duration>) {
+ if self.to_console { eprintln!("{}", new_message); }
+ self.current_message = Some(String::from(new_message));
+
+ let duration = if let Some(duration) = new_duration {
+ Some(duration) } else { Some(self.default_duration) };
+
+ self.clear_at_time = match duration {
+ Some(duration) => Some(Utc::now() + duration),
+ None => None,
+ };
+ }
+
+ pub fn clear_status(&mut self) { self.current_message = None; }
+
+ pub fn get_status(&mut self) -> String {
+ if let Some(expiry_time) = self.clear_at_time {
+ if Utc::now() > expiry_time {
+ self.current_message = None;
+ self.clear_at_time = None;
+ };
+ };
+
+ match &self.current_message {
+ Some(string) => &string,
+ None => &self.default_message,
+ }.clone()
+ }
+}
\ No newline at end of file
--- /dev/null
+///! Terminal based interface and dashboard
+///!
+use std::collections::HashMap;
+
+use super::app::{DashState, LogMonitor, MmmStat, SUMMARY_WINDOW_NAME};
+
+use super::opt::{get_app_name, get_app_version};
+use super::ui::{
+ monetary_string, monetary_string_ant, push_blank, push_metric, push_price, push_subheading,
+ ATTOS_PER_ANT,
+};
+use super::web_requests::{BTC_TICKER, SAFE_TOKEN_TICKER};
+
+use ratatui::{
+ layout::{Constraint, Direction, Layout, Rect},
+ widgets::{Block, Borders, List, ListItem},
+ Frame,
+};
+struct SummaryStats {
+ node_count: u32,
+ active_node_count: u32,
+
+ storage_cost: MmmStat,
+ records: MmmStat,
+ earnings: MmmStat,
+ puts: MmmStat,
+ gets: MmmStat,
+ errors: MmmStat,
+ connections: MmmStat,
+ ram: MmmStat,
+}
+
+impl SummaryStats {
+ pub fn new(
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+ ) -> SummaryStats {
+ let mut summary_stats = SummaryStats {
+ node_count: 0,
+ active_node_count: 0,
+
+ storage_cost: MmmStat::new(),
+ records: MmmStat::new(),
+ earnings: MmmStat::new(),
+ puts: MmmStat::new(),
+ gets: MmmStat::new(),
+ errors: MmmStat::new(),
+ connections: MmmStat::new(),
+ ram: MmmStat::new(),
+ };
+
+ summary_stats.calculate_summary_stats(&dash_state, &monitors);
+ summary_stats
+ }
+
+ fn calculate_summary_stats(
+ &mut self,
+ _dash_state: &DashState,
+ monitors: &HashMap<String, LogMonitor>,
+ ) {
+ for entry in monitors.into_iter() {
+ let (_logfile, monitor) = entry;
+ if monitor.is_node() {
+ self.node_count += 1;
+ self.active_node_count += if monitor.metrics.is_node_active() {
+ 1
+ } else {
+ 0
+ };
+
+ self
+ .storage_cost
+ .add_sample(monitor.metrics.storage_cost.most_recent);
+ self.records.add_sample(monitor.metrics.records_stored);
+ self.earnings.add_sample(monitor.metrics.attos_earned.total);
+ self.puts.add_sample(monitor.metrics.activity_puts.total);
+ self.gets.add_sample(monitor.metrics.activity_gets.total);
+ self
+ .errors
+ .add_sample(monitor.metrics.activity_errors.total);
+ self
+ .connections
+ .add_sample(monitor.metrics.peers_connected.most_recent);
+ self
+ .ram
+ .add_sample(u64::from(monitor.metrics.memory_used_mb.most_recent));
+ }
+ }
+ }
+}
+
+pub fn draw_summary_dash(
+ f: &mut Frame,
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let constraints = [
+ Constraint::Length(13), // Summary statistics for all nodes
+ Constraint::Min(0), // Header above line of details for each node
+ ];
+
+ let chunks = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(constraints.as_ref())
+ .margin(1)
+ .split(f.size());
+
+ let summary_list_widget = Block::default().borders(Borders::ALL).title(format!(
+ "{} ({} v{}: {})",
+ String::from(SUMMARY_WINDOW_NAME),
+ get_app_name(),
+ get_app_version(),
+ &dash_state.vdash_status.get_status()
+ ));
+
+ f.render_widget(summary_list_widget, f.size());
+
+ draw_summary_stats_window(f, chunks[0], dash_state, monitors);
+ crate::custom::ui_summary_table::draw_summary_table_window(f, chunks[1], dash_state, monitors);
+}
+
+fn draw_summary_stats_window(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let constraints = [
+ Constraint::Length(81), // Summary Statistics Panel (left)
+ Constraint::Length(15), // Live Prices Panel (right)
+ ];
+
+ let chunks = Layout::default()
+ .direction(Direction::Horizontal)
+ .constraints(constraints.as_ref())
+ .split(area);
+
+ draw_summary_stats(f, chunks[0], dash_state, monitors);
+ draw_live_prices(f, chunks[1], dash_state, monitors);
+}
+
+fn draw_summary_stats(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let mut items = Vec::<ListItem>::new();
+
+ let ss = SummaryStats::new(dash_state, monitors);
+
+ let active_nodes_text = format!("{}/{}", ss.active_node_count, ss.node_count);
+ push_metric(&mut items, &"Active Nodes".to_string(), &active_nodes_text);
+
+ let units_text = if dash_state.ui_uses_currency {
+ ""
+ } else {
+ crate::custom::app_timelines::EARNINGS_UNITS_TEXT
+ };
+
+ push_subheading(
+ &mut items,
+ &String::from(
+ " Total min mean max ",
+ ),
+ );
+
+ let earnings_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ monetary_string_ant(dash_state, ss.earnings.total),
+ "ANT", //was ' {:<6}'
+ monetary_string_ant(dash_state, ss.earnings.min),
+ monetary_string_ant(dash_state, ss.earnings.mean),
+ monetary_string_ant(dash_state, ss.earnings.max)
+ );
+ let records_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ ss.records.total, "", ss.records.min, ss.records.mean, ss.records.max
+ );
+ let puts_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ ss.puts.total, "", ss.puts.min, ss.puts.mean, ss.puts.max
+ );
+ let gets_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ ss.gets.total, "", ss.gets.min, ss.gets.mean, ss.gets.max
+ );
+ let errors_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ ss.errors.total, "", ss.errors.min, ss.errors.mean, ss.errors.max
+ );
+
+ push_metric(&mut items, &"Earnings".to_string(), &earnings_text);
+ push_metric(&mut items, &"Records".to_string(), &records_text);
+ push_metric(&mut items, &"PUTS".to_string(), &puts_text);
+ push_metric(&mut items, &"GETS".to_string(), &gets_text);
+ push_metric(&mut items, &"ERRORS".to_string(), &errors_text);
+
+ push_blank(&mut items);
+ push_subheading(
+ &mut items,
+ &String::from(
+ " min mean max ",
+ ),
+ );
+ let storage_cost_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12} {}",
+ "-",
+ "",
+ monetary_string(dash_state, ss.storage_cost.min),
+ monetary_string(dash_state, ss.storage_cost.mean),
+ monetary_string(dash_state, ss.storage_cost.max),
+ units_text
+ );
+ let connections_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12}",
+ "-", "", ss.connections.min, ss.connections.mean, ss.connections.max
+ );
+ let ram_text = format!(
+ "{:>14} {:<6}{:>12} {:>12} {:>12} {}",
+ "-", "", ss.ram.min, ss.ram.mean, ss.ram.max, "MB"
+ );
+
+ push_metric(&mut items, &"Storage Cost".to_string(), &storage_cost_text);
+ push_metric(&mut items, &"Connections".to_string(), &connections_text);
+ push_metric(&mut items, &"RAM".to_string(), &ram_text);
+
+ let monitor_widget = List::new(items).block(Block::default());
+ f.render_widget(monitor_widget, area);
+}
+
+fn draw_live_prices(
+ f: &mut Frame,
+ area: Rect,
+ _dash_state: &mut DashState,
+ _monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let mut items = Vec::<ListItem>::new();
+
+ let mut constraints = [
+ Constraint::Length(3), // Live prices height (rows) for just one price
+ Constraint::Min(0), // Rest for remainder
+ ];
+
+ let prices = super::app::WEB_PRICES.lock().unwrap();
+ if let Some(snt_rate) = prices.snt_rate {
+ let value_text = format!("{}{:.2}", prices.currency_symbol, snt_rate);
+ push_price(&mut items, &SAFE_TOKEN_TICKER.to_string(), &value_text);
+
+ if let Some(btc_rate) = prices.btc_rate {
+ let btc_per_snt = snt_rate / btc_rate;
+ let btc_snt_text = format!("B{:.6}", btc_per_snt);
+ push_price(&mut items, &SAFE_TOKEN_TICKER.to_string(), &btc_snt_text);
+
+ let btc_currency_text = format!("{}{:.0}", prices.currency_symbol, btc_rate);
+ push_price(&mut items, &BTC_TICKER.to_string(), &btc_currency_text);
+
+ constraints = [
+ Constraint::Length(5), // Live prices height (rows) for three prices
+ Constraint::Min(0), // Rest for remainder
+ ];
+ }
+
+ let mut age_string = String::from("not available");
+ if let Some(last_update) = prices.last_update_time {
+ age_string = super::timelines::get_duration_text(chrono::Utc::now() - last_update);
+ }
+
+ let live_prices_title = format!("Prices ({})", age_string);
+ let items_widget = List::new(items).block(
+ Block::default()
+ .title(live_prices_title)
+ .borders(Borders::ALL),
+ );
+
+ let chunks = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(constraints.as_ref())
+ .margin(1)
+ .split(area);
+
+ f.render_widget(items_widget, chunks[0]);
+ }
+}
--- /dev/null
+use std::collections::HashMap;
+
+use super::app::{DashState, LogMonitor};
+use super::ui::{monetary_string, monetary_string_ant};
+
+use ratatui::{
+ layout::{Constraint, Direction, Layout, Rect},
+ style::{Color, Modifier, Style},
+ text::{Line, Span},
+ widgets::{Block, List, ListItem},
+ Frame,
+};
+
+use strfmt::{strfmt, strfmt_builder};
+
+#[derive(Copy, Clone)]
+pub enum NodeMetric {
+ Index,
+ StoragePayments,
+ StorageCost,
+ Records,
+ Puts,
+ Gets,
+ Errors,
+ Peers,
+ Memory,
+ Status,
+}
+
+pub const COLUMN_HEADERS: [(NodeMetric, &str, &str); 10] = [
+ // (node_metric, key/heading, format_string)
+ (NodeMetric::Index, "Node", "{index:>4} "),
+ (
+ NodeMetric::StoragePayments,
+ "Earnings",
+ "{storage_payments:>13} ",
+ ),
+ (NodeMetric::StorageCost, "StoreCost", "{storage_cost:>13} "),
+ (NodeMetric::Records, "Records", "{records_stored:>11} "),
+ (NodeMetric::Puts, "PUTS", "{puts:>11} "),
+ (NodeMetric::Gets, "GETS", "{gets:>11} "),
+ (NodeMetric::Errors, "Errors", "{errors:>11} "),
+ (NodeMetric::Peers, "Peers", "{connections:>7} "),
+ (NodeMetric::Memory, "MB RAM", "{memory:>7} "),
+ (NodeMetric::Status, "Status", " {status:<500} "),
+];
+
+pub fn sort_nodes_by_column(
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ use std::cmp::Ordering;
+
+ let sort_by = COLUMN_HEADERS[dash_state.summary_window_heading_selected].0;
+
+ // let logfile_with_focus = dash_state.logfile
+ dash_state.logfile_names_sorted.sort_by(|a, b| {
+ let mut ordering = Ordering::Equal;
+ if let Some(a) = monitors.get(a) {
+ if let Some(b) = monitors.get(b) {
+ ordering = match sort_by {
+ NodeMetric::Index => a.index.cmp(&b.index),
+ NodeMetric::StoragePayments => a
+ .metrics
+ .attos_earned
+ .total
+ .cmp(&b.metrics.attos_earned.total),
+ NodeMetric::StorageCost => a
+ .metrics
+ .storage_cost
+ .most_recent
+ .cmp(&b.metrics.storage_cost.most_recent),
+ NodeMetric::Records => a.metrics.records_stored.cmp(&b.metrics.records_stored),
+ NodeMetric::Puts => a
+ .metrics
+ .activity_puts
+ .total
+ .cmp(&b.metrics.activity_puts.total),
+ NodeMetric::Gets => a
+ .metrics
+ .activity_gets
+ .total
+ .cmp(&b.metrics.activity_gets.total),
+ NodeMetric::Errors => a
+ .metrics
+ .activity_errors
+ .total
+ .cmp(&b.metrics.activity_errors.total),
+ NodeMetric::Peers => a
+ .metrics
+ .peers_connected
+ .most_recent
+ .cmp(&b.metrics.peers_connected.most_recent),
+ NodeMetric::Memory => a
+ .metrics
+ .memory_used_mb
+ .most_recent
+ .cmp(&b.metrics.memory_used_mb.most_recent),
+ NodeMetric::Status => a
+ .metrics
+ .node_status_string
+ .cmp(&b.metrics.node_status_string),
+ }
+ }
+ };
+ if dash_state.logfile_names_sorted_ascending {
+ ordering
+ } else {
+ ordering.reverse()
+ }
+ });
+}
+
+pub fn format_table_row(dash_state: &DashState, monitor: &mut LogMonitor) -> String {
+ let mut row_text = String::from("");
+
+ for i in 0..COLUMN_HEADERS.len() {
+ let (metric, _heading, format_string) = &COLUMN_HEADERS[i];
+ row_text += &match metric {
+ NodeMetric::Index => { strfmt!(format_string, index => monitor.index + 1).unwrap() },
+ NodeMetric::StoragePayments => { strfmt!(format_string, storage_payments => monetary_string_ant(dash_state, monitor.metrics.attos_earned.total)).unwrap() },
+ NodeMetric::StorageCost => { strfmt!(format_string, storage_cost => monetary_string(dash_state, monitor.metrics.storage_cost.most_recent)).unwrap() },
+ NodeMetric::Records => { strfmt!(format_string, records_stored => monitor.metrics.records_stored).unwrap() },
+ NodeMetric::Puts => { strfmt!(format_string, puts => monitor.metrics.activity_puts.total).unwrap() },
+ NodeMetric::Gets => { strfmt!(format_string, gets => monitor.metrics.activity_gets.total).unwrap() },
+ NodeMetric::Errors => { strfmt!(format_string, errors => monitor.metrics.activity_errors.total).unwrap() },
+ NodeMetric::Peers => { strfmt!(format_string, connections => monitor.metrics.peers_connected.most_recent).unwrap() },
+ NodeMetric::Memory => { strfmt!(format_string, memory => monitor.metrics.memory_used_mb.most_recent).unwrap() },
+ NodeMetric::Status => { strfmt!(format_string, status => monitor.metrics.node_status_string.clone()).unwrap() },
+ };
+ }
+
+ row_text
+}
+
+pub fn draw_summary_table_window(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let constraints = [
+ Constraint::Length(1), // Heading
+ Constraint::Min(0), // List
+ ];
+
+ let chunks = Layout::default()
+ .direction(Direction::Vertical)
+ .constraints(constraints.as_ref())
+ .split(area);
+
+ draw_summary_headings(f, chunks[0], dash_state, monitors);
+ draw_summary_rows(f, chunks[1], dash_state, monitors);
+}
+
+pub fn initialise_summary_headings(dash_state: &mut DashState) {
+ for i in 0..COLUMN_HEADERS.len() {
+ let (metric, heading, format_string) = &COLUMN_HEADERS[i];
+ dash_state.summary_window_headings.items.push(match metric {
+ NodeMetric::Index => strfmt!(format_string, index => *heading).unwrap(),
+ NodeMetric::StoragePayments => strfmt!(format_string, storage_payments => *heading).unwrap(),
+ NodeMetric::StorageCost => strfmt!(format_string, storage_cost => *heading).unwrap(),
+ NodeMetric::Records => strfmt!(format_string, records_stored => *heading).unwrap(),
+ NodeMetric::Puts => strfmt!(format_string, puts => *heading).unwrap(),
+ NodeMetric::Gets => strfmt!(format_string, gets => *heading).unwrap(),
+ NodeMetric::Errors => strfmt!(format_string, errors => *heading).unwrap(),
+ NodeMetric::Peers => strfmt!(format_string, connections => *heading).unwrap(),
+ NodeMetric::Memory => strfmt!(format_string, memory => *heading).unwrap(),
+ NodeMetric::Status => strfmt!(format_string, status => *heading).unwrap(),
+ });
+ }
+}
+
+fn draw_summary_headings(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ _monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let heading_style = Style::default().fg(Color::White).bg(Color::Black);
+ let highlight_style = Style::default()
+ .bg(Color::LightGreen)
+ .add_modifier(Modifier::BOLD);
+
+ let mut index = 0;
+ let spans: Vec<Span> = dash_state
+ .summary_window_headings
+ .items
+ .iter()
+ .map(|s| {
+ Span::styled(
+ s.clone(),
+ if dash_state.summary_window_heading_selected != index {
+ index += 1;
+ heading_style
+ } else {
+ index += 1;
+ highlight_style
+ },
+ )
+ })
+ .collect();
+
+ let summary_header_widget = List::new(vec![ListItem::new(vec![Line::from(spans)])])
+ .block(Block::default())
+ .highlight_style(highlight_style);
+
+ f.render_widget(summary_header_widget, area);
+}
+
+fn draw_summary_rows(
+ f: &mut Frame,
+ area: Rect,
+ dash_state: &mut DashState,
+ _monitors: &mut HashMap<String, LogMonitor>,
+) {
+ let highlight_style = Style::default()
+ .bg(Color::LightGreen)
+ .add_modifier(Modifier::BOLD);
+
+ let items: Vec<ListItem> = dash_state
+ .summary_window_rows
+ .items
+ .iter()
+ .map(|s| ListItem::new(vec![Line::from(s.clone())]).style(Style::default().fg(Color::White)))
+ .collect();
+
+ let summary_window_widget = List::new(items)
+ .block(Block::default())
+ .highlight_style(highlight_style);
+
+ f.render_stateful_widget(
+ summary_window_widget,
+ area,
+ &mut dash_state.summary_window_rows.state,
+ );
+}
--- /dev/null
+use chrono::{DateTime, Duration, Utc};
+use serde_json::Value;
+
+pub struct WebPrices {
+ pub snt_rate: Option<f64>, // Currency value per SNT (e.g. 0.20)
+ pub btc_rate: Option<f64>, // Currency value per BTC
+
+ pub currency_apiname: String, // For API query (e.g. "USD")
+ pub currency_symbol: String, // For UI (e.g. "$")
+
+ pub last_update_time: Option<DateTime<Utc>>,
+}
+
+impl WebPrices {
+ pub fn new() -> WebPrices {
+ WebPrices {
+ snt_rate: None,
+ btc_rate: None,
+
+ currency_apiname: String::from(""),
+ currency_symbol: String::from(""),
+
+ last_update_time: None,
+ }
+ }
+}
+
+const DEFAULT_COINGECKO_POLL_INTERVAL: i64 = 30; // Minutes (based on free account)
+const DEFAULT_COINMARKETCAP_POLL_INTERVAL: i64 = 30; // Minutes (based on free account)
+const DEFAULT_SWITCH_API_POLL_INTERVAL: i64 = 5; // Minutes to wait after switching API
+
+pub struct WebPriceAPIs {
+ currency_apiname: String, // For API query (e.g. "USD")
+
+ current_api_key: Option<String>,
+ switching_api_interval: Duration,
+
+ // CoinGecko
+ coingecko_api_key: Option<String>,
+ coingecko_next_poll: Option<DateTime<Utc>>,
+ coingecko_min_poll_interval: Duration,
+
+ // CoinMarketCap Configuration
+ coinmarketcap_api_key: Option<String>,
+ coinmarketcap_next_poll: Option<DateTime<Utc>>,
+ coinmarketcap_min_poll_interval: Duration,
+}
+
+pub const CMC_API_SAFE_TOKEN_NAME: &str = "EMAID"; // Coinmarketcap API
+
+// For vdash UI:
+pub const SAFE_TOKEN_TICKER: &str = "SNT";
+pub const BTC_TICKER: &str = "BTC";
+
+impl WebPriceAPIs {
+ pub fn new(
+ coingecko_api_key: Option<String>,
+ coinmarketcap_api_key: Option<String>,
+ currency_apiname: &String,
+ ) -> WebPriceAPIs {
+ WebPriceAPIs {
+ currency_apiname: currency_apiname.clone(),
+
+ current_api_key: None,
+ switching_api_interval: Duration::seconds(DEFAULT_SWITCH_API_POLL_INTERVAL),
+
+ coingecko_api_key: coingecko_api_key,
+ coingecko_next_poll: None,
+ coingecko_min_poll_interval: Duration::minutes(DEFAULT_COINGECKO_POLL_INTERVAL),
+
+ coinmarketcap_api_key: coinmarketcap_api_key,
+ coinmarketcap_next_poll: None,
+ coinmarketcap_min_poll_interval: Duration::minutes(DEFAULT_COINMARKETCAP_POLL_INTERVAL),
+ }
+ }
+
+ /// Call one of up to two web apis to get prices. Uses a minimum poll interval to
+ /// avoid excessive use of the metered APIs and avoid slowing down other threads.
+ ///
+ /// If the default API fails to return a value, switches to using the alternate API
+ /// for the next cycle (setting a shorter interval for the retry).
+ ///
+ /// Returns the currency_per_token rate if successful
+ pub async fn handle_web_requests(&mut self) -> Result<Option<f64>, Box<dyn std::error::Error>> {
+ let now = Utc::now();
+
+ let mut currency_token_rate = None;
+ if self.coingecko_api_key.is_some() {
+ if self.current_api_key.is_none()
+ || self.current_api_key.as_ref().unwrap() == self.coingecko_api_key.as_ref().unwrap()
+ {
+ if self.coingecko_next_poll.is_none() || self.coingecko_next_poll.unwrap() < now {
+ self.coingecko_next_poll = Some(now + self.coingecko_min_poll_interval);
+ currency_token_rate = self.get_coingecko_prices().await?;
+
+ if currency_token_rate.is_some() {
+ self.current_api_key = Some(self.coingecko_api_key.as_ref().unwrap().clone());
+ } else if self.coinmarketcap_api_key.is_some() {
+ self.coinmarketcap_next_poll = Some(now + self.switching_api_interval);
+ self.current_api_key = Some(self.coinmarketcap_api_key.as_ref().unwrap().clone());
+ }
+ }
+ }
+ }
+
+ if self.coinmarketcap_api_key.is_some() {
+ if self.current_api_key.is_none()
+ || self.current_api_key.as_ref().unwrap() == self.coinmarketcap_api_key.as_ref().unwrap()
+ {
+ if self.coinmarketcap_next_poll.is_none() || self.coinmarketcap_next_poll.unwrap() < now {
+ self.coinmarketcap_next_poll = Some(now + self.coinmarketcap_min_poll_interval);
+ currency_token_rate = self.get_coinmarketcap_prices().await?;
+
+ if currency_token_rate.is_some() {
+ self.current_api_key = Some(self.coinmarketcap_api_key.as_ref().unwrap().clone());
+ } else if self.coingecko_api_key.is_some() {
+ self.coingecko_next_poll = Some(now + self.switching_api_interval);
+ self.current_api_key = Some(self.coingecko_api_key.as_ref().unwrap().clone());
+ }
+ }
+ }
+ }
+
+ Ok(currency_token_rate)
+ }
+
+ // Access price via API, lock the WebPrices object and store the new values
+ // Returns the currency_per_token rate if successful
+ pub async fn get_coingecko_prices(&mut self) -> Result<Option<f64>, Box<dyn std::error::Error>> {
+ if let Some(api_key) = &self.coingecko_api_key {
+ let client = reqwest::Client::new();
+ let url = "https://api.coingecko.com/api/v3/simple/price";
+ let response = client
+ .get(url)
+ .header("x-cg-demo-api-key", api_key)
+ .query(&[
+ ("ids", "maidsafecoin,bitcoin"),
+ (
+ "vs_currencies",
+ &format!("{}", self.currency_apiname).to_lowercase(),
+ ),
+ ])
+ .send()
+ .await?;
+
+ let body = response.text().await?;
+ let json = serde_json::from_str::<Value>(&body)?;
+ let mut prices = super::app::WEB_PRICES.lock()?;
+ let time_now = Some(Utc::now());
+ if let Some(btcprices) = json["bitcoin"].as_object() {
+ let currency_key = &self.currency_apiname.as_str().to_lowercase();
+ if !btcprices.contains_key(currency_key) {
+ let message = format!(
+ "unrecognised API value for --currency-apiname option: {}",
+ &self.currency_apiname.as_str()
+ );
+ return Err(Box::new(std::io::Error::new(
+ std::io::ErrorKind::Other,
+ message.as_str(),
+ )));
+ }
+
+ prices.btc_rate = btcprices[self.currency_apiname.to_lowercase().as_str()].as_f64();
+ }
+ if let Some(token_prices) = json["maidsafecoin"].as_object() {
+ prices.snt_rate = token_prices[self.currency_apiname.to_lowercase().as_str()].as_f64();
+ prices.last_update_time = time_now;
+ return Ok(prices.snt_rate);
+ }
+ }
+
+ Ok(None)
+ }
+
+ // Access price via API, lock the WebPrices object and store the new values
+ // Returns the currency_per_token rate if successful
+ pub async fn get_coinmarketcap_prices(
+ &mut self,
+ ) -> Result<Option<f64>, Box<dyn std::error::Error>> {
+ let mut currency_per_token = None;
+ let mut error = None;
+
+ if let Some(api_key) = &self.coinmarketcap_api_key {
+ let response: reqwest::Response = reqwest::Client::builder()
+ .build()?
+ .get("https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest")
+ .header("X-CMC_PRO_API_KEY", api_key)
+ .header("Accept", "application/json")
+ .query(&[
+ ("symbol", CMC_API_SAFE_TOKEN_NAME),
+ ("convert", self.currency_apiname.as_str()),
+ ])
+ .send()
+ .await?;
+
+ let body = response.text().await?;
+ let json = serde_json::from_str::<Value>(&body)?;
+
+ let _ = json["data"].as_object().is_some_and(|data| {
+ data["EMAID"].as_array().is_some_and(|emaid| {
+ emaid[0].as_object().is_some_and(|emaid_0| {
+ emaid_0["quote"].as_object().is_some_and(|quote| {
+ let currency_key = &self.currency_apiname.as_str().to_uppercase();
+ if !quote.contains_key(currency_key) {
+ let message = format!(
+ "unrecognised API value for --currency-apiname option: {}",
+ &self.currency_apiname.as_str()
+ );
+ error = Some(std::io::Error::new(
+ std::io::ErrorKind::Other,
+ message.as_str(),
+ ));
+ return false;
+ }
+ quote[currency_key].as_object().is_some_and(|usd| {
+ usd["price"].as_f64().is_some_and(|token_price| {
+ let mut prices = super::app::WEB_PRICES.lock().unwrap();
+ prices.snt_rate = Some(token_price);
+ prices.last_update_time = Some(Utc::now());
+ currency_per_token = Some(token_price);
+ true
+ })
+ })
+ })
+ })
+ })
+ });
+ }
+
+ if error.is_some() {
+ return Err(Box::new(error.unwrap()));
+ }
+
+ Ok(currency_per_token)
+ }
+}
--- /dev/null
+#![allow(dead_code)]
+use std::io;
+use std::sync::{
+ atomic::{AtomicBool, Ordering},
+ Arc,
+};
+use std::thread;
+use std::time::Duration;
+use tokio::sync::mpsc;
+
+pub enum Event<I> {
+ Input(I),
+ Tick,
+}
+
+/// A small event handler that wrap termion input and tick events. Each event
+/// type is handled in its own thread and returned to a common `Receiver`
+pub struct Events {
+ pub rx: mpsc::UnboundedReceiver<Event<Key>>,
+ input_handle: thread::JoinHandle<()>,
+ ignore_exit_key: Arc<AtomicBool>,
+ tick_handle: thread::JoinHandle<()>,
+}
+
+#[derive(Debug, Clone, Copy)]
+pub struct Config {
+ pub exit_key: Key,
+ pub tick_rate: Duration,
+}
+
+impl Default for Config {
+ fn default() -> Config {
+ Config {
+ exit_key: Key::Char('q'),
+ tick_rate: Duration::from_millis(250),
+ }
+ }
+}
+
+impl Events {
+ pub fn new() -> Events {
+ Events::with_config(Config::default())
+ }
+
+ pub fn with_config(config: Config) -> Events {
+ let (tx, rx) = mpsc::unbounded_channel();
+ let ignore_exit_key = Arc::new(AtomicBool::new(false));
+ let input_handle = {
+ let tx = tx.clone();
+ let ignore_exit_key = ignore_exit_key.clone();
+ thread::spawn(move || {
+ let stdin = io::stdin();
+ for evt in stdin.keys() {
+ if let Ok(key) = evt {
+ if let Err(err) = tx.send(Event::Input(key)) {
+ eprintln!("{}", err);
+ return;
+ }
+ if !ignore_exit_key.load(Ordering::Relaxed) && key == config.exit_key {
+ return;
+ }
+ }
+ }
+ })
+ };
+ let tick_handle = {
+ thread::spawn(move || loop {
+ if tx.send(Event::Tick).is_err() {
+ break;
+ }
+ thread::sleep(config.tick_rate);
+ })
+ };
+ Events {
+ rx,
+ ignore_exit_key,
+ input_handle,
+ tick_handle,
+ }
+ }
+
+ pub fn disable_exit_key(&mut self) {
+ self.ignore_exit_key.store(true, Ordering::Relaxed);
+ }
+
+ pub fn enable_exit_key(&mut self) {
+ self.ignore_exit_key.store(false, Ordering::Relaxed);
+ }
+}
--- /dev/null
+pub mod util;
--- /dev/null
+use rand::distributions::{Distribution, Uniform};
+use rand::rngs::ThreadRng;
+use ratatui::widgets::ListState;
+
+#[derive(Clone)]
+pub struct RandomSignal {
+ distribution: Uniform<u64>,
+ rng: ThreadRng,
+}
+
+impl RandomSignal {
+ pub fn new(lower: u64, upper: u64) -> RandomSignal {
+ RandomSignal {
+ distribution: Uniform::new(lower, upper),
+ rng: rand::thread_rng(),
+ }
+ }
+}
+
+impl Iterator for RandomSignal {
+ type Item = u64;
+ fn next(&mut self) -> Option<u64> {
+ Some(self.distribution.sample(&mut self.rng))
+ }
+}
+
+#[derive(Clone)]
+pub struct SinSignal {
+ x: f64,
+ interval: f64,
+ period: f64,
+ scale: f64,
+}
+
+impl SinSignal {
+ pub fn new(interval: f64, period: f64, scale: f64) -> SinSignal {
+ SinSignal {
+ x: 0.0,
+ interval,
+ period,
+ scale,
+ }
+ }
+}
+
+impl Iterator for SinSignal {
+ type Item = (f64, f64);
+ fn next(&mut self) -> Option<Self::Item> {
+ let point = (self.x, (self.x * 1.0 / self.period).sin() * self.scale);
+ self.x += self.interval;
+ Some(point)
+ }
+}
+
+pub struct TabsState<'a> {
+ pub titles: Vec<&'a str>,
+ pub index: usize,
+}
+
+impl<'a> TabsState<'a> {
+ pub fn new(titles: Vec<&'a str>) -> TabsState {
+ TabsState { titles, index: 0 }
+ }
+ pub fn next(&mut self) {
+ self.index = (self.index + 1) % self.titles.len();
+ }
+
+ pub fn previous(&mut self) {
+ if self.index > 0 {
+ self.index -= 1;
+ } else {
+ self.index = self.titles.len() - 1;
+ }
+ }
+}
+
+pub struct StatefulList<T> {
+ pub state: ListState,
+ pub items: Vec<T>,
+}
+
+impl<T> StatefulList<T> {
+ pub fn new() -> StatefulList<T> {
+ StatefulList {
+ state: ListState::default(),
+ items: Vec::new(),
+ }
+ }
+
+ pub fn with_items(items: Vec<T>) -> StatefulList<T> {
+ StatefulList {
+ state: ListState::default(),
+ items,
+ }
+ }
+
+ pub fn next(&mut self) {
+ let i = match self.state.selected() {
+ Some(i) => {
+ if i >= self.items.len() - 1 {
+ 0
+ } else {
+ i + 1
+ }
+ }
+ None => 0,
+ };
+ self.state.select(Some(i));
+ }
+
+ pub fn previous(&mut self) {
+ let i = match self.state.selected() {
+ Some(i) => {
+ if i == 0 {
+ self.items.len() - 1
+ } else {
+ i - 1
+ }
+ }
+ None => 0,
+ };
+ self.state.select(Some(i));
+ }
+
+ pub fn unselect(&mut self) {
+ self.state.select(None);
+ }
+}
--- /dev/null
+use ratatui::{
+ buffer::Buffer,
+ layout::Rect,
+ style::{Color, Style},
+ text::Span,
+ widgets::{Block, Widget},
+};
+
+/// A widget to display a task progress.
+///
+/// Note: Gauge requires minimum height of 2, Gauge2 has been modified to work with
+/// a height of 1
+///
+/// # Examples:
+///
+/// ```
+/// # use ratatui::widgets::{Widget, Gauge2, Block, Borders};
+/// # use ratatui::style::{Style, Color, Modifier};
+/// Gauge2::default()
+/// .block(Block::default().borders(Borders::ALL).title("Progress"))
+/// .gauge_style(Style::default().fg(Color::White).bg(Color::Black).add_modifier(Modifier::ITALIC))
+/// .percent(20);
+/// ```
+#[derive(Debug, Clone)]
+pub struct Gauge2<'a> {
+ block: Option<Block<'a>>,
+ ratio: f64,
+ label: Option<Span<'a>>,
+ style: Style,
+ gauge_style: Style,
+}
+
+impl<'a> Default for Gauge2<'a> {
+ fn default() -> Gauge2<'a> {
+ Gauge2 {
+ block: None,
+ ratio: 0.0,
+ label: None,
+ style: Style::default(),
+ gauge_style: Style::default(),
+ }
+ }
+}
+
+impl<'a> Gauge2<'a> {
+ pub fn block(mut self, block: Block<'a>) -> Gauge2<'a> {
+ self.block = Some(block);
+ self
+ }
+
+ pub fn percent(mut self, percent: u16) -> Gauge2<'a> {
+ assert!(
+ percent <= 100,
+ "Percentage should be between 0 and 100 inclusively."
+ );
+ self.ratio = f64::from(percent) / 100.0;
+ self
+ }
+
+ /// Sets ratio ([0.0, 1.0]) directly.
+ pub fn ratio(mut self, ratio: f64) -> Gauge2<'a> {
+ assert!(
+ ratio <= 1.0 && ratio >= 0.0,
+ "{}", format!("Ratio ({}) should be between 0 and 1 inclusively.", ratio).to_string()
+ );
+ self.ratio = ratio;
+ self
+ }
+
+ pub fn label<T>(mut self, label: T) -> Gauge2<'a>
+ where
+ T: Into<Span<'a>>,
+ {
+ self.label = Some(label.into());
+ self
+ }
+
+ pub fn style(mut self, style: Style) -> Gauge2<'a> {
+ self.style = style;
+ self
+ }
+
+ pub fn gauge_style(mut self, style: Style) -> Gauge2<'a> {
+ self.gauge_style = style;
+ self
+ }
+}
+
+impl<'a> Widget for Gauge2<'a> {
+ fn render(mut self, area: Rect, buf: &mut Buffer) {
+ buf.set_style(area, self.style);
+ let gauge_area = match self.block.take() {
+ Some(b) => {
+ let mut inner_area = b.inner(area);
+ if area.height == 1 {
+ inner_area = area;
+ }
+ b.render(area, buf);
+ inner_area
+ }
+ None => area,
+ };
+ buf.set_style(gauge_area, self.gauge_style);
+ if gauge_area.height < 1 {
+ return;
+ }
+
+ let mut center = gauge_area.height / 2 + gauge_area.top();
+ if gauge_area.height < 1 {
+ center = gauge_area.height + gauge_area.top();
+ };
+
+ let width = (f64::from(gauge_area.width) * self.ratio).round() as u16;
+ let end = gauge_area.left() + width;
+ // Label
+ let ratio = self.ratio;
+ let label = self
+ .label
+ .unwrap_or_else(|| Span::from(format!("{}%", (ratio * 100.0).round())));
+
+ for y in gauge_area.top()..gauge_area.bottom() {
+ // Gauge2
+ for x in gauge_area.left()..end {
+ buf.get_mut(x, y).set_symbol(" ");
+ }
+
+ if y == center {
+ let label_width = label.width() as u16;
+ let middle = (gauge_area.width - label_width) / 2 + gauge_area.left();
+ buf.set_span(middle, y, &label, gauge_area.right() - middle);
+ }
+
+ // Fix colors
+ for x in gauge_area.left()..end {
+ buf.get_mut(x, y)
+ .set_fg(self.gauge_style.bg.unwrap_or(Color::Reset))
+ .set_bg(self.gauge_style.fg.unwrap_or(Color::Reset));
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ #[should_panic]
+ fn gauge_invalid_percentage() {
+ Gauge2::default().percent(110);
+ }
+
+ #[test]
+ #[should_panic]
+ fn gauge_invalid_ratio_upper_bound() {
+ Gauge2::default().ratio(1.1);
+ }
+
+ #[test]
+ #[should_panic]
+ fn gauge_invalid_ratio_lower_bound() {
+ Gauge2::default().ratio(-0.5);
+ }
+}
--- /dev/null
+pub mod gauge;
+pub mod sparkline;
--- /dev/null
+use std::cmp::min;
+use ratatui::{
+ buffer::Buffer,
+ layout::Rect,
+ style::Style,
+ symbols,
+ widgets::{Block, Widget},
+};
+
+/// Widget to render a sparkline over one or more lines.
+///
+/// Based on ratatui::widgets::Sparkline, but with origin
+/// on right hand edge.
+#[derive(Debug, Clone)]
+pub struct Sparkline2<'a> {
+ /// A block to wrap the widget in
+ block: Option<Block<'a>>,
+ /// Widget style
+ style: Style,
+ /// A slice of the data to display
+ data: &'a [u64],
+ /// The maximum value to take to compute the maximum bar height (if nothing is specified, the
+ /// widget uses the max of the dataset)
+ max: Option<u64>,
+ /// A set of bar symbols used to represent the give data
+ bar_set: symbols::bar::Set,
+}
+
+impl<'a> Default for Sparkline2<'a> {
+ fn default() -> Sparkline2<'a> {
+ Sparkline2 {
+ block: None,
+ style: Default::default(),
+ data: &[],
+ max: None,
+ bar_set: symbols::bar::NINE_LEVELS,
+ }
+ }
+}
+
+impl<'a> Sparkline2<'a> {
+ pub fn block(mut self, block: Block<'a>) -> Sparkline2<'a> {
+ self.block = Some(block);
+ self
+ }
+
+ pub fn style(mut self, style: Style) -> Sparkline2<'a> {
+ self.style = style;
+ self
+ }
+
+ pub fn data(mut self, data: &'a [u64]) -> Sparkline2<'a> {
+ self.data = data;
+ self
+ }
+
+ pub fn max(mut self, max: u64) -> Sparkline2<'a> {
+ self.max = Some(max);
+ self
+ }
+
+ pub fn bar_set(mut self, bar_set: symbols::bar::Set) -> Sparkline2<'a> {
+ self.bar_set = bar_set;
+ self
+ }
+}
+
+impl<'a> Widget for Sparkline2<'a> {
+ fn render(mut self, area: Rect, buf: &mut Buffer) {
+ let spark_area = match self.block.take() {
+ Some(b) => {
+ let inner_area = b.inner(area);
+ b.render(area, buf);
+ inner_area
+ }
+ None => area,
+ };
+
+ if spark_area.height < 1 {
+ return;
+ }
+
+ let max = match self.max {
+ Some(v) => v,
+ None => *self.data.iter().max().unwrap_or(&1u64),
+ };
+ let max_index = min(spark_area.width as usize, self.data.len());
+ let mut data = self
+ .data
+ .iter()
+ .take(max_index)
+ .map(|e| {
+ if max != 0 {
+ e * u64::from(spark_area.height) * 8 / max
+ } else {
+ 0
+ }
+ })
+ .collect::<Vec<u64>>();
+ for j in (0..spark_area.height).rev() {
+ for (i, d) in data.iter_mut().enumerate() {
+ let symbol = match *d {
+ 0 => self.bar_set.empty,
+ 1 => self.bar_set.one_eighth,
+ 2 => self.bar_set.one_quarter,
+ 3 => self.bar_set.three_eighths,
+ 4 => self.bar_set.half,
+ 5 => self.bar_set.five_eighths,
+ 6 => self.bar_set.three_quarters,
+ 7 => self.bar_set.seven_eighths,
+ _ => self.bar_set.full,
+ };
+ buf.get_mut(spark_area.left() + i as u16, spark_area.top() + j)
+ .set_symbol(symbol)
+ .set_style(self.style);
+
+ if *d > 8 {
+ *d -= 8;
+ } else {
+ *d = 0;
+ }
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn it_does_not_panic_if_max_is_zero() {
+ let widget = Sparkline2::default().data(&[0, 0, 0]);
+ let area = Rect::new(0, 0, 3, 1);
+ let mut buffer = Buffer::empty(area);
+ widget.render(area, &mut buffer);
+ }
+
+ #[test]
+ fn it_does_not_panic_if_max_is_set_to_zero() {
+ let widget = Sparkline2::default().data(&[0, 1, 2]).max(0);
+ let area = Rect::new(0, 0, 3, 1);
+ let mut buffer = Buffer::empty(area);
+ widget.render(area, &mut buffer);
+ }
+}