diff --git a/node/pruner/src/lib.rs b/node/pruner/src/lib.rs index 142c998..e078924 100644 --- a/node/pruner/src/lib.rs +++ b/node/pruner/src/lib.rs @@ -276,7 +276,7 @@ impl Pruner { } } -async fn get_shard_config(store: &Store) -> Result> { +pub async fn get_shard_config(store: &Store) -> Result> { store .get_config_decoded(&SHARD_CONFIG_KEY, DATA_DB_KEY) .await diff --git a/node/src/client/builder.rs b/node/src/client/builder.rs index 0298083..b5ec148 100644 --- a/node/src/client/builder.rs +++ b/node/src/client/builder.rs @@ -7,7 +7,7 @@ use network::{ self, new_network_channel, Keypair, NetworkConfig, NetworkGlobals, NetworkReceiver, NetworkSender, RequestId, Service as LibP2PService, }; -use pruner::{Pruner, PrunerConfig, PrunerMessage}; +use pruner::{get_shard_config, Pruner, PrunerConfig, PrunerMessage}; use router::RouterService; use rpc::RPCConfig; use std::sync::Arc; @@ -203,7 +203,7 @@ impl ClientBuilder { if let Some(config) = config { let executor = require!("miner", self, runtime_context).clone().executor; let network_send = require!("miner", self, network).send.clone(); - let store = self.async_store.as_ref().unwrap().clone(); + let store = require!("miner", self, async_store).clone(); let send = MineService::spawn(executor, network_send, config, store).await?; self.miner = Some(MinerComponents { send }); @@ -225,7 +225,11 @@ impl ClientBuilder { Ok(self) } - pub async fn with_shard(self, config: ShardConfig) -> Result { + pub async fn with_shard(self, mut config: ShardConfig) -> Result { + let store = require!("shard", self, async_store).clone(); + if let Some(stored_config) = get_shard_config(store.as_ref()).await.unwrap_or(None) { + config = stored_config; + } self.async_store .as_ref() .unwrap() diff --git a/node/src/main.rs b/node/src/main.rs index 9c42046..ba21fa9 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -23,6 +23,8 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result Result