@@ -65,7 +65,7 @@ pub const REQUEST_PACKETS_COMPARE_CONSTANT: f64 = 0.125 * 100.0;
6565/// Packet that should be sent every second. Depending on `ConnectionStatus` it
6666/// can be `CookieRequest` or `CryptoHandshake`
6767#[ derive( Clone , Debug , Eq , PartialEq ) ]
68- enum StatusPacketEnum {
68+ pub enum StatusPacketEnum {
6969 /// `CookieRequest` packet
7070 CookieRequest ( CookieRequest ) ,
7171 /// `CryptoHandshake` packet
@@ -78,7 +78,7 @@ enum StatusPacketEnum {
7878pub struct StatusPacket {
7979 /// Packet that should be sent every second. Depending on `ConnectionStatus`
8080 /// it can be `CookieRequest` or `CryptoHandshake`
81- packet : StatusPacketEnum ,
81+ pub packet : StatusPacketEnum ,
8282 /// When packet was sent last time
8383 pub sent_time : Instant ,
8484 /// How many times packet was sent
@@ -104,14 +104,6 @@ impl StatusPacket {
104104 }
105105 }
106106
107- /// Get `Packet` that should be sent every second
108- pub fn dht_packet ( & self ) -> Packet {
109- match self . packet {
110- StatusPacketEnum :: CookieRequest ( ref packet) => Packet :: CookieRequest ( packet. clone ( ) ) ,
111- StatusPacketEnum :: CryptoHandshake ( ref packet) => Packet :: CryptoHandshake ( packet. clone ( ) ) ,
112- }
113- }
114-
115107 /// Check if one second is elapsed since last time when the packet was sent
116108 fn is_time_elapsed ( & self ) -> bool {
117109 clock_elapsed ( self . sent_time ) > CRYPTO_SEND_PACKET_INTERVAL
@@ -431,15 +423,15 @@ impl CryptoConnection {
431423
432424 /// Get `CookieRequest` or `CryptoHandshake` if it should be sent depending
433425 /// on connection status and update sent counter
434- pub fn packet_to_send ( & mut self ) -> Option < Packet > {
426+ pub fn packet_to_send ( & mut self ) -> Option < StatusPacketEnum > {
435427 match self . status {
436428 ConnectionStatus :: CookieRequesting { ref mut packet, .. }
437429 | ConnectionStatus :: HandshakeSending { ref mut packet, .. }
438430 | ConnectionStatus :: NotConfirmed { ref mut packet, .. } => {
439431 if packet. should_be_sent ( ) {
440432 packet. num_sent += 1 ;
441433 packet. sent_time = clock_now ( ) ;
442- Some ( packet. dht_packet ( ) )
434+ Some ( packet. packet . clone ( ) )
443435 } else {
444436 None
445437 }
0 commit comments