aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-29 22:03:52 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-11 10:46:41 +0000
commit9f8dc4ce515f52ebb2a434ba6d1d9f47bfeac612 (patch)
tree7c73227be570f59685f1c3efb4d313c0831aa9f6 /contrib/epee
parentMerge pull request #5367 (diff)
downloadmonero-9f8dc4ce515f52ebb2a434ba6d1d9f47bfeac612.tar.xz
simplewallet: new net_stats command
displays total sent and received bytes
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/net/http_client.h10
-rw-r--r--contrib/epee/include/net/net_helper.h22
2 files changed, 30 insertions, 2 deletions
diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h
index a18a1d30a..bb10c8efc 100644
--- a/contrib/epee/include/net/http_client.h
+++ b/contrib/epee/include/net/http_client.h
@@ -444,6 +444,16 @@ namespace net_utils
return handle_reciev(timeout);
}
//---------------------------------------------------------------------------
+ uint64_t get_bytes_sent() const
+ {
+ return m_net_client.get_bytes_sent();
+ }
+ //---------------------------------------------------------------------------
+ uint64_t get_bytes_received() const
+ {
+ return m_net_client.get_bytes_received();
+ }
+ //---------------------------------------------------------------------------
private:
//---------------------------------------------------------------------------
inline bool handle_reciev(std::chrono::milliseconds timeout)
diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h
index 66a307c97..e8fb40a0a 100644
--- a/contrib/epee/include/net/net_helper.h
+++ b/contrib/epee/include/net/net_helper.h
@@ -108,7 +108,9 @@ namespace net_utils
m_initialized(true),
m_connected(false),
m_deadline(m_io_service),
- m_shutdowned(0)
+ m_shutdowned(0),
+ m_bytes_sent(0),
+ m_bytes_received(0)
{
}
@@ -313,6 +315,7 @@ namespace net_utils
}else
{
m_deadline.expires_at(std::chrono::steady_clock::time_point::max());
+ m_bytes_sent += buff.size();
}
}
@@ -369,6 +372,7 @@ namespace net_utils
}else
{
m_deadline.expires_at(std::chrono::steady_clock::time_point::max());
+ m_bytes_sent += sz;
}
}
@@ -458,6 +462,7 @@ namespace net_utils
/*if(!bytes_transfered)
return false;*/
+ m_bytes_received += bytes_transfered;
buff.assign(local_buff, bytes_transfered);
return true;
}
@@ -526,6 +531,7 @@ namespace net_utils
m_deadline.expires_at(std::chrono::steady_clock::time_point::max());
}
+ m_bytes_received += bytes_transfered;
if(bytes_transfered != buff.size())
{
LOG_ERROR("Transferred mismatch with transfer_at_least value: m_bytes_transferred=" << bytes_transfered << " at_least value=" << buff.size());
@@ -581,7 +587,17 @@ namespace net_utils
{
return m_ssl_socket->next_layer();
}
-
+
+ uint64_t get_bytes_sent() const
+ {
+ return m_bytes_sent;
+ }
+
+ uint64_t get_bytes_received() const
+ {
+ return m_bytes_received;
+ }
+
private:
void check_deadline()
@@ -667,6 +683,8 @@ namespace net_utils
bool m_connected;
boost::asio::steady_timer m_deadline;
volatile uint32_t m_shutdowned;
+ std::atomic<uint64_t> m_bytes_sent;
+ std::atomic<uint64_t> m_bytes_received;
};