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

feat: add liveness call to wallet GRPC #3854

Merged
merged 6 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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