Skip to content

Commit

Permalink
Support shard in case the mining is not enabled (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-valante authored Oct 12, 2024
1 parent 45fa344 commit 82fd299
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion node/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -216,6 +216,16 @@ impl ClientBuilder {
Ok(self)
}

pub async fn with_shard(self, config: ShardConfig) -> Result<Self, String> {
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<Self, String> {
let executor = require!("router", self, runtime_context).clone().executor;
Expand Down
2 changes: 1 addition & 1 deletion node/src/config/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl ZgsConfig {
}
}

fn shard_config(&self) -> Result<ShardConfig, String> {
pub fn shard_config(&self) -> Result<ShardConfig, String> {
self.shard_position.clone().try_into()
}
}
3 changes: 3 additions & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
let miner_config = config.mine_config()?;
let router_config = config.router_config(&network_config)?;
let pruner_config = config.pruner_config()?;
let shard_config = config.shard_config()?;

ClientBuilder::default()
.with_runtime_context(context)
Expand All @@ -30,6 +31,8 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
.await?
.with_miner(miner_config)
.await?
.with_shard(shard_config)
.await?
.with_pruner(pruner_config)
.await?
.with_rpc(config.rpc, config.chunk_pool_config()?)
Expand Down

0 comments on commit 82fd299

Please sign in to comment.