-simplify logic
[oweals/gnunet.git] / src / transport / gnunet-service-transport_neighbours.c
index 7c596fbae8c2f8972612151f3cedc66c9fc03ea8..17e30c0b790c087e1fa50710426f32b7d4b7175d 100644 (file)
@@ -826,6 +826,9 @@ set_alternative_address (struct NeighbourMapEntry *n,
   n->alternative_address.session = session;
   n->alternative_address.ats_active = GNUNET_NO;
   n->alternative_address.keep_alive_nonce = 0;
+  GNUNET_assert (GNUNET_YES ==
+                 GST_ats_is_known (n->alternative_address.address,
+                                   n->alternative_address.session));
 }
 
 
@@ -890,6 +893,9 @@ set_primary_address (struct NeighbourMapEntry *n,
   n->primary_address.bandwidth_out = bandwidth_out;
   n->primary_address.session = session;
   n->primary_address.keep_alive_nonce = 0;
+  GNUNET_assert (GNUNET_YES ==
+                 GST_ats_is_known (n->primary_address.address,
+                                   n->primary_address.session));
   /* subsystems about address use */
   GST_validation_set_address_use (n->primary_address.address,
                                   GNUNET_YES);
@@ -1508,7 +1514,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
   if (NULL == (n = lookup_neighbour (neighbour)))
   {
     GNUNET_STATISTICS_update (GST_stats,
-                              gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not connected)"),
+                              gettext_noop ("# KEEPALIVE_RESPONSEs discarded (not connected)"),
                               1,
                               GNUNET_NO);
     return;
@@ -1517,7 +1523,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
        (GNUNET_YES != n->expect_latency_response) )
   {
     GNUNET_STATISTICS_update (GST_stats,
-                              gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not expected)"),
+                              gettext_noop ("# KEEPALIVE_RESPONSEs discarded (not expected)"),
                               1,
                               GNUNET_NO);
     return;
@@ -1525,7 +1531,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
   if (NULL == n->primary_address.address)
   {
     GNUNET_STATISTICS_update (GST_stats,
-                              gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (address changed)"),
+                              gettext_noop ("# KEEPALIVE_RESPONSEs discarded (address changed)"),
                               1,
                               GNUNET_NO);
     return;
@@ -1534,18 +1540,18 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
   {
     if (0 == n->primary_address.keep_alive_nonce)
       GNUNET_STATISTICS_update (GST_stats,
-                                gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (no nonce)"),
+                                gettext_noop ("# KEEPALIVE_RESPONSEs discarded (no nonce)"),
                                 1,
                                 GNUNET_NO);
     else
       GNUNET_STATISTICS_update (GST_stats,
-                                gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"),
+                                gettext_noop ("# KEEPALIVE_RESPONSEs discarded (bad nonce)"),
                                 1,
                                 GNUNET_NO);
     return;
   }
   GNUNET_STATISTICS_update (GST_stats,
-                            gettext_noop ("# KEEPALIVE_RESPONSE messages received in good order"),
+                            gettext_noop ("# KEEPALIVE_RESPONSEs received (OK)"),
                             1,
                             GNUNET_NO);
 
@@ -2455,6 +2461,9 @@ try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address,
     /* switch to a different session, but keeping same address; could
        happen if there is a 2nd inbound connection */
     n->primary_address.session = session;
+    GNUNET_assert (GNUNET_YES ==
+                   GST_ats_is_known (n->primary_address.address,
+                                     n->primary_address.session));
   }
   n->primary_address.bandwidth_in = bandwidth_in;
   n->primary_address.bandwidth_out = bandwidth_out;
@@ -3398,6 +3407,9 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
     /* Destroy the inbound address since it cannot be used */
     free_address (&n->primary_address);
     n->primary_address = n->alternative_address;
+    GNUNET_assert (GNUNET_YES ==
+                   GST_ats_is_known (n->primary_address.address,
+                                     n->primary_address.session));
     memset (&n->alternative_address,
             0,
             sizeof (struct NeighbourAddress));
@@ -3483,7 +3495,8 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                 print_ack_state (n->ack_state));
 
     GNUNET_STATISTICS_update (GST_stats,
-                              gettext_noop ("# unexpected ACK messages"), 1,
+                              gettext_noop ("# unexpected ACK messages"),
+                              1,
                               GNUNET_NO);
     return GNUNET_OK;
   }
@@ -3498,7 +3511,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                          GNUNET_TRANSPORT_PS_CONNECTED,
                          GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
 
-  /* Reset backoff for primary address  */
+  /* Reset backoff for primary address */
   GST_ats_block_reset (n->primary_address.address,
                        n->primary_address.session);
   return GNUNET_OK;