Skip to content

Commit 727f685

Browse files
committed
Relax chain polling interval to 2 seconds
Polling every second may be overly aggressive, especially when we're polling the mempool. Here, we relax the chain polling interval a bit.
1 parent 46bc4ee commit 727f685

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/chain/bitcoind_rpc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ impl BitcoindRpcClient {
121121
.map(|resp| resp.0)
122122
}
123123

124-
pub(crate) async fn get_mempool_entry(&self, txid: &Txid) -> std::io::Result<MempoolEntry> {
125-
let txid_hex = bitcoin::consensus::encode::serialize_hex(txid);
124+
pub(crate) async fn get_mempool_entry(&self, txid: Txid) -> std::io::Result<MempoolEntry> {
125+
let txid_hex = bitcoin::consensus::encode::serialize_hex(&txid);
126126
let txid_json = serde_json::json!(txid_hex);
127127
self.rpc_client
128128
.call_method::<GetMempoolEntryResponse>("getmempoolentry", &vec![txid_json])
129129
.await
130-
.map(|resp| MempoolEntry { txid: txid.clone(), height: resp.height, time: resp.time })
130+
.map(|resp| MempoolEntry { txid, height: resp.height, time: resp.time })
131131
}
132132

133133
pub(crate) async fn get_mempool_entries(&self) -> std::io::Result<Vec<MempoolEntry>> {
134134
let mempool_txids = self.get_raw_mempool().await?;
135135
let mut mempool_entries = Vec::with_capacity(mempool_txids.len());
136-
for txid in &mempool_txids {
136+
for txid in mempool_txids {
137137
let entry = self.get_mempool_entry(txid).await?;
138138
mempool_entries.push(entry);
139139
}

src/chain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) const DEFAULT_ESPLORA_SERVER_URL: &str = "https://blockstream.info/ap
5151
// The default Esplora client timeout we're using.
5252
pub(crate) const DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS: u64 = 10;
5353

54-
const CHAIN_POLLING_INTERVAL_SECS: u64 = 1;
54+
const CHAIN_POLLING_INTERVAL_SECS: u64 = 2;
5555

5656
pub(crate) enum WalletSyncStatus {
5757
Completed,

0 commit comments

Comments
 (0)