Browse Source

adding counting bytes sent to NodeIO

Aaron Johnson 1 year ago
parent
commit
fc72e6414a
2 changed files with 4 additions and 1 deletions
  1. 2 1
      App/net.cpp
  2. 2 0
      App/net.hpp

+ 2 - 1
App/net.cpp

@@ -13,7 +13,7 @@
 NetIO *g_netio = NULL;
 
 NodeIO::NodeIO(tcp::socket &&socket, nodenum_t nodenum) :
-    sock(std::move(socket)), node_num(nodenum)
+    sock(std::move(socket)), node_num(nodenum), bytes_sent(0)
 {
 }
 
@@ -82,6 +82,7 @@ void NodeIO::async_send_commands()
                 &(commands_inflight.front()) == commandp);
             uint8_t *data = std::get<1>(*commandp);
             commands_inflight.pop_front();
+            bytes_sent += std::get<2>(*commandp);
             if (commands_inflight.size() > 0) {
                 async_send_commands();
             }

+ 2 - 0
App/net.hpp

@@ -90,6 +90,8 @@ class NodeIO {
     // The static frame used to receive a chunk
     uint8_t receive_frame[FRAME_SIZE];
 
+    uint64_t bytes_sent; // count bytes sent
+
     void send_header_data(uint64_t header, uint8_t *data, size_t len);
 
     // Asynchronously send the first message from the command queue.