refactor: centralize constants, eliminate unwraps, remove dead code, resolve TODOs

- R13+R16: Replace .expect() with .context()? in main.rs and identity.rs
- R17+R18+R19: Fix unwrap() calls in helpers and js-engine
- R20+R21: Remove #[allow(dead_code)] annotations and delete truly dead code
- R22-R26: Create constants.rs module, replace 21 hardcoded values across 12 files
- R28+R29: LND/DWN timeouts already present — verified
- R30-R33: Remove TODO comments, implement marketplace payment check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-21 01:54:35 +00:00
parent 5c3a3ffa8e
commit f3976ba03a
22 changed files with 113 additions and 104 deletions

View File

@@ -7,7 +7,6 @@ use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::sync::{Mutex, OnceLock};
const TOR_SOCKS: &str = "socks5h://127.0.0.1:9050";
const MAX_STORED: usize = 200;
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -263,7 +262,7 @@ pub async fn send_to_peer(
"encrypted": encrypted,
});
let proxy = reqwest::Proxy::all(TOR_SOCKS).context("Invalid Tor proxy")?;
let proxy = reqwest::Proxy::all(crate::constants::TOR_SOCKS_PROXY).context("Invalid Tor proxy")?;
let client = reqwest::Client::builder()
.proxy(proxy)
.timeout(std::time::Duration::from_secs(60))
@@ -306,7 +305,7 @@ pub async fn check_peer_reachable(onion: &str) -> Result<bool> {
format!("{}.onion", onion)
};
let url = format!("http://{}/health", host);
let proxy = reqwest::Proxy::all(TOR_SOCKS).context("Invalid Tor proxy")?;
let proxy = reqwest::Proxy::all(crate::constants::TOR_SOCKS_PROXY).context("Invalid Tor proxy")?;
let client = reqwest::Client::builder()
.proxy(proxy)
.timeout(std::time::Duration::from_secs(30))