Skip to content

Commit 34a10f0

Browse files
committed
electrum: retry send last request if response do not match
1 parent 14ac384 commit 34a10f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

rust/joinstr/src/electrum.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ impl Client {
285285
batch.push(sub);
286286
}
287287
if !batch.is_empty() {
288+
log::debug!(
289+
"Client::listen_txs() last_request = {:?}",
290+
batch.len()
291+
);
288292
last_request = Some(batch.clone());
289293
// TODO: do not unwrap
290294
self.inner.try_send_batch(batch.iter().collect()).unwrap();
@@ -302,6 +306,10 @@ impl Client {
302306
batch.push(history);
303307
}
304308
if !batch.is_empty() {
309+
log::debug!(
310+
"Client::listen_txs() last_request = {:?}",
311+
batch.len()
312+
);
305313
last_request = Some(batch.clone());
306314
// TODO: do not unwrap
307315
self.inner.try_send_batch(batch.iter().collect()).unwrap();
@@ -316,6 +324,10 @@ impl Client {
316324
batch.push(tx);
317325
}
318326
if !batch.is_empty() {
327+
log::debug!(
328+
"Client::listen_txs() last_request = {:?}",
329+
batch.len()
330+
);
319331
last_request = Some(batch.clone());
320332
// TODO: do not unwrap
321333
self.inner.try_send_batch(batch.iter().collect()).unwrap();
@@ -349,6 +361,12 @@ impl Client {
349361
};
350362
if r_match {
351363
last_request = None;
364+
} else if let Some(last_req) = &last_request {
365+
log::debug!("Client::listen_txs() request not match resend last request");
366+
thread::sleep(Duration::from_millis(100));
367+
self.inner
368+
.try_send_batch(last_req.iter().collect())
369+
.unwrap();
352370
}
353371

354372
log::debug!("Client::listen_txs() from electrum: {r:#?}");

0 commit comments

Comments
 (0)