Skip to content

Commit 16def80

Browse files
author
Ludo Galabru
committed
fix: better termination
1 parent 77fc359 commit 16def80

File tree

1 file changed

+8
-3
lines changed
  • vendor/orchestra-event-observer/src/observer

1 file changed

+8
-3
lines changed

vendor/orchestra-event-observer/src/observer/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ pub async fn handle_bitcoin_rpc_call(
646646

647647
let bitcoin_rpc_call = bitcoin_rpc_call.into_inner().clone();
648648
let method = bitcoin_rpc_call.method.clone();
649+
649650
let body = rocket::serde::json::serde_json::to_vec(&bitcoin_rpc_call).unwrap();
650651

651652
let token = encode(format!(
@@ -659,6 +660,7 @@ pub async fn handle_bitcoin_rpc_call(
659660
config.bitcoin_node_rpc_host, config.bitcoin_node_rpc_port
660661
))
661662
.header("Content-Type", "application/json")
663+
.timeout(std::time::Duration::from_secs(5))
662664
.header("Authorization", format!("Basic {}", token));
663665

664666
if method == "sendrawtransaction" {
@@ -671,9 +673,12 @@ pub async fn handle_bitcoin_rpc_call(
671673
};
672674
}
673675

674-
let res = builder.body(body).send().await.unwrap();
675-
676-
Json(res.json().await.unwrap())
676+
match builder.body(body).send().await {
677+
Ok(res) => Json(res.json().await.unwrap()),
678+
Err(_) => Json(json!({
679+
"status": 500
680+
})),
681+
}
677682
}
678683

679684
#[post("/v1/chainhooks", format = "application/json", data = "<hook>")]

0 commit comments

Comments
 (0)