transfer stats
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "./components.hpp"
|
||||
|
||||
std::vector<size_t> Components::FT1ChunkSHA1Cache::chunkIndices(const SHA1Digest& hash) const {
|
||||
namespace Components {
|
||||
|
||||
std::vector<size_t> FT1ChunkSHA1Cache::chunkIndices(const SHA1Digest& hash) const {
|
||||
const auto it = chunk_hash_to_index.find(hash);
|
||||
if (it != chunk_hash_to_index.cend()) {
|
||||
return it->second;
|
||||
@@ -9,7 +11,7 @@ std::vector<size_t> Components::FT1ChunkSHA1Cache::chunkIndices(const SHA1Digest
|
||||
}
|
||||
}
|
||||
|
||||
bool Components::FT1ChunkSHA1Cache::haveChunk(const SHA1Digest& hash) const {
|
||||
bool FT1ChunkSHA1Cache::haveChunk(const SHA1Digest& hash) const {
|
||||
if (have_all) { // short cut
|
||||
return true;
|
||||
}
|
||||
@@ -23,3 +25,17 @@ bool Components::FT1ChunkSHA1Cache::haveChunk(const SHA1Digest& hash) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransferStatsTally::Peer::trimSent(const float time_now) {
|
||||
while (recently_sent.size() > 4 && time_now - recently_sent.front().time_point > 1.f) {
|
||||
recently_sent.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void TransferStatsTally::Peer::trimReceived(const float time_now) {
|
||||
while (recently_received.size() > 4 && time_now - recently_received.front().time_point > 1.f) {
|
||||
recently_received.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
} // Components
|
||||
|
||||
|
Reference in New Issue
Block a user