Skip to content

Commit f92df1c

Browse files
apollo_class_manager: spwan storage reader server for class manager (#11689)
1 parent ad02e0f commit f92df1c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

crates/apollo_class_manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ strum.workspace = true
2626
strum_macros.workspace = true
2727
tempfile.workspace = true
2828
thiserror.workspace = true
29+
tokio.workspace = true
2930
tracing.workspace = true
3031

3132
[dev-dependencies]

crates/apollo_class_manager/src/class_storage.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use apollo_storage::storage_reader_types::GenericStorageReaderServer;
1313
use apollo_storage::StorageConfig;
1414
use starknet_api::class_cache::GlobalContractCache;
1515
use thiserror::Error;
16+
use tokio::task::AbortHandle;
1617
use tracing::instrument;
1718

1819
use crate::metrics::{increment_n_classes, record_class_size, CairoClassType, ClassObjectType};
@@ -249,7 +250,7 @@ pub struct ClassHashStorage {
249250
writer: Arc<Mutex<apollo_storage::StorageWriter>>,
250251
// Kept alive to maintain the server running.
251252
#[allow(dead_code)]
252-
storage_reader_server: Option<Arc<GenericStorageReaderServer>>,
253+
storage_reader_server_handle: Option<AbortHandle>,
253254
}
254255

255256
impl ClassHashStorage {
@@ -264,11 +265,10 @@ impl ClassHashStorage {
264265
storage_reader_server_config,
265266
)?;
266267

267-
Ok(Self {
268-
reader,
269-
writer: Arc::new(Mutex::new(writer)),
270-
storage_reader_server: storage_reader_server.map(Arc::new),
271-
})
268+
let storage_reader_server_handle =
269+
GenericStorageReaderServer::spawn_if_enabled(storage_reader_server);
270+
271+
Ok(Self { reader, writer: Arc::new(Mutex::new(writer)), storage_reader_server_handle })
272272
}
273273

274274
fn writer(&self) -> ClassHashStorageResult<LockedWriter<'_>> {

0 commit comments

Comments
 (0)