diff --git a/chain/jsonrpc-primitives/src/types/split_storage.rs b/chain/jsonrpc-primitives/src/types/split_storage.rs index 4aeed41a196..7399b00dba7 100644 --- a/chain/jsonrpc-primitives/src/types/split_storage.rs +++ b/chain/jsonrpc-primitives/src/types/split_storage.rs @@ -2,6 +2,8 @@ use near_primitives::views::SplitStorageInfoView; use serde::{Deserialize, Serialize}; use serde_json::Value; +use crate::types::status::RpcStatusError; + #[derive(Serialize, Deserialize, Debug)] pub struct RpcSplitStorageInfoRequest {} @@ -39,3 +41,16 @@ impl From for crate::errors::RpcError { Self::new_internal_or_handler_error(error_data, error_data_value) } } + +impl RpcSplitStorageInfoError { + // Implementing From for RpcStatusError causes cargo to spit out hundreds + // of lines of compilation errors. I don't want to spend time debugging this, so let's use this function instead. + // It's good enough. + pub fn into_rpc_status_error(self) -> RpcStatusError { + match self { + RpcSplitStorageInfoError::InternalError { error_message } => { + RpcStatusError::InternalError { error_message } + } + } + } +} diff --git a/chain/jsonrpc-primitives/src/types/status.rs b/chain/jsonrpc-primitives/src/types/status.rs index fe116a24aa5..c321da3f90c 100644 --- a/chain/jsonrpc-primitives/src/types/status.rs +++ b/chain/jsonrpc-primitives/src/types/status.rs @@ -5,7 +5,8 @@ use near_client_primitives::debug::{ #[cfg(feature = "debug_types")] use near_primitives::views::{ CatchupStatusView, ChainProcessingInfo, NetworkGraphView, NetworkRoutesView, PeerStoreView, - RecentOutboundConnectionsView, RequestedStatePartsView, SnapshotHostsView, SyncStatusView, + RecentOutboundConnectionsView, RequestedStatePartsView, SnapshotHostsView, + SplitStorageInfoView, SyncStatusView, }; #[derive(Debug, serde::Serialize, serde::Deserialize)] @@ -34,6 +35,7 @@ pub enum DebugStatusResponse { RecentOutboundConnections(RecentOutboundConnectionsView), Routes(NetworkRoutesView), SnapshotHosts(SnapshotHostsView), + SplitStoreStatus(SplitStorageInfoView), } #[cfg(feature = "debug_types")] diff --git a/chain/jsonrpc/res/debug.html b/chain/jsonrpc/res/debug.html index 48963b1883a..532c792606e 100644 --- a/chain/jsonrpc/res/debug.html +++ b/chain/jsonrpc/res/debug.html @@ -67,6 +67,7 @@

Chain & Chunk info

Sync info

Validator info

Client Config

+

Split Store

diff --git a/chain/jsonrpc/res/split_store.html b/chain/jsonrpc/res/split_store.html new file mode 100644 index 00000000000..2b671b33ddf --- /dev/null +++ b/chain/jsonrpc/res/split_store.html @@ -0,0 +1,33 @@ + + + + Split Store + + + +

+ Split Store +

+ + + + + + + diff --git a/chain/jsonrpc/src/lib.rs b/chain/jsonrpc/src/lib.rs index f8d20bd96ba..9e1c60aa004 100644 --- a/chain/jsonrpc/src/lib.rs +++ b/chain/jsonrpc/src/lib.rs @@ -24,7 +24,9 @@ use near_jsonrpc_primitives::message::{Message, Request}; use near_jsonrpc_primitives::types::config::RpcProtocolConfigResponse; use near_jsonrpc_primitives::types::entity_debug::{EntityDebugHandler, EntityQuery}; use near_jsonrpc_primitives::types::query::RpcQueryRequest; -use near_jsonrpc_primitives::types::split_storage::RpcSplitStorageInfoResponse; +use near_jsonrpc_primitives::types::split_storage::{ + RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, +}; use near_jsonrpc_primitives::types::transactions::{ RpcSendTransactionRequest, RpcTransactionResponse, }; @@ -771,6 +773,13 @@ impl JsonRpcHandler { .peer_manager_send(near_network::debug::GetDebugStatus::SnapshotHosts) .await? .rpc_into(), + "/debug/api/split_store_info" => { + let split_storage_info: RpcSplitStorageInfoResponse = self + .split_storage_info(RpcSplitStorageInfoRequest {}) + .await + .map_err(|e| e.into_rpc_status_error())?; + near_jsonrpc_primitives::types::status::DebugStatusResponse::SplitStoreStatus(split_storage_info.result) + } _ => return Ok(None), }; Ok(Some(near_jsonrpc_primitives::types::status::RpcDebugStatusResponse { @@ -1444,6 +1453,7 @@ async fn display_debug_html( "sync.css" => Some(debug_page_string!("sync.css", handler)), "validator" => Some(debug_page_string!("validator.html", handler)), "validator.css" => Some(debug_page_string!("validator.css", handler)), + "split_store" => Some(debug_page_string!("split_store.html", handler)), _ => None, };