浏览代码

Allocate space for the priority field in public routing

Ian Goldberg 11 月之前
父节点
当前提交
ce01061057
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 18 4
      Client/clients.cpp

+ 18 - 4
Client/clients.cpp

@@ -525,25 +525,39 @@ void Client::initializeIngSocket(boost::asio::io_context &ioc,
     Populates the buffer pt_msgbundle with a valid message pt_msgbundle.
     Assumes that it is supplied with a pt_msgbundle buffer of the correct length
 
-    Correct length for pt_msgbundle  =  8 + (priv_out)*(msg_size) + 16 bytes
+    num_out is either priv_out or pub_out, depending on whether we're
+    doing private or public routing
+
+    Correct length for pt_msgbundle  = (num_out)*(msg_size) +
+        (only for private routing) (num_out)*TOKEN_SIZE
 
 */
-void Client::generateMessageBundle(uint8_t priv_out, uint32_t msg_size,
+void Client::generateMessageBundle(uint8_t num_out, uint32_t msg_size,
     unsigned char *pt_msgbundle)
 {
     unsigned char *ptr = pt_msgbundle;
 
     // Setup message pt_msgbundle
-    for(uint32_t i = 0; i < priv_out; i++) {
+    for(uint32_t i = 0; i < num_out; i++) {
         // For benchmarking, each client just sends messages to
         // themselves, so the destination and source ids are the same.
+
+        // Destination id
+        unsigned char *start_ptr = ptr;
         memcpy(ptr, &id, sizeof(id));
         ptr+=(sizeof(id));
 
+        // Priority (for public routing only)
+        if (!private_routing) {
+            memset(ptr, 0, sizeof(uint32_t));
+            ptr+=sizeof(uint32_t);
+        }
+
+        // Source id
         memcpy(ptr, &id, sizeof(id));
         ptr+=(sizeof(id));
 
-        uint32_t remaining_message_size = msg_size - (sizeof(id)*2);
+        uint32_t remaining_message_size = start_ptr + msg_size - ptr;
         memset(ptr, 0, remaining_message_size);
         ptr+=(remaining_message_size);
     }