From 82fd29968b93e038753b9d819750e873322ac25c Mon Sep 17 00:00:00 2001 From: bruno-valante <140794260+bruno-valante@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:03:47 +0800 Subject: [PATCH] Support shard in case the mining is not enabled (#231) --- node/src/client/builder.rs | 12 +++++++++++- node/src/config/convert.rs | 2 +- node/src/main.rs | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/node/src/client/builder.rs b/node/src/client/builder.rs index 4d742e1..dbbe590 100644 --- a/node/src/client/builder.rs +++ b/node/src/client/builder.rs @@ -2,7 +2,7 @@ use super::{Client, RuntimeContext}; use chunk_pool::{ChunkPoolMessage, Config as ChunkPoolConfig, MemoryChunkPool}; use file_location_cache::FileLocationCache; use log_entry_sync::{LogSyncConfig, LogSyncEvent, LogSyncManager}; -use miner::{MineService, MinerConfig, MinerMessage}; +use miner::{MineService, MinerConfig, MinerMessage, ShardConfig}; use network::{ self, Keypair, NetworkConfig, NetworkGlobals, NetworkMessage, RequestId, Service as LibP2PService, @@ -216,6 +216,16 @@ impl ClientBuilder { Ok(self) } + pub async fn with_shard(self, config: ShardConfig) -> Result { + self.async_store + .as_ref() + .unwrap() + .update_shard_config(config) + .await; + + Ok(self) + } + /// Starts the networking stack. pub fn with_router(mut self, router_config: router::Config) -> Result { let executor = require!("router", self, runtime_context).clone().executor; diff --git a/node/src/config/convert.rs b/node/src/config/convert.rs index e871b84..34dc3d3 100644 --- a/node/src/config/convert.rs +++ b/node/src/config/convert.rs @@ -228,7 +228,7 @@ impl ZgsConfig { } } - fn shard_config(&self) -> Result { + pub fn shard_config(&self) -> Result { self.shard_position.clone().try_into() } } diff --git a/node/src/main.rs b/node/src/main.rs index cfac0b7..a73b26c 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -17,6 +17,7 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result Result