Skip to content

Commit

Permalink
feat: add liveness call to wallet GRPC (#3854)
Browse files Browse the repository at this point in the history
Description
---
Add GRPC call to check wallet liveness. The liveness service is mapped to GRPC now as well. 

Motivation and Context
---
We only have an FFI call to check the liveness but we need a GRPC option as well. This will allow any service connecting via GRPC to also call the liveness service to determine the liveness of the wallet.
  • Loading branch information
SWvheerden authored Feb 22, 2022
1 parent d28703d commit 9ab832a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions applications/tari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -354,3 +356,14 @@ message SetBaseNodeRequest {
}

message SetBaseNodeResponse{}

message GetConnectivityRequest{}

message CheckConnectivityResponse{
enum OnlineStatus {
Connecting = 0;
Online = 1;
Offline = 2;
}
OnlineStatus status = 1;
}
19 changes: 19 additions & 0 deletions applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use tari_app_grpc::{
self,
payment_recipient::PaymentType,
wallet_server,
CheckConnectivityResponse,
ClaimHtlcRefundRequest,
ClaimHtlcRefundResponse,
ClaimShaAtomicSwapRequest,
Expand All @@ -48,6 +49,7 @@ use tari_app_grpc::{
GetCoinbaseResponse,
GetCompletedTransactionsRequest,
GetCompletedTransactionsResponse,
GetConnectivityRequest,
GetIdentityRequest,
GetIdentityResponse,
GetOwnedAssetsResponse,
Expand Down Expand Up @@ -88,6 +90,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,
Expand Down Expand Up @@ -129,6 +132,22 @@ impl wallet_server::Wallet for WalletGrpcServer {
}))
}

async fn check_connectivity(
&self,
_: Request<GetConnectivityRequest>,
) -> Result<Response<CheckConnectivityResponse>, Status> {
let mut connectivity = self.wallet.wallet_connectivity.clone();
let status = connectivity.get_connectivity_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,
};
Ok(Response::new(CheckConnectivityResponse {
status: grpc_connectivity as i32,
}))
}

async fn check_for_updates(
&self,
_: Request<tari_rpc::Empty>,
Expand Down

0 comments on commit 9ab832a

Please sign in to comment.