From 532747c37286589452350800d27c802102fde919 Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Sun, 29 Dec 2024 10:19:42 +0100 Subject: [PATCH] feat: Windows get size of Node BD from rpc, reduce code --- src/helper/node.rs | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/src/helper/node.rs b/src/helper/node.rs index 15bb7a6..606633c 100644 --- a/src/helper/node.rs +++ b/src/helper/node.rs @@ -415,36 +415,12 @@ impl PrivNodeApi { state: &Node, ) -> std::result::Result { let adr = format!("http://{}:{}/json_rpc", state.api_ip, state.api_port); - #[cfg(target_os = "windows")] - let mut private = client + Ok(client .post(adr) .body(r#"{"jsonrpc":"2.0","id":"0","method":"get_info"}"#) .send() .await? .json::() - .await?; - #[cfg(not(target_os = "windows"))] - let private = client - .post(adr) - .body(r#"{"jsonrpc":"2.0","id":"0","method":"get_info"}"#) - .send() - .await? - .json::() - .await?; - #[cfg(target_os = "windows")] - // api returns 0 for DB size for Windows so we read the size directly from the filesystem. - // https://github.com/monero-project/monero/issues/9513 - { - if let Ok(metadata) = std::fs::metadata(if !state.path_db.is_empty() { - let mut path_db = std::path::PathBuf::from(&state.path_db); - path_db.push("lmdb/data.mdb"); - path_db.to_str().unwrap().to_string() - } else { - r#"C:\ProgramData\bitmonero\lmdb\data.mdb"#.to_string() - }) { - private.result.database_size = metadata.file_size(); - } - } - Ok(private) + .await?) } }