Skip to content

Commit

Permalink
Fix shielded sync scanned progress bar limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 19, 2024
1 parent fb3a7cd commit 5c90209
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/shielded_token/src/masp/shielded_sync/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ where

self.config
.scanned_tracker
.set_upper_limit(self.cache.fetched.len() as u64);
.set_upper_limit(self.cache.fetched.shielded_outputs() as u64);
self.config.applied_tracker.set_upper_limit(
self.cache.trial_decrypted.successful_decryptions() as u64,
);
Expand Down Expand Up @@ -667,9 +667,9 @@ where
self.cache.fetched.extend(tx_batch);

self.config.fetched_tracker.increment_by(to.0 - from.0 + 1);
self.config
.scanned_tracker
.set_upper_limit(self.cache.fetched.len() as u64);
self.config.scanned_tracker.set_upper_limit(
self.cache.fetched.shielded_outputs() as u64,
);
}
Message::FetchTxs(Err(TaskError {
error,
Expand Down
13 changes: 10 additions & 3 deletions crates/shielded_token/src/masp/shielded_sync/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,16 @@ impl Fetched {
self.txs.is_empty()
}

/// Check the length of the fetched cache
pub fn len(&self) -> usize {
self.txs.len()
/// Return the number of shielded outputs in the cache
pub fn shielded_outputs(&self) -> usize {
self.txs
.values()
.map(|shielded| {
shielded
.sapling_bundle()
.map_or(0, |x| x.shielded_outputs.len())
})
.sum::<usize>()
}
}

Expand Down

0 comments on commit 5c90209

Please sign in to comment.