mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 19:41:08 +03:00
Add Inbound/Outbound for connected peers
This commit is contained in:
parent
05d1c6c817
commit
b6a28ea16f
2 changed files with 14 additions and 2 deletions
|
@ -99,6 +99,7 @@ impl Handshake {
|
||||||
addr: peer_addr,
|
addr: peer_addr,
|
||||||
version: shake.version,
|
version: shake.version,
|
||||||
total_difficulty: shake.total_difficulty,
|
total_difficulty: shake.total_difficulty,
|
||||||
|
direction: Direction::Outbound,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If denied then we want to close the connection
|
// If denied then we want to close the connection
|
||||||
|
@ -154,6 +155,7 @@ impl Handshake {
|
||||||
addr: extract_ip(&hand.sender_addr.0, &conn),
|
addr: extract_ip(&hand.sender_addr.0, &conn),
|
||||||
version: hand.version,
|
version: hand.version,
|
||||||
total_difficulty: hand.total_difficulty,
|
total_difficulty: hand.total_difficulty,
|
||||||
|
direction: Direction::Inbound,
|
||||||
};
|
};
|
||||||
|
|
||||||
// At this point we know the published ip and port of the peer
|
// At this point we know the published ip and port of the peer
|
||||||
|
|
|
@ -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.
|
/// General information about a connected peer that's useful to other modules.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct PeerInfo {
|
pub struct PeerInfo {
|
||||||
|
@ -131,6 +140,7 @@ pub struct PeerInfo {
|
||||||
pub version: u32,
|
pub version: u32,
|
||||||
pub addr: SocketAddr,
|
pub addr: SocketAddr,
|
||||||
pub total_difficulty: Difficulty,
|
pub total_difficulty: Difficulty,
|
||||||
|
pub direction: Direction,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The full sumtree data along with indexes required for a consumer to
|
/// The full sumtree data along with indexes required for a consumer to
|
||||||
|
|
Loading…
Reference in a new issue