mwc_web3/types/
parity_peers.rs

1//! Types for getting peer information
2use ethereum_types::U256;
3use serde::{Deserialize, Serialize};
4
5/// Stores active peer count, connected count, max connected peers
6/// and a list of peers for parity node
7#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
8pub struct ParityPeerType {
9    /// number of active peers
10    pub active: usize,
11    /// number of connected peers
12    pub connected: usize,
13    /// maximum number of peers that can connect
14    pub max: u32,
15    /// list of all peers with details
16    pub peers: Vec<ParityPeerInfo>,
17}
18
19/// details of a peer
20#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
21pub struct ParityPeerInfo {
22    /// id of peer
23    pub id: Option<String>,
24    /// name of peer if set by user
25    pub name: String,
26    /// sync logic for protocol messaging
27    pub caps: Vec<String>,
28    /// remote address and local address
29    pub network: PeerNetworkInfo,
30    /// protocol version of peer
31    pub protocols: PeerProtocolsInfo,
32}
33
34/// ip address of both local and remote
35#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
36#[serde(rename_all = "camelCase")]
37pub struct PeerNetworkInfo {
38    /// remote peer address
39    pub remote_address: String,
40    /// local peer address
41    pub local_address: String,
42}
43
44/// chain protocol info
45#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
46pub struct PeerProtocolsInfo {
47    /// chain info
48    pub eth: Option<EthProtocolInfo>,
49    /// chain info
50    pub pip: Option<PipProtocolInfo>,
51}
52
53/// eth chain version, difficulty, and head of chain
54/// which soft fork? Olympic, Frontier, Homestead, Metropolis, Serenity, etc.
55#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
56pub struct EthProtocolInfo {
57    /// version
58    pub version: u32,
59    /// difficulty
60    pub difficulty: Option<U256>,
61    /// head of chain
62    pub head: String,
63}
64
65/// pip version, difficulty, and head
66#[derive(Serialize, PartialEq, Clone, Deserialize, Debug)]
67pub struct PipProtocolInfo {
68    /// version
69    pub version: u32,
70    /// difficulty
71    pub difficulty: U256,
72    /// head of chain
73    pub head: String,
74}