Skip to content

Commit

Permalink
chore: add an extra safeguard so as not to handle internal Messages t…
Browse files Browse the repository at this point in the history
…hat were not actually internal

Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Jan 13, 2021
1 parent 27a9f85 commit a09dbb7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,14 @@ impl Server {

match payload {
Payload::ConnectingTo(remote_address, nonce) => {
self.peers.connecting_to_peer(remote_address, nonce)?;
if direction == Direction::Internal {
self.peers.connecting_to_peer(remote_address, nonce)?;
}
}
Payload::ConnectedTo(remote_address, nonce) => {
self.peers.connected_to_peer(remote_address, nonce)?;
if direction == Direction::Internal {
self.peers.connected_to_peer(remote_address, nonce)?;
}
}
Payload::Version(version) => {
self.peers.version_to_verack(&version)?;
Expand Down Expand Up @@ -225,7 +229,9 @@ impl Server {
self.blocks.received_sync(source.unwrap(), sync).await?;
}
Payload::Disconnect(addr) => {
self.peers.disconnected_from_peer(&addr)?;
if direction == Direction::Internal {
self.peers.disconnected_from_peer(&addr)?;
}
}
Payload::GetPeers => {
self.peers.send_get_peers(source.unwrap());
Expand Down

0 comments on commit a09dbb7

Please sign in to comment.