Skip to content

Commit d43a616

Browse files
authored
fix shard config init (#354)
1 parent 898350e commit d43a616

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

node/pruner/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Pruner {
276276
}
277277
}
278278

279-
async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
279+
pub async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
280280
store
281281
.get_config_decoded(&SHARD_CONFIG_KEY, DATA_DB_KEY)
282282
.await

node/src/client/builder.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use network::{
77
self, new_network_channel, Keypair, NetworkConfig, NetworkGlobals, NetworkReceiver,
88
NetworkSender, RequestId, Service as LibP2PService,
99
};
10-
use pruner::{Pruner, PrunerConfig, PrunerMessage};
10+
use pruner::{get_shard_config, Pruner, PrunerConfig, PrunerMessage};
1111
use router::RouterService;
1212
use rpc::RPCConfig;
1313
use std::sync::Arc;
@@ -203,7 +203,7 @@ impl ClientBuilder {
203203
if let Some(config) = config {
204204
let executor = require!("miner", self, runtime_context).clone().executor;
205205
let network_send = require!("miner", self, network).send.clone();
206-
let store = self.async_store.as_ref().unwrap().clone();
206+
let store = require!("miner", self, async_store).clone();
207207

208208
let send = MineService::spawn(executor, network_send, config, store).await?;
209209
self.miner = Some(MinerComponents { send });
@@ -225,7 +225,11 @@ impl ClientBuilder {
225225
Ok(self)
226226
}
227227

228-
pub async fn with_shard(self, config: ShardConfig) -> Result<Self, String> {
228+
pub async fn with_shard(self, mut config: ShardConfig) -> Result<Self, String> {
229+
let store = require!("shard", self, async_store).clone();
230+
if let Some(stored_config) = get_shard_config(store.as_ref()).await.unwrap_or(None) {
231+
config = stored_config;
232+
}
229233
self.async_store
230234
.as_ref()
231235
.unwrap()

node/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
2323
ClientBuilder::default()
2424
.with_runtime_context(context)
2525
.with_rocksdb_store(&storage_config)?
26+
.with_shard(shard_config)
27+
.await?
2628
.with_log_sync(log_sync_config)
2729
.await?
2830
.with_file_location_cache(config.file_location_cache)
@@ -34,8 +36,6 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
3436
.await?
3537
.with_miner(miner_config)
3638
.await?
37-
.with_shard(shard_config)
38-
.await?
3939
.with_pruner(pruner_config)
4040
.await?
4141
.with_rpc(config.rpc)

node/storage/src/log_store/log_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ impl LogManager {
11571157
.get_tx_by_seq_number(from_tx_seq)?
11581158
.ok_or_else(|| anyhow!("from tx missing"))?;
11591159
let mut to_tx_offset_list = Vec::with_capacity(to_tx_seq_list.len());
1160+
11601161
for seq in to_tx_seq_list {
11611162
// No need to copy data for completed tx.
11621163
if self.check_tx_completed(seq)? {

0 commit comments

Comments
 (0)