Skip to content

Commit aac614a

Browse files
committed
propagate tx handler errors, change shutdown handler to reporter
1 parent 93f67fc commit aac614a

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

binaries/cuprated/src/p2p/request_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ where
178178
fut.await.map_err(|e| match e {
179179
HandlerError::Peer(e) => e,
180180
HandlerError::Service(e) => {
181-
shutdown_handle.handle_service_error(&e, ());
181+
shutdown_handle.report_service_error(&e);
182182
e
183183
}
184184
})

binaries/cuprated/src/rpc/handlers/json_rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async fn submit_block(
246246
.await
247247
{
248248
if matches!(&e, IncomingBlockError::Service(_)) {
249-
state.shutdown_handle.handle_service_error(&e, ());
249+
state.shutdown_handle.report_service_error(&e);
250250
}
251251
return Err(e.into());
252252
}

binaries/cuprated/src/rpc/service/tx_handler.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ pub async fn handle_incoming_txs(
1717
) -> Result<TxRelayChecks, Error> {
1818
let resp = match tx_handler.ready().await {
1919
Ok(r) => r.call(incoming_txs).await,
20-
Err(e) => return Ok(shutdown_handle.handle_service_error(e, TxRelayChecks::empty())),
20+
Err(e) => {
21+
shutdown_handle.report_service_error(&e);
22+
return Err(e.into());
23+
}
2124
};
2225

2326
Ok(match resp {
@@ -67,7 +70,8 @@ pub async fn handle_incoming_txs(
6770
}
6871
IncomingTxError::DuplicateTransaction => TxRelayChecks::DOUBLE_SPEND,
6972
IncomingTxError::Internal(e) => {
70-
return Ok(shutdown_handle.handle_service_error(e, TxRelayChecks::empty()));
73+
shutdown_handle.report_service_error(&e);
74+
return Err(e);
7175
}
7276
},
7377
})

binaries/cuprated/src/supervisor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ impl ShutdownHandle {
4040
self.trigger_shutdown();
4141
}
4242

43-
/// Handle a service error by triggering a fatal shutdown.
44-
pub fn handle_service_error<T>(&self, error: impl std::fmt::Display, default: T) -> T {
43+
/// Report a service error and trigger a shutdown.
44+
pub fn report_service_error(&self, error: impl std::fmt::Display) {
4545
self.fatal(&error);
46-
default
4746
}
4847
}
4948

0 commit comments

Comments
 (0)