diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 31311139..caa14ac3 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -99,6 +99,10 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("public_server_mode", GetBoolArg("-public_server_mode",false))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); } + + Object torrent_stats = getLibtorrentSessionStatus(); + obj.insert( obj.end(), torrent_stats.begin(), torrent_stats.end() ); + return obj; } diff --git a/src/twister.cpp b/src/twister.cpp index 2aaff17a..287ae0ab 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -2333,3 +2333,37 @@ Value torrentstatus(const Array& params, bool fHelp) return result; } + +Object getLibtorrentSessionStatus() +{ + Object obj; + boost::shared_ptr ses(m_ses); + if( ses ) { + session_status stats = ses->status(); + + obj.push_back( Pair("dht_torrents", stats.dht_torrents) ); + obj.push_back( Pair("num_peers", stats.num_peers) ); + obj.push_back( Pair("peerlist_size", stats.peerlist_size) ); + obj.push_back( Pair("num_active_requests", stats.active_requests.size()) ); + + obj.push_back( Pair("download_rate", stats.download_rate) ); + obj.push_back( Pair("upload_rate", stats.upload_rate) ); + obj.push_back( Pair("dht_download_rate", stats.dht_download_rate) ); + obj.push_back( Pair("dht_upload_rate", stats.dht_upload_rate) ); + obj.push_back( Pair("ip_overhead_download_rate", stats.ip_overhead_download_rate) ); + obj.push_back( Pair("ip_overhead_upload_rate", stats.ip_overhead_upload_rate) ); + obj.push_back( Pair("payload_download_rate", stats.payload_download_rate) ); + obj.push_back( Pair("payload_upload_rate", stats.payload_upload_rate) ); + + obj.push_back( Pair("total_download", stats.total_download) ); + obj.push_back( Pair("total_upload", stats.total_upload) ); + obj.push_back( Pair("total_dht_download", stats.total_dht_download) ); + obj.push_back( Pair("total_dht_upload", stats.total_dht_upload) ); + obj.push_back( Pair("total_ip_overhead_download", stats.total_ip_overhead_download) ); + obj.push_back( Pair("total_ip_overhead_upload", stats.total_ip_overhead_upload) ); + obj.push_back( Pair("total_payload_download", stats.total_payload_download) ); + obj.push_back( Pair("total_payload_upload", stats.total_payload_upload) ); + } + // @TODO: Is there a way to get some statistics for dhtProxy? + return obj; +} diff --git a/src/twister.h b/src/twister.h index 74456961..ea197a33 100644 --- a/src/twister.h +++ b/src/twister.h @@ -4,6 +4,7 @@ #include "util.h" #include "key.h" #include +#include "json/json_spirit.h" #define LIBTORRENT_PORT_OFFSET 1000 @@ -52,4 +53,6 @@ void dhtPutData(std::string const &username, std::string const &resource, bool m void dhtPutDataSigned(std::string const &username, std::string const &resource, bool multi, libtorrent::entry const &p, std::string const &sig_p, std::string const &sig_user, bool local); +json_spirit::Object getLibtorrentSessionStatus(); + #endif // TWISTER_H