From 3332b89a8e33f08e02b5ed1e312016e1ef25da89 Mon Sep 17 00:00:00 2001 From: Guoteng Rao <3603304+grao1991@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:42:30 +0000 Subject: [PATCH] [Indexer-Grpc-V2] Add implementation for Ping in FN. --- .../src/fullnode_data_service.rs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/fullnode_data_service.rs b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/fullnode_data_service.rs index 94cdf25b686d9..8f50e56146f73 100644 --- a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/fullnode_data_service.rs +++ b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/fullnode_data_service.rs @@ -2,13 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{counters::CHANNEL_SIZE, stream_coordinator::IndexerStreamCoordinator, ServiceContext}; -use aptos_indexer_grpc_utils::counters::{log_grpc_step_fullnode, IndexerGrpcStep}; +use aptos_indexer_grpc_utils::{ + counters::{log_grpc_step_fullnode, IndexerGrpcStep}, + timstamp_now_proto, +}; use aptos_logger::{error, info}; use aptos_moving_average::MovingAverage; -use aptos_protos::internal::fullnode::v1::{ - fullnode_data_server::FullnodeData, stream_status::StatusType, transactions_from_node_response, - GetTransactionsFromNodeRequest, PingFullnodeRequest, PingFullnodeResponse, StreamStatus, - TransactionsFromNodeResponse, +use aptos_protos::{ + indexer::v1::FullnodeInfo, + internal::fullnode::v1::{ + fullnode_data_server::FullnodeData, stream_status::StatusType, + transactions_from_node_response, GetTransactionsFromNodeRequest, PingFullnodeRequest, + PingFullnodeResponse, StreamStatus, TransactionsFromNodeResponse, + }, }; use futures::Stream; use std::pin::Pin; @@ -160,9 +166,22 @@ impl FullnodeData for FullnodeDataService { async fn ping( &self, - _request: Request, + request: Request, ) -> Result, Status> { - unimplemented!() + let timestamp = timestamp_now_proto(); + + let info = FullnodeInfo { + chain_id: self.service_context.context.chain_id().id() as u64, + timestamp: Some(timestamp), + known_latest_version: self + .service_context + .context + .db + .get_synced_version() + .map_err(|e| Status::internal(format!("{e}")))?, + }; + let response = PingFullnodeResponse { info: Some(info) }; + Ok(Response::new(response)) } }