node: fix global config values init on start

This commit is contained in:
ardocrat 2023-07-01 17:22:28 +03:00
parent 6e6bb24e7d
commit 34eb159ddc

View file

@ -28,8 +28,6 @@ use jni::sys::{jboolean, jstring};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use crate::node::NodeConfig; use crate::node::NodeConfig;
use crate::Settings;
lazy_static! { lazy_static! {
/// Static thread-aware state of [`Node`] to be updated from another thread. /// Static thread-aware state of [`Node`] to be updated from another thread.
static ref NODE_STATE: Arc<Node> = Arc::new(Node::default()); static ref NODE_STATE: Arc<Node> = Arc::new(Node::default());
@ -481,6 +479,8 @@ fn start_server() -> Result<Server, Error> {
// These are read via global and not read from config beyond this point. // These are read via global and not read from config beyond this point.
if !global::GLOBAL_CHAIN_TYPE.is_init() { if !global::GLOBAL_CHAIN_TYPE.is_init() {
global::init_global_chain_type(config.server.chain_type); global::init_global_chain_type(config.server.chain_type);
} else {
global::set_global_chain_type(config.server.chain_type);
} }
if !global::GLOBAL_NRD_FEATURE_ENABLED.is_init() { if !global::GLOBAL_NRD_FEATURE_ENABLED.is_init() {
@ -495,13 +495,19 @@ fn start_server() -> Result<Server, Error> {
} }
} }
} }
if !global::GLOBAL_ACCEPT_FEE_BASE.is_init() {
let afb = config.server.pool_config.accept_fee_base; let afb = config.server.pool_config.accept_fee_base;
if !global::GLOBAL_ACCEPT_FEE_BASE.is_init() {
global::init_global_accept_fee_base(afb); global::init_global_accept_fee_base(afb);
} else {
global::set_global_accept_fee_base(afb);
} }
if !global::GLOBAL_FUTURE_TIME_LIMIT.is_init() {
let future_time_limit = config.server.future_time_limit; let future_time_limit = config.server.future_time_limit;
if !global::GLOBAL_FUTURE_TIME_LIMIT.is_init() {
global::init_global_future_time_limit(future_time_limit); global::init_global_future_time_limit(future_time_limit);
} else {
global::set_global_future_time_limit(future_time_limit);
} }
let api_chan: &'static mut (oneshot::Sender<()>, oneshot::Receiver<()>) = let api_chan: &'static mut (oneshot::Sender<()>, oneshot::Receiver<()>) =