gui(home): indicate if blockchain is syncing
This commit is contained in:
parent
62788d105c
commit
1408f66963
@ -67,6 +67,7 @@ impl Panels {
|
||||
wallet.clone(),
|
||||
&cache.coins,
|
||||
cache.blockheight,
|
||||
cache.sync_progress,
|
||||
cache.last_poll_timestamp,
|
||||
daemon_backend.clone(),
|
||||
),
|
||||
|
||||
@ -79,10 +79,13 @@ pub fn redirect(menu: Menu) -> Command<Message> {
|
||||
fn sync_status(
|
||||
daemon_backend: DaemonBackend,
|
||||
blockheight: i32,
|
||||
sync_progress: f64,
|
||||
last_poll: Option<u32>,
|
||||
last_poll_at_startup: Option<u32>,
|
||||
) -> SyncStatus {
|
||||
if blockheight <= 0 {
|
||||
if sync_progress < 1.0 {
|
||||
return SyncStatus::BlockchainSync(sync_progress);
|
||||
} else if blockheight <= 0 {
|
||||
// If blockheight <= 0, then this is a newly created wallet.
|
||||
// If user imported descriptor and is using a local bitcoind, a rescan
|
||||
// will need to be performed in order to see past transactions and so the
|
||||
@ -134,6 +137,7 @@ impl Home {
|
||||
wallet: Arc<Wallet>,
|
||||
coins: &[Coin],
|
||||
blockheight: i32,
|
||||
sync_progress: f64,
|
||||
last_poll: Option<u32>,
|
||||
daemon_backend: DaemonBackend,
|
||||
) -> Self {
|
||||
@ -150,7 +154,13 @@ impl Home {
|
||||
},
|
||||
);
|
||||
|
||||
let sync_status = sync_status(daemon_backend, blockheight, last_poll, last_poll);
|
||||
let sync_status = sync_status(
|
||||
daemon_backend,
|
||||
blockheight,
|
||||
sync_progress,
|
||||
last_poll,
|
||||
last_poll,
|
||||
);
|
||||
|
||||
Self {
|
||||
wallet,
|
||||
@ -174,11 +184,13 @@ impl Home {
|
||||
&self,
|
||||
daemon_backend: DaemonBackend,
|
||||
blockheight: i32,
|
||||
sync_progress: f64,
|
||||
last_poll: Option<u32>,
|
||||
) -> SyncStatus {
|
||||
sync_status(
|
||||
daemon_backend,
|
||||
blockheight,
|
||||
sync_progress,
|
||||
last_poll,
|
||||
self.last_poll_at_startup,
|
||||
)
|
||||
@ -296,6 +308,7 @@ impl State for Home {
|
||||
self.sync_status = self.sync_status(
|
||||
daemon.backend(),
|
||||
cache.blockheight,
|
||||
cache.sync_progress,
|
||||
cache.last_poll_timestamp,
|
||||
);
|
||||
// If this is the current panel, reload it if wallet is no longer syncing.
|
||||
|
||||
@ -62,11 +62,14 @@ pub fn home_view<'a>(
|
||||
Some(
|
||||
Row::new()
|
||||
.push(
|
||||
text(if *sync_status == SyncStatus::WalletFullScan {
|
||||
"Syncing"
|
||||
} else {
|
||||
"Checking for new transactions"
|
||||
})
|
||||
match sync_status {
|
||||
SyncStatus::BlockchainSync(progress) => text(format!(
|
||||
"Syncing blockchain ({:.1}%)",
|
||||
100.0 * *progress
|
||||
)),
|
||||
SyncStatus::WalletFullScan => text("Syncing"),
|
||||
_ => text("Checking for new transactions"),
|
||||
}
|
||||
.style(color::GREY_2),
|
||||
)
|
||||
.push(spinner::typing_text_carousel(
|
||||
|
||||
@ -197,6 +197,8 @@ pub enum SyncStatus {
|
||||
WalletFullScan,
|
||||
/// Wallet is syncing with latest transactions.
|
||||
LatestWalletSync,
|
||||
/// Blockchain is syncing with given progress between 0.0 and 1.0.
|
||||
BlockchainSync(f64),
|
||||
}
|
||||
|
||||
impl SyncStatus {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user