Skip to content

Commit 7dbfe7c

Browse files
apollo_storage,apollo_batcher: store the AbortHandle instead of the JoinHandle (#11688)
1 parent d6128a3 commit 7dbfe7c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

crates/apollo_batcher/src/batcher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use starknet_api::core::{ContractAddress, GlobalRoot, Nonce};
6969
use starknet_api::state::{StateNumber, ThinStateDiff};
7070
use starknet_api::transaction::TransactionHash;
7171
use tokio::sync::Mutex;
72-
use tokio::task::JoinHandle;
72+
use tokio::task::AbortHandle;
7373
use tracing::{debug, error, info, instrument, trace, Instrument};
7474

7575
use crate::block_builder::{
@@ -177,7 +177,7 @@ pub struct Batcher {
177177
commitment_manager: ApolloCommitmentManager,
178178

179179
/// Task handle for the storage reader server, if enabled.
180-
storage_reader_server_handle: Option<JoinHandle<()>>,
180+
storage_reader_server_handle: Option<AbortHandle>,
181181
}
182182

183183
impl Batcher {
@@ -193,7 +193,7 @@ impl Batcher {
193193
block_builder_factory: Box<dyn BlockBuilderFactoryTrait>,
194194
pre_confirmed_block_writer_factory: Box<dyn PreconfirmedBlockWriterFactoryTrait>,
195195
commitment_manager: ApolloCommitmentManager,
196-
storage_reader_server_handle: Option<JoinHandle<()>>,
196+
storage_reader_server_handle: Option<AbortHandle>,
197197
) -> Self {
198198
Self {
199199
config,

crates/apollo_storage/src/storage_reader_server.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use axum::routing::post;
1313
use axum::{Json, Router};
1414
use serde::de::DeserializeOwned;
1515
use serde::{Deserialize, Serialize};
16+
use tokio::task::AbortHandle;
1617
use tracing::{error, info};
1718
use validator::Validate;
1819

@@ -162,7 +163,7 @@ where
162163
}
163164

164165
/// Spawns the storage reader server in a background task if it's enabled.
165-
pub fn spawn_if_enabled(server: Option<Self>) -> Option<tokio::task::JoinHandle<()>>
166+
pub fn spawn_if_enabled(server: Option<Self>) -> Option<AbortHandle>
166167
where
167168
RequestHandler: Send + Sync + 'static,
168169
Request: Send + Sync + 'static,
@@ -174,6 +175,7 @@ where
174175
tracing::error!("Storage reader server error: {:?}", e);
175176
}
176177
})
178+
.abort_handle()
177179
})
178180
}
179181
}

0 commit comments

Comments
 (0)