diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index 65c17cc..fee043d 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -113,7 +113,6 @@ static size_t chunkSize(const FT1InfoSHA1& sha1_info, size_t chunk_index) { } void SHA1_NGCFT1::queueUpRequestChunk(uint32_t group_number, uint32_t peer_number, ContentHandle content, const SHA1Digest& hash) { - // TODO: transfers for (auto& [i_g, i_p, i_m, i_h, i_t] : _queue_requested_chunk) { // if already in queue if (i_g == group_number && i_p == peer_number && i_h == hash) { @@ -123,6 +122,32 @@ void SHA1_NGCFT1::queueUpRequestChunk(uint32_t group_number, uint32_t peer_numbe } } + // check for running transfer + if (_sending_transfers.count(combineIds(group_number, peer_number))) { + for (const auto& [_, transfer] : _sending_transfers.at(combineIds(group_number, peer_number))) { + if (std::holds_alternative(transfer.v)) { + // ignore info + continue; + } + + const auto& t_c = std::get(transfer.v); + + if (content != t_c.content) { + // ignore different content + continue; + } + + auto chunk_idx_vec = content.get().chunkIndices(hash); + + for (size_t idx : chunk_idx_vec) { + if (idx == t_c.chunk_index) { + // already sending + return; // skip + } + } + } + } + // not in queue yet _queue_requested_chunk.push_back(std::make_tuple(group_number, peer_number, content, hash, 0.f)); }