Skip to content

Commit

Permalink
[Indexer-Grpc-V2] Add implementation for Ping in FN.
Browse files Browse the repository at this point in the history
  • Loading branch information
grao1991 committed Jan 17, 2025
1 parent 17540fa commit 3332b89
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -160,9 +166,22 @@ impl FullnodeData for FullnodeDataService {

async fn ping(
&self,
_request: Request<PingFullnodeRequest>,
request: Request<PingFullnodeRequest>,
) -> Result<Response<PingFullnodeResponse>, 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))
}
}

Expand Down

0 comments on commit 3332b89

Please sign in to comment.