Add a category for timedout pong
authorMatt Corallo <git@bluematt.me>
Mon, 10 Jun 2019 10:38:02 +0000 (06:38 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 10 Jun 2019 10:38:47 +0000 (06:38 -0400)
src/datastore.rs
src/main.rs

index 0eb2e8e7b9a21ea9d8444062efa15c9887644b1e..4f59305b30f5cf17e634b493f8742700b75a411f 100644 (file)
@@ -27,6 +27,7 @@ pub enum AddressState {
        ProtocolViolation,
        Timeout,
        TimeoutDuringRequest,
        ProtocolViolation,
        Timeout,
        TimeoutDuringRequest,
+       TimeoutAwaitingPong,
        TimeoutAwaitingAddr,
        TimeoutAwaitingBlock,
        Good,
        TimeoutAwaitingAddr,
        TimeoutAwaitingBlock,
        Good,
@@ -45,10 +46,11 @@ impl AddressState {
                        0x6 => Some(AddressState::ProtocolViolation),
                        0x7 => Some(AddressState::Timeout),
                        0x8 => Some(AddressState::TimeoutDuringRequest),
                        0x6 => Some(AddressState::ProtocolViolation),
                        0x7 => Some(AddressState::Timeout),
                        0x8 => Some(AddressState::TimeoutDuringRequest),
-                       0x9 => Some(AddressState::TimeoutAwaitingAddr),
-                       0xa => Some(AddressState::TimeoutAwaitingBlock),
-                       0xb => Some(AddressState::Good),
-                       0xc => Some(AddressState::WasGood),
+                       0x9 => Some(AddressState::TimeoutAwaitingPong),
+                       0xa => Some(AddressState::TimeoutAwaitingAddr),
+                       0xb => Some(AddressState::TimeoutAwaitingBlock),
+                       0xc => Some(AddressState::Good),
+                       0xd => Some(AddressState::WasGood),
                        _   => None,
                }
        }
                        _   => None,
                }
        }
@@ -64,10 +66,11 @@ impl AddressState {
                        AddressState::ProtocolViolation => 6,
                        AddressState::Timeout => 7,
                        AddressState::TimeoutDuringRequest => 8,
                        AddressState::ProtocolViolation => 6,
                        AddressState::Timeout => 7,
                        AddressState::TimeoutDuringRequest => 8,
-                       AddressState::TimeoutAwaitingAddr => 9,
-                       AddressState::TimeoutAwaitingBlock => 10,
-                       AddressState::Good => 11,
-                       AddressState::WasGood => 12,
+                       AddressState::TimeoutAwaitingPong => 9,
+                       AddressState::TimeoutAwaitingAddr => 10,
+                       AddressState::TimeoutAwaitingBlock => 11,
+                       AddressState::Good => 12,
+                       AddressState::WasGood => 13,
                }
        }
 
                }
        }
 
@@ -82,6 +85,7 @@ impl AddressState {
                        AddressState::ProtocolViolation => "Protocol Violation",
                        AddressState::Timeout => "Timeout",
                        AddressState::TimeoutDuringRequest => "Timeout During Request",
                        AddressState::ProtocolViolation => "Protocol Violation",
                        AddressState::Timeout => "Timeout",
                        AddressState::TimeoutDuringRequest => "Timeout During Request",
+                       AddressState::TimeoutAwaitingPong => "Timeout Awaiting Pong",
                        AddressState::TimeoutAwaitingAddr => "Timeout Awaiting Addr",
                        AddressState::TimeoutAwaitingBlock => "Timeout Awaiting Block",
                        AddressState::Good => "Good",
                        AddressState::TimeoutAwaitingAddr => "Timeout Awaiting Addr",
                        AddressState::TimeoutAwaitingBlock => "Timeout Awaiting Block",
                        AddressState::Good => "Good",
@@ -90,7 +94,7 @@ impl AddressState {
        }
 
        pub const fn get_count() -> u8 {
        }
 
        pub const fn get_count() -> u8 {
-               13
+               14
        }
 }
 
        }
 }
 
@@ -175,6 +179,7 @@ impl Store {
                        u64s.insert(U64Setting::RescanInterval(AddressState::ProtocolViolation), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::Timeout), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::ProtocolViolation), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::Timeout), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest), try_read!(l, u64));
+                       u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingPong), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::Good), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock), try_read!(l, u64));
                        u64s.insert(U64Setting::RescanInterval(AddressState::Good), try_read!(l, u64));
@@ -194,6 +199,7 @@ impl Store {
                        u64s.insert(U64Setting::RescanInterval(AddressState::ProtocolViolation), 86400);
                        u64s.insert(U64Setting::RescanInterval(AddressState::Timeout), 86400);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest), 21600);
                        u64s.insert(U64Setting::RescanInterval(AddressState::ProtocolViolation), 86400);
                        u64s.insert(U64Setting::RescanInterval(AddressState::Timeout), 86400);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest), 21600);
