Skip to content

Commit 9c96507

Browse files
committed
fix simulation-mode building
1 parent 7fa70d8 commit 9c96507

2 files changed

Lines changed: 33 additions & 23 deletions

File tree

hyperdrive/src/http/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ async fn login_handler(
350350
let info = LoginInfo {
351351
password_hash: "secret".to_string(),
352352
subdomain: info.subdomain,
353+
custom_cache_sources: None,
354+
custom_base_l2_access_providers: None,
353355
};
354356

355357
println!("login_handler: got info {info:?}\r");

hyperdrive/src/main.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use std::collections::HashMap;
1313
use std::env;
1414
use std::path::Path;
1515
use std::sync::Arc;
16-
use tokio::sync::{mpsc, oneshot};
16+
use tokio::sync::mpsc;
17+
18+
#[cfg(not(feature = "simulation-mode"))]
19+
use tokio::sync::oneshot;
1720

1821
mod eth;
1922
mod eth_config_utils;
@@ -319,6 +322,7 @@ async fn main() {
319322

320323
is_eth_provider_config_updated = false;
321324

325+
#[cfg(not(feature = "simulation-mode"))]
322326
if !base_l2_access_source_vector.is_empty() {
323327
// Process in reverse order so the first entry in the vector becomes highest priority
324328
for (_reverse_index, provider_str) in
@@ -485,33 +489,37 @@ async fn main() {
485489
// Create the cache_sources file with test content
486490
let data_file_path = initfiles_dir.join("cache_sources");
487491

488-
// Write cache_source_vector to cache_sources as JSON
489-
let cache_json = serde_json::to_string_pretty(&cache_source_vector)
490-
.expect("Failed to serialize cache_source_vector to JSON");
491-
let cache_json_clone = cache_json.clone();
492492

493-
if let Err(e) = tokio::fs::write(&data_file_path, cache_json).await {
494-
eprintln!("Warning: Failed to write cache data to file: {}", e);
495-
}
493+
#[cfg(not(feature = "simulation-mode"))]
494+
{
495+
// Write cache_source_vector to cache_sources as JSON
496+
let cache_json = serde_json::to_string_pretty(&cache_source_vector)
497+
.expect("Failed to serialize cache_source_vector to JSON");
498+
let cache_json_clone = cache_json.clone();
496499

497-
// Create the second directory structure for hns-indexer:sys
498-
let hns_indexer_dir = vfs_dir.join("hns-indexer:sys");
499-
let hns_initfiles_dir = hns_indexer_dir.join("initfiles");
500+
if let Err(e) = tokio::fs::write(&data_file_path, cache_json).await {
501+
eprintln!("Warning: Failed to write cache data to file: {}", e);
502+
}
500503

501-
// Create all directories at once for the second location
502-
if let Err(e) = tokio::fs::create_dir_all(&hns_initfiles_dir).await {
503-
eprintln!(
504-
"Failed to create directory structure {}: {}",
505-
hns_initfiles_dir.display(),
506-
e
507-
);
508-
}
504+
// Create the second directory structure for hns-indexer:sys
505+
let hns_indexer_dir = vfs_dir.join("hns-indexer:sys");
506+
let hns_initfiles_dir = hns_indexer_dir.join("initfiles");
509507

510-
// Create the cache_sources file in the second location
511-
let hns_data_file_path = hns_initfiles_dir.join("cache_sources");
508+
// Create all directories at once for the second location
509+
if let Err(e) = tokio::fs::create_dir_all(&hns_initfiles_dir).await {
510+
eprintln!(
511+
"Failed to create directory structure {}: {}",
512+
hns_initfiles_dir.display(),
513+
e
514+
);
515+
}
512516

513-
if let Err(e) = tokio::fs::write(&hns_data_file_path, cache_json_clone).await {
514-
eprintln!("Warning: Failed to write cache data to second file: {}", e);
517+
// Create the cache_sources file in the second location
518+
let hns_data_file_path = hns_initfiles_dir.join("cache_sources");
519+
520+
if let Err(e) = tokio::fs::write(&hns_data_file_path, cache_json_clone).await {
521+
eprintln!("Warning: Failed to write cache data to second file: {}", e);
522+
}
515523
}
516524

517525
let mut tasks = tokio::task::JoinSet::<Result<()>>::new();

0 commit comments

Comments
 (0)