gui(cache): store last poll at startup

This commit is contained in:
Michael Mallan 2024-11-01 11:29:16 +00:00
parent acf14c6d73
commit 92a4a4f8dc
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB
4 changed files with 11 additions and 1 deletions

View File

@ -10,7 +10,10 @@ pub struct Cache {
pub coins: Vec<Coin>,
pub rescan_progress: Option<f64>,
pub sync_progress: f64,
/// The most recent `last_poll_timestamp`.
pub last_poll_timestamp: Option<u32>,
/// The `last_poll_timestamp` when starting the application.
pub last_poll_at_startup: Option<u32>,
}
/// only used for tests.
@ -24,6 +27,7 @@ impl std::default::Default for Cache {
rescan_progress: None,
sync_progress: 1.0,
last_poll_timestamp: None,
last_poll_at_startup: None,
}
}
}

View File

@ -284,6 +284,7 @@ impl App {
let daemon = self.daemon.clone();
let datadir_path = self.cache.datadir_path.clone();
let network = self.cache.network;
let last_poll_at_startup = self.cache.last_poll_at_startup;
Command::perform(
async move {
// we check every 10 second if the daemon poller is alive
@ -302,6 +303,7 @@ impl App {
rescan_progress: info.rescan_progress,
sync_progress: info.sync,
last_poll_timestamp: info.last_poll_timestamp,
last_poll_at_startup, // doesn't change
})
},
Message::UpdateCache,

View File

@ -407,7 +407,9 @@ pub async fn load_application(
blockheight: info.block_height,
coins,
sync_progress: info.sync,
// Both last poll fields start with the same value.
last_poll_timestamp: info.last_poll_timestamp,
last_poll_at_startup: info.last_poll_timestamp,
..Default::default()
};

View File

@ -462,7 +462,9 @@ pub fn create_app_with_remote_backend(
sync_progress: 1.0, // Remote backend is always synced
datadir_path: datadir.clone(),
blockheight: wallet.tip_height.unwrap_or(0),
last_poll_timestamp: None, // We ignore this field for remote backend.
// We ignore last poll fields for remote backend.
last_poll_timestamp: None,
last_poll_at_startup: None,
},
Arc::new(
Wallet::new(wallet.descriptor)