mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-29 00:53:19 +00:00
feat(indexer): run genesis-consistency check at service and FFI startup
This commit is contained in:
parent
aa46b69b79
commit
06ec24540a
@ -112,10 +112,17 @@ unsafe fn setup_indexer(
|
|||||||
unsafe { Runtime::from_borrowed(caller.as_ref()) }
|
unsafe { Runtime::from_borrowed(caller.as_ref()) }
|
||||||
};
|
};
|
||||||
|
|
||||||
let core = IndexerCore::new(config, &storage_dir).map_err(|e| {
|
let allow_reset = config.allow_chain_reset;
|
||||||
log::error!("Could not initialize indexer core: {e}");
|
let core = runtime
|
||||||
OperationStatus::InitializationError
|
.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
|
// 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
|
// of being polled, so we spawn a task that simply drains it. There are no
|
||||||
|
|||||||
@ -3,5 +3,6 @@
|
|||||||
"bedrock_config": {
|
"bedrock_config": {
|
||||||
"addr": "http://localhost:18080"
|
"addr": "http://localhost:18080"
|
||||||
},
|
},
|
||||||
"channel_id": "0101010101010101010101010101010101010101010101010101010101010101"
|
"channel_id": "0101010101010101010101010101010101010101010101010101010101010101",
|
||||||
|
"allow_chain_reset": false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,7 @@ pub async fn run_server(
|
|||||||
#[cfg(not(feature = "mock-responses"))]
|
#[cfg(not(feature = "mock-responses"))]
|
||||||
let handle = {
|
let handle = {
|
||||||
let service = service::IndexerService::new(config, storage_dir)
|
let service = service::IndexerService::new(config, storage_dir)
|
||||||
|
.await
|
||||||
.context("Failed to initialize indexer service")?;
|
.context("Failed to initialize indexer service")?;
|
||||||
server.start(service.into_rpc())
|
server.start(service.into_rpc())
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,8 +19,9 @@ pub struct IndexerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexerService {
|
impl IndexerService {
|
||||||
pub fn new(config: IndexerConfig, storage_dir: &Path) -> Result<Self> {
|
pub async fn new(config: IndexerConfig, storage_dir: &Path) -> Result<Self> {
|
||||||
let indexer = IndexerCore::new(config, storage_dir)?;
|
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());
|
let subscription_service = SubscriptionService::spawn_new(indexer.clone());
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user