Skip to content

Commit 01b2565

Browse files
authored
Chain type field (#3790)
* Adding chain type field into get_status rpc * formatting
1 parent 9a23cfe commit 01b2565

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

api/src/owner_rpc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub trait OwnerRpc: Sync + Send {
4949
"jsonrpc": "2.0",
5050
"result": {
5151
"Ok": {
52+
"chain": "main",
5253
"protocol_version": "2",
5354
"user_agent": "MW/Grin 2.x.x",
5455
"connections": "8",

api/src/types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::chain;
1616
use crate::core::core::hash::Hashed;
1717
use crate::core::core::merkle_proof::MerkleProof;
1818
use crate::core::core::{FeeFields, KernelFeatures, TxKernel};
19-
use crate::core::{core, ser};
19+
use crate::core::{core, global, ser};
2020
use crate::p2p;
2121
use crate::util::secp::pedersen;
2222
use crate::util::{self, ToHex};
@@ -68,6 +68,8 @@ impl Tip {
6868
/// Status page containing different server information
6969
#[derive(Serialize, Deserialize, Debug, Clone)]
7070
pub struct Status {
71+
// The chain type
72+
pub chain: String,
7173
// The protocol version
7274
pub protocol_version: u32,
7375
// The user user agent
@@ -91,6 +93,7 @@ impl Status {
9193
sync_info: Option<serde_json::Value>,
9294
) -> Status {
9395
Status {
96+
chain: global::get_chain_type().shortname(),
9497
protocol_version: ser::ProtocolVersion::local().into(),
9598
user_agent: p2p::msg::USER_AGENT.to_string(),
9699
connections: connections,

src/bin/cmd/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl HTTPNodeClient {
9292
t.reset().unwrap();
9393
match self.send_json_request::<Status>("get_status", &serde_json::Value::Null) {
9494
Ok(status) => {
95+
writeln!(e, "Chain type: {}", status.chain).unwrap();
9596
writeln!(e, "Protocol version: {:?}", status.protocol_version).unwrap();
9697
writeln!(e, "User agent: {}", status.user_agent).unwrap();
9798
writeln!(e, "Connections: {}", status.connections).unwrap();

0 commit comments

Comments
 (0)