Przeglądaj źródła

Handling the single server case in public routing protocol

Sajin 1 rok temu
rodzic
commit
37b1a89d94
1 zmienionych plików z 10 dodań i 4 usunięć
  1. 10 4
      Enclave/route.cpp

+ 10 - 4
Enclave/route.cpp

@@ -397,7 +397,10 @@ static void round1b_received(NodeCommState &nodest,
     uint16_t prev_nodes = g_teems_config.weights[my_node_num].startweight;
     nodenum_t num_routing_nodes = g_teems_config.num_routing_nodes;
     nodenum_t adjacent_nodes =
-        (((prev_nodes == 0) || (prev_nodes == num_routing_nodes-1)) ? 1 : 2);        
+        (((prev_nodes == 0) || (prev_nodes == num_routing_nodes-1)) ? 1 : 2);
+    if(num_routing_nodes==1) {
+        adjacent_nodes = 0;
+    }
     if (nodes_received == adjacent_nodes && completed_prev_round) {
         route_state.step = ROUTE_ROUND_1B;
         void *cbpointer = route_state.cbpointer;
@@ -579,7 +582,7 @@ static void send_round1_msgs(const uint8_t *msgs, const T *indices,
 
     for (auto &routing_node: g_teems_config.routing_nodes) {
         uint8_t weight = g_teems_config.weights[routing_node].weight;
-        
+
         if (weight == 0) {
             // This shouldn't happen, but just in case
             continue;
@@ -772,7 +775,7 @@ static void send_round1c_msgs(const uint8_t *msgs, const UidPriorityKey *indices
 
     for (auto &routing_node: g_teems_config.routing_nodes) {
         uint8_t weight = g_teems_config.weights[routing_node].weight;
-        
+
         if (weight == 0) {
             // This shouldn't happen, but just in case
             continue;
@@ -1006,7 +1009,10 @@ static void round1b_processing(void *cbpointer) {
         round1b.completed_prev_round = true;
         nodenum_t nodes_received = round1b.nodes_received;
         nodenum_t adjacent_nodes =
-            (((prev_nodes == 0) || (prev_nodes == num_routing_nodes-1)) ? 1 : 2);        
+            (((prev_nodes == 0) || (prev_nodes == num_routing_nodes-1)) ? 1 : 2);
+        if(num_routing_nodes==1) {
+            adjacent_nodes = 0;
+        }
         pthread_mutex_unlock(&round1b.mutex);
         if (nodes_received == adjacent_nodes) {
             route_state.step = ROUTE_ROUND_1B;