mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Merge #1429
1429: Immediately sync bitcoin tx status upon subscribing r=binarybaron a=binarybaron Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
This commit is contained in:
commit
4c69013c1b
@ -761,9 +761,10 @@ impl Client {
|
||||
self.blockchain.get_tx(txid)
|
||||
}
|
||||
|
||||
fn update_state(&mut self) -> Result<()> {
|
||||
fn update_state(&mut self, force_sync: bool) -> Result<()> {
|
||||
let now = Instant::now();
|
||||
if now < self.last_sync + self.sync_interval {
|
||||
|
||||
if !force_sync && now < self.last_sync + self.sync_interval {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@ -783,9 +784,14 @@ impl Client {
|
||||
|
||||
if !self.script_history.contains_key(&script) {
|
||||
self.script_history.insert(script.clone(), vec![]);
|
||||
}
|
||||
|
||||
self.update_state()?;
|
||||
// When we first subscribe to a script we want to immediately fetch its status
|
||||
// Otherwise we would have to wait for the next sync interval, which can take a minute
|
||||
// This would result in potentially inaccurate status updates until that next sync interval is hit
|
||||
self.update_state(true)?;
|
||||
} else {
|
||||
self.update_state(false)?;
|
||||
}
|
||||
|
||||
let history = self.script_history.entry(script).or_default();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user