From e0296e401c1b2c037858a7e59521efa59f358ff1 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Fri, 18 Feb 2022 11:34:16 +0200 Subject: [PATCH 1/3] add liveness call to wallet GRPC --- applications/tari_app_grpc/proto/wallet.proto | 13 +++++++++++++ .../src/grpc/wallet_grpc_server.rs | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/applications/tari_app_grpc/proto/wallet.proto b/applications/tari_app_grpc/proto/wallet.proto index acdd7086b6..d7039cca27 100644 --- a/applications/tari_app_grpc/proto/wallet.proto +++ b/applications/tari_app_grpc/proto/wallet.proto @@ -30,6 +30,8 @@ import "types.proto"; service Wallet { // This returns the current version rpc GetVersion (GetVersionRequest) returns (GetVersionResponse); + // This checks if the wallet is healthy and running + rpc CheckConnectivity(GetConnectivityRequest) returns (CheckConnectivityResponse); // Check for new updates rpc CheckForUpdates (Empty) returns (SoftwareUpdate); // This returns the identity information @@ -343,3 +345,14 @@ message SetBaseNodeRequest { } message SetBaseNodeResponse{} + +message GetConnectivityRequest{} + +message CheckConnectivityResponse{ + enum OnlineStatus { + Connecting = 0; + Online = 1; + Offline = 2; + } + OnlineStatus status = 1; +} 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 3d4366fb7f..b209e5dc41 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -30,6 +30,7 @@ use tari_app_grpc::{ self, payment_recipient::PaymentType, wallet_server, + CheckConnectivityResponse, ClaimHtlcRefundRequest, ClaimHtlcRefundResponse, ClaimShaAtomicSwapRequest, @@ -46,6 +47,7 @@ use tari_app_grpc::{ GetCoinbaseResponse, GetCompletedTransactionsRequest, GetCompletedTransactionsResponse, + GetConnectivityRequest, GetIdentityRequest, GetIdentityResponse, GetOwnedAssetsResponse, @@ -86,6 +88,7 @@ use tari_core::transactions::{ use tari_crypto::{ristretto::RistrettoPublicKey, tari_utilities::Hashable}; use tari_utilities::{hex::Hex, ByteArray}; use tari_wallet::{ + connectivity_service::{OnlineStatus, WalletConnectivityInterface}, output_manager_service::handle::OutputManagerHandle, transaction_service::{handle::TransactionServiceHandle, storage::models}, WalletSqlite, @@ -127,6 +130,22 @@ impl wallet_server::Wallet for WalletGrpcServer { })) } + async fn check_connectivity( + &self, + _: Request, + ) -> Result, Status> { + let mut connectivity = self.wallet.wallet_connectivity.clone(); + let status = connectivity.get_connectivity_status(); + let gprc_connectivity = match status { + tari_wallet::connectivity_service::OnlineStatus::Connecting => OnlineStatus::Connecting, + tari_wallet::connectivity_service::OnlineStatus::Online => OnlineStatus::Online, + tari_wallet::connectivity_service::OnlineStatus::Offline => OnlineStatus::Offline, + }; + Ok(Response::new(CheckConnectivityResponse { + status: gprc_connectivity as i32, + })) + } + async fn check_for_updates( &self, _: Request, From ebcd4bcb54ec7aba9e6c10c4667dd8a1fd5f8d3f Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Fri, 18 Feb 2022 11:43:33 +0200 Subject: [PATCH 2/3] Update applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs Co-authored-by: Stan Bondi --- applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b209e5dc41..7abd8b19b8 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -142,7 +142,7 @@ impl wallet_server::Wallet for WalletGrpcServer { tari_wallet::connectivity_service::OnlineStatus::Offline => OnlineStatus::Offline, }; Ok(Response::new(CheckConnectivityResponse { - status: gprc_connectivity as i32, + status: grpc_connectivity as i32, })) } From 2bc4a3de06b00fb818f5bcf5e745d7054bf59f80 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Fri, 18 Feb 2022 11:47:31 +0200 Subject: [PATCH 3/3] fix typo --- applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7abd8b19b8..8f3dbad64b 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -136,7 +136,7 @@ impl wallet_server::Wallet for WalletGrpcServer { ) -> Result, Status> { let mut connectivity = self.wallet.wallet_connectivity.clone(); let status = connectivity.get_connectivity_status(); - let gprc_connectivity = match status { + let grpc_connectivity = match status { tari_wallet::connectivity_service::OnlineStatus::Connecting => OnlineStatus::Connecting, tari_wallet::connectivity_service::OnlineStatus::Online => OnlineStatus::Online, tari_wallet::connectivity_service::OnlineStatus::Offline => OnlineStatus::Offline,