+ EvilNode,
+}
+
+impl AddressState {
+ pub fn from_num(num: u8) -> Option<AddressState> {
+ match num {
+ 0x0 => Some(AddressState::Untested),
+ 0x1 => Some(AddressState::LowBlockCount),
+ 0x2 => Some(AddressState::HighBlockCount),
+ 0x3 => Some(AddressState::LowVersion),
+ 0x4 => Some(AddressState::BadVersion),
+ 0x5 => Some(AddressState::NotFullNode),
+ 0x6 => Some(AddressState::ProtocolViolation),
+ 0x7 => Some(AddressState::Timeout),
+ 0x8 => Some(AddressState::TimeoutDuringRequest),
+ 0x9 => Some(AddressState::TimeoutAwaitingPong),
+ 0xa => Some(AddressState::TimeoutAwaitingAddr),
+ 0xb => Some(AddressState::TimeoutAwaitingBlock),
+ 0xc => Some(AddressState::Good),
+ 0xd => Some(AddressState::WasGood),
+ 0xe => Some(AddressState::EvilNode),
+ _ => None,
+ }
+ }
+
+ pub fn to_num(&self) -> u8 {
+ match *self {
+ AddressState::Untested => 0,
+ AddressState::LowBlockCount => 1,
+ AddressState::HighBlockCount => 2,
+ AddressState::LowVersion => 3,
+ AddressState::BadVersion => 4,
+ AddressState::NotFullNode => 5,
+ AddressState::ProtocolViolation => 6,
+ AddressState::Timeout => 7,
+ AddressState::TimeoutDuringRequest => 8,
+ AddressState::TimeoutAwaitingPong => 9,
+ AddressState::TimeoutAwaitingAddr => 10,
+ AddressState::TimeoutAwaitingBlock => 11,
+ AddressState::Good => 12,
+ AddressState::WasGood => 13,
+ AddressState::EvilNode => 14,
+ }
+ }
+
+ pub fn to_str(&self) -> &'static str {
+ match *self {
+ AddressState::Untested => "Untested",
+ AddressState::LowBlockCount => "Low Block Count",
+ AddressState::HighBlockCount => "High Block Count",
+ AddressState::LowVersion => "Low Version",
+ AddressState::BadVersion => "Bad Version",
+ AddressState::NotFullNode => "Not Full Node",
+ 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::WasGood => "Was Good",
+ AddressState::EvilNode => "Evil Node",
+ }
+ }
+
+ pub const fn get_count() -> u8 {
+ 15
+ }