diff --git a/applications/tari_base_node/src/commands/cli_loop.rs b/applications/tari_base_node/src/commands/cli_loop.rs index 8107f23fea..9d8798603f 100644 --- a/applications/tari_base_node/src/commands/cli_loop.rs +++ b/applications/tari_base_node/src/commands/cli_loop.rs @@ -117,7 +117,7 @@ impl CliLoop { async fn watch_loop(&mut self) { if let Some(command) = self.watch_task.take() { let mut interrupt = signal::ctrl_c().fuse().boxed(); - let mut software_update_notif = self.context.software_updater.new_update_notifier().clone(); + let mut software_update_notif = self.context.software_updater.update_notifier().clone(); let config = self.context.config.clone(); let line = command.line(); let interval = command diff --git a/applications/tari_base_node/src/commands/command/version.rs b/applications/tari_base_node/src/commands/command/version.rs index 677c3657ea..6c69c96af7 100644 --- a/applications/tari_base_node/src/commands/command/version.rs +++ b/applications/tari_base_node/src/commands/command/version.rs @@ -45,7 +45,7 @@ impl CommandContext { println!("Author: {}", consts::APP_AUTHOR); println!("Avx2: {}", if cfg!(feature = "avx2") { "enabled" } else { "disabled" }); - if let Some(ref update) = *self.software_updater.new_update_notifier().borrow() { + if let Some(ref update) = *self.software_updater.update_notifier().borrow() { println!( "Version {} of the {} is available: {} (sha: {})", update.version(), diff --git a/applications/tari_base_node/src/grpc/base_node_grpc_server.rs b/applications/tari_base_node/src/grpc/base_node_grpc_server.rs index b1d138d8ed..3859312589 100644 --- a/applications/tari_base_node/src/grpc/base_node_grpc_server.rs +++ b/applications/tari_base_node/src/grpc/base_node_grpc_server.rs @@ -1563,7 +1563,7 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer { ) -> Result, Status> { let mut resp = tari_rpc::SoftwareUpdate::default(); - if let Some(ref update) = *self.software_updater.new_update_notifier().borrow() { + if let Some(ref update) = *self.software_updater.update_notifier().borrow() { resp.has_update = true; resp.version = update.version().to_string(); resp.sha = update.to_hash_hex(); diff --git a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs index b817610bc1..6a6b29be7a 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -196,21 +196,18 @@ impl wallet_server::Wallet for WalletGrpcServer { &self, _: Request, ) -> Result, Status> { - todo!("reimplement updates") - // let mut resp = tari_rpc::SoftwareUpdate::default(); - // - // if let Some(ref update) = *self - // .wallet - // .get_software_updater() - // .map(|su| su.new_update_notifier().borrow()) - // { - // resp.has_update = true; - // resp.version = update.version().to_string(); - // resp.sha = update.to_hash_hex(); - // resp.download_url = update.download_url().to_string(); - // } - // - // Ok(Response::new(resp)) + let mut resp = tari_rpc::SoftwareUpdate::default(); + + if let Some(ref updater) = self.wallet.get_software_updater() { + if let Some(ref update) = *updater.latest_update() { + resp.has_update = true; + resp.version = update.version().to_string(); + resp.sha = update.to_hash_hex(); + resp.download_url = update.download_url().to_string(); + } + } + + Ok(Response::new(resp)) } async fn identify(&self, _: Request) -> Result, Status> { diff --git a/base_layer/p2p/src/auto_update/service.rs b/base_layer/p2p/src/auto_update/service.rs index 9c332e5dfc..8bed655a91 100644 --- a/base_layer/p2p/src/auto_update/service.rs +++ b/base_layer/p2p/src/auto_update/service.rs @@ -45,7 +45,7 @@ pub type SoftwareUpdateNotifier = watch::Receiver>; #[derive(Clone)] pub struct SoftwareUpdaterHandle { - new_update_notifier: SoftwareUpdateNotifier, + update_notifier: SoftwareUpdateNotifier, request_tx: mpsc::Sender>>, } @@ -53,8 +53,13 @@ impl SoftwareUpdaterHandle { /// Returns watch notifier that emits a value whenever a new software update is detected. /// First the current SoftwareUpdate (if any) is emitted. Thereafter, only software updates with a greater version /// number are emitted. - pub fn new_update_notifier(&self) -> &SoftwareUpdateNotifier { - &self.new_update_notifier + pub fn update_notifier(&self) -> &SoftwareUpdateNotifier { + &self.update_notifier + } + + /// Returns the latest update or None if the updater has not retrieved the latest update yet. + pub fn latest_update(&self) -> watch::Ref<'_, Option> { + self.update_notifier.borrow() } /// Returns watch notifier that triggers after a check for software updates @@ -177,7 +182,7 @@ impl ServiceInitializer for SoftwareUpdaterService { let (request_tx, request_rx) = mpsc::channel(1); context.register_handle(SoftwareUpdaterHandle { - new_update_notifier: new_update_notif.clone(), + update_notifier: new_update_notif.clone(), request_tx, }); context.spawn_until_shutdown(move |_| service.run(request_rx, notifier, new_update_notif)); diff --git a/meta/hashes.txt b/meta/hashes.txt index 3c7df39762..f5f8d8d901 100644 --- a/meta/hashes.txt +++ b/meta/hashes.txt @@ -2,3 +2,8 @@ 6e77da12535e0ed7851761ae6c6729f2dd3ae8050840e8c08e10e279dadfde8a osx/tari_base_node-0.8.10-65fc65a-release.pkg fa2623588f0891caa39344d4b1b6ca1ba6256fede52b0f7cb96b285a125dff6d linux/tari_base_node-ubuntu-18.04-x64-0.8.10-65fc65a-release.zip 952b04d1f79d5712133d78fbc0f2dbfb80dac199c782ac7884ec36c10f4bd623 windows/tari_base_node-Windows-0.8.11-3b00f2d-release.exe + +## Console wallet (these need updating) +6e77da12535e0ed7851761ae6c6729f2dd3ae8050840e8c08e10e279dadfde8a osx/console_wallet-0.8.10-65fc65a-release.pkg +fa2623588f0891caa39344d4b1b6ca1ba6256fede52b0f7cb96b285a125dff6d linux/console_wallet-ubuntu-18.04-x64-0.8.10-65fc65a-release.zip +952b04d1f79d5712133d78fbc0f2dbfb80dac199c782ac7884ec36c10f4bd623 windows/console_wallet-Windows-0.8.11-3b00f2d-release.exe diff --git a/meta/hashes.txt.sig b/meta/hashes.txt.sig index 4bc8c465cd..89657f7ba3 100644 Binary files a/meta/hashes.txt.sig and b/meta/hashes.txt.sig differ