1
- //! Contains the network RPC request type.
1
+ //! Contains the p2p RPC request type.
2
2
3
3
use crate :: { Discv5Handler , GossipDriver } ;
4
4
use discv5:: multiaddr:: Protocol ;
5
- use kona_rpc:: PeerInfo ;
6
5
use tokio:: sync:: oneshot:: Sender ;
7
6
8
- /// A network RPC Request.
7
+ use super :: types:: { Connectedness , Direction , PeerInfo , PeerScores } ;
8
+
9
+ /// A p2p RPC Request.
9
10
#[ derive( Debug ) ]
10
- pub enum NetRpcRequest {
11
+ pub enum P2pRpcRequest {
11
12
/// Returns [`PeerInfo`] for the [`crate::Network`].
12
13
PeerInfo ( Sender < PeerInfo > ) ,
13
14
/// Dumps the node's discovery table from the [`crate::Discv5Driver`].
@@ -18,7 +19,7 @@ pub enum NetRpcRequest {
18
19
PeerCount ( Sender < ( Option < usize > , usize ) > ) ,
19
20
}
20
21
21
- impl NetRpcRequest {
22
+ impl P2pRpcRequest {
22
23
/// Handles the peer count request.
23
24
pub fn handle ( self , gossip : & GossipDriver , disc : & Discv5Handler ) {
24
25
match self {
@@ -71,21 +72,21 @@ impl NetRpcRequest {
71
72
let node_id = enr. node_id ( ) . to_string ( ) ;
72
73
73
74
// We need to add the local multiaddr to the list of known addresses.
74
- let peer_info = kona_rpc :: PeerInfo {
75
+ let peer_info = PeerInfo {
75
76
peer_id : peer_id. to_string ( ) ,
76
77
node_id,
77
78
user_agent : "kona" . to_string ( ) ,
78
79
protocol_version : "1" . to_string ( ) ,
79
80
enr : enr. to_string ( ) ,
80
81
addresses,
81
82
protocols : None ,
82
- connectedness : kona_rpc :: Connectedness :: Connected ,
83
- direction : kona_rpc :: Direction :: Inbound ,
83
+ connectedness : Connectedness :: Connected ,
84
+ direction : Direction :: Inbound ,
84
85
protected : false ,
85
86
chain_id,
86
87
latency : 0 ,
87
88
gossip_blocks : true ,
88
- peer_scores : kona_rpc :: PeerScores :: default ( ) ,
89
+ peer_scores : PeerScores :: default ( ) ,
89
90
} ;
90
91
if let Err ( e) = sender. send ( peer_info) {
91
92
warn ! ( "Failed to send peer info through response channel: {:?}" , e) ;
0 commit comments