mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
service/btc: Expire subscription after 10 minutes.
This commit is contained in:
@@ -216,12 +216,24 @@ impl BtcClient {
|
||||
|
||||
let status = client.script_subscribe(&script)?;
|
||||
|
||||
let iter_interval = 5;
|
||||
let mut sub_iter = 0;
|
||||
|
||||
loop {
|
||||
if sub_iter > 60 * 10 {
|
||||
// 10 minutes
|
||||
return Err(BtcFailed::ElectrumError(format!(
|
||||
"Deposit for {:?} expired",
|
||||
script
|
||||
)));
|
||||
}
|
||||
sub_iter += iter_interval;
|
||||
|
||||
let current_status = client.script_pop(&script)?;
|
||||
debug!(target: "BTC BRIDGE", "script status: {:?}", status);
|
||||
debug!(target: "BTC BRIDGE", "current_script status: {:?}", current_status);
|
||||
if current_status == status {
|
||||
async_std::task::sleep(Duration::from_secs(5)).await;
|
||||
async_std::task::sleep(Duration::from_secs(iter_interval)).await;
|
||||
debug!(
|
||||
target: "BTC BRIDGE",
|
||||
"ScriptPubKey status has not changed, amtucfd: {}, amtcfd: {}",
|
||||
|
||||
Reference in New Issue
Block a user