From 01b25650e2c9d6c0536d2839dc27e7e2ee3c98d2 Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:03:51 +0300 Subject: [PATCH] Chain type field (#3790) * Adding chain type field into get_status rpc * formatting --- api/src/owner_rpc.rs | 1 + api/src/types.rs | 5 ++++- src/bin/cmd/client.rs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index 537a4fb2e..6884b509e 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -49,6 +49,7 @@ pub trait OwnerRpc: Sync + Send { "jsonrpc": "2.0", "result": { "Ok": { + "chain": "main", "protocol_version": "2", "user_agent": "MW/Grin 2.x.x", "connections": "8", diff --git a/api/src/types.rs b/api/src/types.rs index 6b0ee0e55..4d3194056 100644 --- a/api/src/types.rs +++ b/api/src/types.rs @@ -16,7 +16,7 @@ use crate::chain; use crate::core::core::hash::Hashed; use crate::core::core::merkle_proof::MerkleProof; use crate::core::core::{FeeFields, KernelFeatures, TxKernel}; -use crate::core::{core, ser}; +use crate::core::{core, global, ser}; use crate::p2p; use crate::util::secp::pedersen; use crate::util::{self, ToHex}; @@ -68,6 +68,8 @@ impl Tip { /// Status page containing different server information #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Status { + // The chain type + pub chain: String, // The protocol version pub protocol_version: u32, // The user user agent @@ -91,6 +93,7 @@ impl Status { sync_info: Option, ) -> Status { Status { + chain: global::get_chain_type().shortname(), protocol_version: ser::ProtocolVersion::local().into(), user_agent: p2p::msg::USER_AGENT.to_string(), connections: connections, diff --git a/src/bin/cmd/client.rs b/src/bin/cmd/client.rs index e3c6165b6..04bbdeb32 100644 --- a/src/bin/cmd/client.rs +++ b/src/bin/cmd/client.rs @@ -92,6 +92,7 @@ impl HTTPNodeClient { t.reset().unwrap(); match self.send_json_request::("get_status", &serde_json::Value::Null) { Ok(status) => { + writeln!(e, "Chain type: {}", status.chain).unwrap(); writeln!(e, "Protocol version: {:?}", status.protocol_version).unwrap(); writeln!(e, "User agent: {}", status.user_agent).unwrap(); writeln!(e, "Connections: {}", status.connections).unwrap();