xpx_chain_sdk/models/node/
node.rs

1/*
2 * Copyright 2018 ProximaX Limited. All rights reserved.
3 * Use of this source code is governed by the Apache 2.0
4 * license that can be found in the LICENSE file.
5 */
6
7use crate::network::NetworkType;
8
9#[derive(Debug, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct NodeInfo {
12    /// The public key used to identify the node.
13    pub public_key: String,
14    /// The port used for the communication.
15    pub port: u16,
16    pub network_type: NetworkType,
17    /// The version of the application.
18    pub version: u16,
19    pub roles: u32,
20    /// The IP address of the endpoint.
21    pub host: String,
22    /// The name of the node.
23    pub friendly_name: String,
24}
25
26impl core::fmt::Display for NodeInfo {
27    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
28        write!(f, "{}", serde_json::to_string_pretty(self).unwrap_or_default())
29    }
30}
31
32#[derive(Debug, Serialize, Deserialize)]
33pub struct NodeTime {
34    #[serde(rename = "sendTimestamp", skip_serializing_if = "Option::is_none")]
35    pub send_timestamp: Option<u64>,
36    #[serde(rename = "receiveTimestamp", skip_serializing_if = "Option::is_none")]
37    pub receive_timestamp: Option<u64>,
38}
39
40impl core::fmt::Display for NodeTime {
41    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
42        write!(f, "{}", serde_json::to_string_pretty(self).unwrap_or_default())
43    }
44}