Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Only include enr_seq in pong if ping has it
Browse files Browse the repository at this point in the history
  • Loading branch information
vorot93 committed Mar 31, 2020
1 parent cd62ca0 commit fad711b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions util/network-devp2p/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,12 @@ impl Discovery {
let ping_to = NodeEndpoint::from_rlp(&rlp.at(2)?)?;
let timestamp: u64 = rlp.val_at(3)?;
self.check_timestamp(timestamp)?;
// let enr_seq = rlp.val_at::<u64>(4).ok();
let mut response = RlpStream::new_list(4);
let enr_seq = rlp.val_at::<u64>(4).ok();
let mut response = RlpStream::new_list(3 + if enr_seq.is_some() {
1
} else {
0
});
let pong_to = NodeEndpoint {
address: from,
udp_port: ping_from.udp_port
Expand All @@ -549,7 +553,9 @@ impl Discovery {

response.append(&echo_hash);
append_expiration(&mut response);
response.append(&self.enr.seq());
if enr_seq.is_some() {
response.append(&self.enr.seq());
}
self.send_packet(PACKET_PONG, from, response.drain())?;

let entry = NodeEntry { id: node_id, endpoint: pong_to };
Expand Down

0 comments on commit fad711b

Please sign in to comment.