Add Inbound/Outbound for connected peers

This commit is contained in:
Quentin Le Sceller 2018-02-23 12:07:22 -05:00
parent 05d1c6c817
commit b6a28ea16f
2 changed files with 14 additions and 2 deletions

View file

@ -99,6 +99,7 @@ impl Handshake {
addr: peer_addr,
version: shake.version,
total_difficulty: shake.total_difficulty,
direction: Direction::Outbound,
};
// If denied then we want to close the connection
@ -154,6 +155,7 @@ impl Handshake {
addr: extract_ip(&hand.sender_addr.0, &conn),
version: hand.version,
total_difficulty: hand.total_difficulty,
direction: Direction::Inbound,
};
// At this point we know the published ip and port of the peer

View file

@ -123,6 +123,15 @@ bitflags! {
}
}
/// Types of connection
enum_from_primitive! {
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum Direction {
Inbound,
Outbound,
}
}
/// General information about a connected peer that's useful to other modules.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PeerInfo {
@ -131,6 +140,7 @@ pub struct PeerInfo {
pub version: u32,
pub addr: SocketAddr,
pub total_difficulty: Difficulty,
pub direction: Direction,
}
/// The full sumtree data along with indexes required for a consumer to