Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: sync all payment updates #1095

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions libs/sdk-core/src/breez_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,16 +1188,16 @@ impl BreezServices {
let node_pubkey = self.node_api.start().await?;
self.connect_lsp_peer(node_pubkey).await?;

// First query the changes since last sync time.
let since_timestamp = self.persister.get_last_sync_time()?.unwrap_or(0);
// First query the changes since last sync state.
let sync_state = self.persister.get_sync_state()?;
let new_data = &self
.node_api
.pull_changed(since_timestamp, match_local_balance)
.pull_changed(sync_state.clone(), match_local_balance)
.await?;

debug!(
"pull changed time={:?} {:?}",
since_timestamp, new_data.payments
"pull changed old state={:?} new state={:?}",
sync_state, new_data.sync_state
);

// update node state and channels state
Expand Down Expand Up @@ -1232,11 +1232,8 @@ impl BreezServices {
let duration = start.elapsed();
info!("Sync duration: {:?}", duration);

// update the cached last sync time
if let Ok(last_payment_timestamp) = self.persister.last_payment_timestamp() {
self.persister.set_last_sync_time(last_payment_timestamp)?;
}

// update the cached sync state
self.persister.set_sync_state(&new_data.sync_state)?;
self.notify_event_listeners(BreezEvent::Synced).await?;
Ok(())
}
Expand Down
Loading
Loading