Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/rpc/server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::time::Duration;
use bitcoin::block::Header;
use bitcoin::{BlockHash, Transaction, Txid};
use jsonrpsee::{
Expand Down Expand Up @@ -243,9 +244,28 @@ impl RpcServerImpl {
None => return Ok(()),
};

// Send request to broadcast endpoint
let health_check = self.broadcast_client
.head(endpoint)
.timeout(Duration::from_secs(1))
.send()
.await;

match health_check {
Ok(resp) => {
if !resp.status().is_success() {
tracing::warn!("mempool health check: failed with status: {}", resp.status());
return Ok(())
}
}
Err(e) => {
tracing::warn!("mempool health check: could not connect: {}", e);
return Ok(())
}
}

let response = self.broadcast_client
.post(endpoint)
.timeout(Duration::from_secs(30))
.body(tx_hex.to_string())
.send()
.await;
Expand Down