feat(indexer): run genesis-consistency check at service and FFI startup

This commit is contained in:
erhant 2026-06-26 21:08:06 +03:00
parent e04626063f
commit 5c48dab887
4 changed files with 17 additions and 7 deletions

View File

@ -112,10 +112,17 @@ unsafe fn setup_indexer(
unsafe { Runtime::from_borrowed(caller.as_ref()) }
};
let core = IndexerCore::new(config, &storage_dir).map_err(|e| {
log::error!("Could not initialize indexer core: {e}");
OperationStatus::InitializationError
})?;
let allow_reset = config.allow_chain_reset;
let core = runtime
.block_on(IndexerCore::new_with_genesis_check(
config,
&storage_dir,
allow_reset,
))
.map_err(|e| {
log::error!("Could not initialize indexer core: {e}");
OperationStatus::InitializationError
})?;
// The block stream writes each parsed block into the store as a side effect
// of being polled, so we spawn a task that simply drains it. There are no

View File

@ -3,5 +3,6 @@
"bedrock_config": {
"addr": "http://localhost:18080"
},
"channel_id": "0101010101010101010101010101010101010101010101010101010101010101"
"channel_id": "0101010101010101010101010101010101010101010101010101010101010101",
"allow_chain_reset": false
}

View File

@ -87,6 +87,7 @@ pub async fn run_server(
#[cfg(not(feature = "mock-responses"))]
let handle = {
let service = service::IndexerService::new(config, storage_dir)
.await
.context("Failed to initialize indexer service")?;
server.start(service.into_rpc())
};

View File

@ -19,8 +19,9 @@ pub struct IndexerService {
}
impl IndexerService {
pub fn new(config: IndexerConfig, storage_dir: &Path) -> Result<Self> {
let indexer = IndexerCore::new(config, storage_dir)?;
pub async fn new(config: IndexerConfig, storage_dir: &Path) -> Result<Self> {
let allow_reset = config.allow_chain_reset;
let indexer = IndexerCore::new_with_genesis_check(config, storage_dir, allow_reset).await?;
let subscription_service = SubscriptionService::spawn_new(indexer.clone());
Ok(Self {