}
}
- pub fn set_node_state(&self, addr: SocketAddr, state: AddressState, services: u64) -> bool {
+ pub fn set_node_state(&self, addr: SocketAddr, state: AddressState, services: u64) -> AddressState {
let mut nodes_lock = self.nodes.write().unwrap();
let nodes = nodes_lock.borrow_mut();
let state_ref = nodes.nodes_to_state.get_mut(&addr).unwrap();
- let ret = state != state_ref.state;
+ let ret = state_ref.state;
let now = Instant::now();
if (state_ref.state == AddressState::Good || state_ref.state == AddressState::WasGood)
&& state != AddressState::Good
let state_lock = final_peer_state.lock().unwrap();
if state_lock.recvd_version && state_lock.recvd_verack &&
state_lock.recvd_addrs && state_lock.recvd_block {
- if store.set_node_state(node, AddressState::Good, state_lock.node_services) && state_lock.msg.0 != "" {
- printer.add_line(state_lock.msg.0.clone(), state_lock.msg.1);
+ let old_state = store.set_node_state(node, AddressState::Good, state_lock.node_services);
+ if old_state != AddressState::Good && state_lock.msg.0 != "" {
+ printer.add_line(state_lock.msg.0.clone() + " from " + old_state.to_str(), state_lock.msg.1);
}
} else {
assert!(state_lock.fail_reason != AddressState::Good);
- if store.set_node_state(node, state_lock.fail_reason, 0) && state_lock.msg.0 != "" {
- printer.add_line(state_lock.msg.0.clone(), state_lock.msg.1);
+ let old_state = store.set_node_state(node, state_lock.fail_reason, 0);
+ if old_state != state_lock.fail_reason && state_lock.msg.0 != "" {
+ printer.add_line(state_lock.msg.0.clone() + " from " + old_state.to_str(), state_lock.msg.1);
}
}
future::ok(())