+                       u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingPong), 3600);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr), 1800);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock), 3600);
                        u64s.insert(U64Setting::RescanInterval(AddressState::Good), 1800);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr), 1800);
                        u64s.insert(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock), 3600);
                        u64s.insert(U64Setting::RescanInterval(AddressState::Good), 1800);
@@ -372,7 +378,7 @@ impl Store {
        pub fn save_data(&'static self) -> impl Future<Item=(), Error=()> {
                let settings_file = self.store.clone() + "/settings";
                let settings_future = File::create(settings_file.clone() + ".tmp").and_then(move |f| {
        pub fn save_data(&'static self) -> impl Future<Item=(), Error=()> {
                let settings_file = self.store.clone() + "/settings";
                let settings_future = File::create(settings_file.clone() + ".tmp").and_then(move |f| {
-                       let settings_string = format!("{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
+                       let settings_string = format!("{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
                                self.get_u64(U64Setting::ConnsPerSec),
                                self.get_u64(U64Setting::RunTimeout),
                                self.get_u64(U64Setting::WasGoodTimeout),
                                self.get_u64(U64Setting::ConnsPerSec),
                                self.get_u64(U64Setting::RunTimeout),
                                self.get_u64(U64Setting::WasGoodTimeout),
@@ -386,6 +392,7 @@ impl Store {
                                self.get_u64(U64Setting::RescanInterval(AddressState::ProtocolViolation)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::Timeout)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::ProtocolViolation)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::Timeout)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutDuringRequest)),
+                               self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutAwaitingPong)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::Good)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutAwaitingAddr)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::TimeoutAwaitingBlock)),
                                self.get_u64(U64Setting::RescanInterval(AddressState::Good)),
index a1d03d2b978533266f94c80f03d25e4196387c5b..0f2838f68f48e29842966283ccd11d8cccf54674 100644 (file)
@@ -202,8 +202,10 @@ pub fn scan_node(scan_time: Instant, node: SocketAddr, manual: bool) {
                        }
                } else {
                        assert!(state_lock.fail_reason != AddressState::Good);
                        }
                } else {
                        assert!(state_lock.fail_reason != AddressState::Good);
-                       if state_lock.fail_reason == AddressState::TimeoutDuringRequest && state_lock.recvd_version && state_lock.recvd_verack && state_lock.recvd_pong {
-                               if !state_lock.recvd_addrs {
+                       if state_lock.fail_reason == AddressState::TimeoutDuringRequest && state_lock.recvd_version && state_lock.recvd_verack {
+                               if !state_lock.recvd_pong {
+                                       state_lock.fail_reason = AddressState::TimeoutAwaitingPong;
+                               } else if !state_lock.recvd_addrs {
                                        state_lock.fail_reason = AddressState::TimeoutAwaitingAddr;
                                } else if !state_lock.recvd_block {
                                        state_lock.fail_reason = AddressState::TimeoutAwaitingBlock;
                                        state_lock.fail_reason = AddressState::TimeoutAwaitingAddr;
                                } else if !state_lock.recvd_block {
                                        state_lock.fail_reason = AddressState::TimeoutAwaitingBlock;
@@ -211,8 +213,8 @@ pub fn scan_node(scan_time: Instant, node: SocketAddr, manual: bool) {
                        }
                        let old_state = store.set_node_state(node, state_lock.fail_reason, 0);
                        if (manual || old_state != state_lock.fail_reason) && state_lock.fail_reason == AddressState::TimeoutDuringRequest {
                        }
                        let old_state = store.set_node_state(node, state_lock.fail_reason, 0);
                        if (manual || old_state != state_lock.fail_reason) && state_lock.fail_reason == AddressState::TimeoutDuringRequest {
-                               printer.add_line(format!("Updating {} from {} to Timeout During Request (ver: {}, vack: {}, pong: {})",
-                                       node, old_state.to_str(), state_lock.recvd_version, state_lock.recvd_verack, state_lock.recvd_pong), true);
+                               printer.add_line(format!("Updating {} from {} to Timeout During Request (ver: {}, vack: {})",
+                                       node, old_state.to_str(), state_lock.recvd_version, state_lock.recvd_verack), true);
                        } else if manual || (old_state != state_lock.fail_reason && state_lock.msg.0 != "" && state_lock.msg.1) {
                                printer.add_line(format!("Updating {} from {} to {} {}", node, old_state.to_str(), state_lock.fail_reason.to_str(), &state_lock.msg.0), state_lock.msg.1);
                        }
                        } else if manual || (old_state != state_lock.fail_reason && state_lock.msg.0 != "" && state_lock.msg.1) {
                                printer.add_line(format!("Updating {} from {} to {} {}", node, old_state.to_str(), state_lock.fail_reason.to_str(), &state_lock.msg.0), state_lock.msg.1);
                        }