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(wallet): implement check_for_updates in wallet grpc #4359

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/tari_base_node/src/commands/cli_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
) -> Result<Response<tari_rpc::SoftwareUpdate>, 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();
Expand Down
27 changes: 12 additions & 15 deletions applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,18 @@ impl wallet_server::Wallet for WalletGrpcServer {
&self,
_: Request<tari_rpc::Empty>,
) -> Result<Response<tari_rpc::SoftwareUpdate>, 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<GetIdentityRequest>) -> Result<Response<GetIdentityResponse>, Status> {
Expand Down
13 changes: 9 additions & 4 deletions base_layer/p2p/src/auto_update/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ pub type SoftwareUpdateNotifier = watch::Receiver<Option<SoftwareUpdate>>;

#[derive(Clone)]
pub struct SoftwareUpdaterHandle {
new_update_notifier: SoftwareUpdateNotifier,
update_notifier: SoftwareUpdateNotifier,
request_tx: mpsc::Sender<oneshot::Sender<Option<SoftwareUpdate>>>,
}

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<SoftwareUpdate>> {
self.update_notifier.borrow()
}

/// Returns watch notifier that triggers after a check for software updates
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions meta/hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified meta/hashes.txt.sig
Binary file not shown.