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

Fix shielded sync scanned progress bar limit #4046

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the limit of the scanned progress bar in shielded sync being lower than
the current value. ([\#4046](https://github.com/anoma/namada/pull/4046))
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