Skip to content

Commit 14ac384

Browse files
committed
electrum: do not forward empty batch requests
1 parent 88478b8 commit 14ac384

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

rust/joinstr/src/electrum.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ impl Client {
284284
sh_sbf_map.insert(sh, spk);
285285
batch.push(sub);
286286
}
287-
last_request = Some(batch.clone());
288-
// TODO: do not unwrap
289-
self.inner.try_send_batch(batch.iter().collect()).unwrap();
287+
if !batch.is_empty() {
288+
last_request = Some(batch.clone());
289+
// TODO: do not unwrap
290+
self.inner.try_send_batch(batch.iter().collect()).unwrap();
291+
}
290292
}
291293
CoinRequest::History(sbfs) => {
292294
let mut batch = vec![];
@@ -299,9 +301,11 @@ impl Client {
299301
reqid_spk_map.insert(id, spk);
300302
batch.push(history);
301303
}
302-
last_request = Some(batch.clone());
303-
// TODO: do not unwrap
304-
self.inner.try_send_batch(batch.iter().collect()).unwrap();
304+
if !batch.is_empty() {
305+
last_request = Some(batch.clone());
306+
// TODO: do not unwrap
307+
self.inner.try_send_batch(batch.iter().collect()).unwrap();
308+
}
305309
}
306310
CoinRequest::Txs(txids) => {
307311
let mut batch = vec![];
@@ -311,9 +315,11 @@ impl Client {
311315
log::debug!("Client::listen_txs() txs request: {tx:?}");
312316
batch.push(tx);
313317
}
314-
last_request = Some(batch.clone());
315-
// TODO: do not unwrap
316-
self.inner.try_send_batch(batch.iter().collect()).unwrap();
318+
if !batch.is_empty() {
319+
last_request = Some(batch.clone());
320+
// TODO: do not unwrap
321+
self.inner.try_send_batch(batch.iter().collect()).unwrap();
322+
}
317323
}
318324
CoinRequest::Stop => {
319325
send.send(CoinResponse::Stopped.into()).unwrap();

0 commit comments

Comments
 (0)