add upload/download session stats per torrent to the daemon

This commit is contained in:
simplepad 2023-10-13 01:08:49 +08:00
parent 6c1cee5f79
commit da703185cd
No known key found for this signature in database
GPG Key ID: 00DB76DD9FB623EC
5 changed files with 28 additions and 0 deletions

View File

@ -72,6 +72,7 @@ auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
"cookies"sv,
"corrupt"sv,
"corruptEver"sv,
"corruptThisSession"sv,
"created by"sv,
"created by.utf-8"sv,
"creation date"sv,
@ -103,6 +104,7 @@ auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
"downloaded-bytes"sv,
"downloadedBytes"sv,
"downloadedEver"sv,
"downloadedThisSession"sv,
"downloaders"sv,
"downloading-time-seconds"sv,
"dropped"sv,
@ -411,6 +413,7 @@ auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
"uploaded-bytes"sv,
"uploadedBytes"sv,
"uploadedEver"sv,
"uploadedThisSession"sv,
"url-list"sv,
"use-global-speed-limit"sv,
"use-speed-limit"sv,

View File

@ -73,6 +73,7 @@ enum
TR_KEY_cookies,
TR_KEY_corrupt,
TR_KEY_corruptEver,
TR_KEY_corruptThisSession,
TR_KEY_created_by,
TR_KEY_created_by_utf_8,
TR_KEY_creation_date,
@ -104,6 +105,7 @@ enum
TR_KEY_downloaded_bytes,
TR_KEY_downloadedBytes,
TR_KEY_downloadedEver,
TR_KEY_downloadedThisSession,
TR_KEY_downloaders,
TR_KEY_downloading_time_seconds,
TR_KEY_dropped,
@ -412,6 +414,7 @@ enum
TR_KEY_uploaded_bytes,
TR_KEY_uploadedBytes,
TR_KEY_uploadedEver,
TR_KEY_uploadedThisSession,
TR_KEY_url_list,
TR_KEY_use_global_speed_limit,
TR_KEY_use_speed_limit,

View File

@ -508,6 +508,7 @@ namespace make_torrent_field_helpers
case TR_KEY_bandwidthPriority:
case TR_KEY_comment:
case TR_KEY_corruptEver:
case TR_KEY_corruptThisSession:
case TR_KEY_creator:
case TR_KEY_dateCreated:
case TR_KEY_desiredAvailable:
@ -516,6 +517,7 @@ namespace make_torrent_field_helpers
case TR_KEY_downloadLimit:
case TR_KEY_downloadLimited:
case TR_KEY_downloadedEver:
case TR_KEY_downloadedThisSession:
case TR_KEY_editDate:
case TR_KEY_error:
case TR_KEY_errorString:
@ -577,6 +579,7 @@ namespace make_torrent_field_helpers
case TR_KEY_uploadLimited:
case TR_KEY_uploadRatio:
case TR_KEY_uploadedEver:
case TR_KEY_uploadedThisSession:
case TR_KEY_wanted:
case TR_KEY_webseeds:
case TR_KEY_webseedsSendingToUs:
@ -602,6 +605,7 @@ namespace make_torrent_field_helpers
case TR_KEY_bandwidthPriority: return tor.get_priority();
case TR_KEY_comment: return tor.comment();
case TR_KEY_corruptEver: return st.corruptEver;
case TR_KEY_corruptThisSession: return st.corruptThisSession;
case TR_KEY_creator: return tor.creator();
case TR_KEY_dateCreated: return tor.date_created();
case TR_KEY_desiredAvailable: return st.desiredAvailable;
@ -610,6 +614,7 @@ namespace make_torrent_field_helpers
case TR_KEY_downloadLimit: return tr_torrentGetSpeedLimit_KBps(&tor, TR_DOWN);
case TR_KEY_downloadLimited: return tor.uses_speed_limit(TR_DOWN);
case TR_KEY_downloadedEver: return st.downloadedEver;
case TR_KEY_downloadedThisSession: return st.downloadedThisSession;
case TR_KEY_editDate: return st.editDate;
case TR_KEY_error: return st.error;
case TR_KEY_errorString: return st.errorString;
@ -671,6 +676,7 @@ namespace make_torrent_field_helpers
case TR_KEY_uploadLimited: return tor.uses_speed_limit(TR_UP);
case TR_KEY_uploadRatio: return st.ratio;
case TR_KEY_uploadedEver: return st.uploadedEver;
case TR_KEY_uploadedThisSession: return st.uploadedThisSession;
case TR_KEY_wanted: return make_file_wanted_vec(tor);
case TR_KEY_webseeds: return make_webseed_vec(tor);
case TR_KEY_webseedsSendingToUs: return st.webseedsSendingToUs;

View File

@ -1337,8 +1337,11 @@ tr_stat tr_torrent::stats() const
stats.secondsDownloading = this->seconds_downloading(now_sec);
stats.corruptEver = this->bytes_corrupt_.ever();
stats.corruptThisSession = this->bytes_corrupt_.during_this_session();
stats.downloadedEver = this->bytes_downloaded_.ever();
stats.downloadedThisSession = this->bytes_downloaded_.during_this_session();
stats.uploadedEver = this->bytes_uploaded_.ever();
stats.uploadedThisSession = this->bytes_uploaded_.during_this_session();
stats.haveValid = this->completion_.has_valid();
stats.haveUnchecked = this->has_total() - stats.haveValid;
stats.desiredAvailable = tr_peerMgrGetDesiredAvailable(this);

View File

@ -1442,14 +1442,27 @@ struct tr_stat
grow very large. */
uint64_t corruptEver;
/** Byte count of all the corrupt data you've downloaded during this session for
this torrent. If you're on a poisoned torrent, this number can
grow very large. */
uint64_t corruptThisSession;
/** Byte count of all data you've ever uploaded for this torrent. */
uint64_t uploadedEver;
/** Byte count of all data you've uploaded during this session for this torrent. */
uint64_t uploadedThisSession;
/** Byte count of all the non-corrupt data you've ever downloaded
for this torrent. If you deleted the files and downloaded a second
time, this will be `2*totalSize`.. */
uint64_t downloadedEver;
/** Byte count of all the non-corrupt data you've downloaded during this session
for this torrent. If you deleted the files and downloaded a second
time, this will be `2*totalSize`.. */
uint64_t downloadedThisSession;
/** Byte count of all the checksum-verified data we have for this torrent.
*/
uint64_t haveValid;