pink_web3/types/
parity_peers.rs

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