Skip to content

Commit 2fdb4fb

Browse files
committed
checking peer connection when update lnd snapshot
1 parent b826243 commit 2fdb4fb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mutiny-core/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use crate::messagehandler::CommonLnEventCallback;
5151
use crate::nodemanager::NodeManager;
5252
use crate::nodemanager::{ChannelClosure, MutinyBip21RawMaterials};
5353
pub use crate::onchain::BroadcastTx1InMultiOut;
54+
use crate::peermanager::CONNECTED_PEER_MANAGER;
5455
use crate::storage::{get_invoice_by_hash, DEVICE_LOCK_KEY, LND_CHANNELS_SNAPSHOT_KEY};
5556
use crate::utils::{now, sleep, spawn, spawn_with_handle, StopHandle};
5657
use crate::vss::VSS_MANAGER;
@@ -847,9 +848,11 @@ impl<S: MutinyStorage> MutinyWalletBuilder<S> {
847848
};
848849

849850
let pending = VSS_MANAGER.get_pending_writes();
850-
if pending.is_empty()
851-
|| (pending.len() == 1 && pending.iter().any(|(key, _)| key == DEVICE_LOCK_KEY))
852-
{
851+
let only_device_lock_vss_pending =
852+
pending.len() == 1 && pending.iter().any(|(key, _)| key == DEVICE_LOCK_KEY);
853+
let can_update_snapshot = (pending.is_empty() || only_device_lock_vss_pending)
854+
&& CONNECTED_PEER_MANAGER.is_any_connected();
855+
if can_update_snapshot {
853856
let second_lnd_snapshot =
854857
match fetch_lnd_channels_snapshot(&Client::new(), lsp_url, &node_id, &logger).await
855858
{

0 commit comments

Comments
 (0)