Skip to content

Commit

Permalink
Chain type field (mimblewimble#3790)
Browse files Browse the repository at this point in the history
* Adding chain type field into get_status rpc

* formatting
  • Loading branch information
aglkm authored Sep 12, 2024
1 parent 9a23cfe commit 01b2565
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand All @@ -91,6 +93,7 @@ impl Status {
sync_info: Option<serde_json::Value>,
) -> Status {
Status {
chain: global::get_chain_type().shortname(),
protocol_version: ser::ProtocolVersion::local().into(),
user_agent: p2p::msg::USER_AGENT.to_string(),
connections: connections,
Expand Down
1 change: 1 addition & 0 deletions src/bin/cmd/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl HTTPNodeClient {
t.reset().unwrap();
match self.send_json_request::<Status>("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();
Expand Down

0 comments on commit 01b2565

Please sign in to comment.