Skip to content

Commit 6d2f73e

Browse files
pashinovRexagon
authored andcommitted
feat(light-node): enable S3 client; pass ignore_states flag when starts
1 parent 2e3cd51 commit 6d2f73e

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

light-node/examples/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn main() -> anyhow::Result<()> {
5252
.with_fallback(archive_block_provider.clone());
5353

5454
let init_block_id = node
55-
.init(ColdBootType::LatestPersistent, import_zerostate)
55+
.init(ColdBootType::LatestPersistent, import_zerostate, false)
5656
.await?;
5757
node.update_validator_set(&init_block_id).await?;
5858

light-node/src/cli.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use tycho_core::blockchain_rpc::{
1313
BlockchainRpcClient, BlockchainRpcService, NoopBroadcastListener,
1414
};
1515
use tycho_core::global_config::{GlobalConfig, ZerostateId};
16+
use tycho_core::node::NodeBootArgs;
1617
use tycho_core::overlay_client::PublicOverlayClient;
1718
#[cfg(feature = "s3")]
1819
use tycho_core::s3::S3Client;
@@ -243,11 +244,17 @@ impl<C> Node<C> {
243244
&self,
244245
boot_type: ColdBootType,
245246
import_zerostate: Option<Vec<PathBuf>>,
247+
ignore_states: bool,
246248
) -> Result<BlockId> {
247249
self.wait_for_neighbours().await;
248250

249251
let init_block_id = self
250-
.boot(boot_type, import_zerostate)
252+
.boot(NodeBootArgs {
253+
boot_type,
254+
ignore_states,
255+
zerostates: import_zerostate,
256+
..Default::default()
257+
})
251258
.await
252259
.context("failed to init node")?;
253260

@@ -268,23 +275,28 @@ impl<C> Node<C> {
268275
}
269276

270277
/// Initialize the node and return the init block id.
271-
async fn boot(
272-
&self,
273-
boot_type: ColdBootType,
274-
zerostates: Option<Vec<PathBuf>>,
275-
) -> Result<BlockId> {
278+
async fn boot(&self, args: NodeBootArgs) -> Result<BlockId> {
276279
let node_state = self.storage.node_state();
277280

278281
let last_mc_block_id = match node_state.load_last_mc_block_id() {
279282
Some(block_id) => block_id,
280283
None => {
281-
Starter::builder()
284+
#[cfg_attr(not(feature = "s3"), allow(unused_mut))]
285+
let mut starter = Starter::builder()
282286
.with_storage(self.storage.clone())
283287
.with_blockchain_rpc_client(self.blockchain_rpc_client.clone())
284288
.with_zerostate_id(self.zerostate)
285289
.with_config(self.starter_config.clone())
290+
.ignore_states(args.ignore_states);
291+
292+
#[cfg(feature = "s3")]
293+
if let Some(s3_client) = self.s3_client.as_ref() {
294+
starter = starter.with_s3_client(s3_client.clone());
295+
}
296+
297+
starter
286298
.build()
287-
.cold_boot(boot_type, zerostates.map(FileZerostateProvider))
299+
.cold_boot(args.boot_type, args.zerostates.map(FileZerostateProvider))
288300
.await?
289301
}
290302
};

0 commit comments

Comments
 (0)