Skip to content

Commit cc795ce

Browse files
committed
Add diagram
1 parent 7730940 commit cc795ce

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/breez-sdk/core/src/sync/sparkscan.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,34 @@ impl SparkscanSyncService {
209209
/// `last_synced_payment_id`. If `max_pages` is reached or we get an error response from the Sparkscan
210210
/// API, it will update the `next_head_offset` for the next sync. This allows us to gradually sync the
211211
/// head up to the `last_synced_payment_id` in multiple sync cycles.
212+
///
213+
/// Sync cycle 1:
214+
/// Last synced payment ID
215+
/// ↓
216+
/// [ 0 - 24 ][ 25 - 49 ][ 50 - 74 ][ 75 - 99 ]
217+
/// [###########][###########]
218+
/// ↑
219+
/// Next offset 50
220+
/// 75 new payments added during sync
221+
///
222+
/// [ 0 - 24 ][ 25 - 49 ][ 50 - 74 ]
223+
/// ↑
224+
/// Next offset still 50
225+
/// [ 50 - 74 ][ 75 - 99 ][ 100 - 124 ][ 125 - 149 ][ 150 - 174 ]
226+
/// [###########][###########] <- Double synced
227+
/// [###########][###########][###########][###########][####### ]
228+
/// ↑
229+
/// ↑ Find last synced payment ID
230+
/// New last synced payment ID
231+
///
232+
/// Sync cycle 2:
233+
/// Last synced payment ID
234+
/// ↓
235+
/// [ 0 - 24 ][ 25 - 49 ][ 50 - 74 ]
236+
/// [###########][###########][# ]
237+
/// ↑
238+
/// New last synced payment ID
239+
///
212240
async fn sync_payments_head_to_storage(&self) -> Result<(), SdkError> {
213241
info!("Syncing payments head to storage");
214242
let object_repository = ObjectCacheRepository::new(self.storage.clone());

0 commit comments

Comments
 (0)