feat: Node: fast mode support

feat: enable fast mode in simple mode if available memory > 4GB
feat: Node tab advanced sublenu add checkbox to enable fast mode
This commit is contained in:
Cyrix126 2025-02-07 22:14:06 +01:00
parent 920287b7fd
commit ef693d2549
4 changed files with 18 additions and 1 deletions
src
app/panels/middle
disk
helper
utils

View file

@ -20,7 +20,7 @@ use crate::app::panels::middle::common::header_tab::header_tab;
use crate::app::panels::middle::common::state_edit_field::{path_db_field, slider_state_field};
use crate::app::panels::middle::{rpc_bind_field, rpc_port_field, zmq_bind_field, zmq_port_field};
use crate::{
NODE_DNS_BLOCKLIST, NODE_DNS_CHECKPOINT, NODE_INPUT, NODE_PRUNNING, NODE_URL,
NODE_DNS_BLOCKLIST, NODE_DNS_CHECKPOINT, NODE_FULL_MEM, NODE_INPUT, NODE_PRUNNING, NODE_URL,
START_OPTIONS_HOVER,
};
use egui::TextStyle;
@ -99,6 +99,9 @@ impl Node {
ui.separator();
ui.checkbox(&mut self.disable_dns_checkpoint, "DNS checkpoint")
.on_hover_text(NODE_DNS_CHECKPOINT);
ui.separator();
ui.checkbox(&mut self.full_memory, "Fast Mode")
.on_hover_text(NODE_FULL_MEM);
});
});

View file

@ -338,6 +338,7 @@ pub struct Node {
pub dns_blocklist: bool,
pub disable_dns_checkpoint: bool,
pub path_db: String,
pub full_memory: bool,
pub console_height: u32,
}
@ -357,6 +358,7 @@ impl Default for Node {
dns_blocklist: true,
disable_dns_checkpoint: true,
path_db: String::new(),
full_memory: false,
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}

View file

@ -28,6 +28,7 @@ use std::{
thread,
time::{Duration, Instant},
};
use sysinfo::MemoryRefreshKind;
use tokio::spawn;
use crate::{
@ -239,6 +240,16 @@ impl Helper {
debug!("Node | Creating command...");
let mut cmd = portable_pty::cmdbuilder::CommandBuilder::new(path.clone());
cmd.args(args);
// if in simple state and enough free memory, enable full memory env
if state.simple {
let mut sys = sysinfo::System::new();
sys.refresh_memory_specifics(MemoryRefreshKind::nothing().with_ram());
if sys.available_memory() > 4_000_000_000 {
cmd.env("MONERO_RANDOMX_FULL_MEM", "1");
}
} else if state.full_memory {
cmd.env("MONERO_RANDOMX_FULL_MEM", "1");
}
cmd.cwd(path.as_path().parent().unwrap());
// 1c. Create child
debug!("Node | Creating child...");

View file

@ -476,6 +476,7 @@ pub const NODE_API_BIND: &str = "bind address of RPC API";
pub const NODE_API_PORT: &str = "RPC API listen port";
pub const NODE_ZMQ_BIND: &str = "bind address of ZMQ API";
pub const NODE_ZMQ_PORT: &str = "ZMQ API listen port";
pub const NODE_FULL_MEM: &str = "Use 2GB of RAM insteal of 256MB for faster block verification";
// XMRig
pub const XMRIG_API_PORT_DEFAULT: u16 = 18088;
pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings: