switch to os provided remote have set and other fixes
This commit is contained in:
parent
78390dd342
commit
b35babe3f8
@ -272,7 +272,7 @@ std::vector<ChunkPicker::ContentChunkR> ChunkPicker::updateChunkRequests(
|
||||
ObjectHandle o {objreg, it->first};
|
||||
|
||||
// intersect self have with other have
|
||||
if (!o.all_of<Components::RemoteHaveBitset, Components::FT1ChunkSHA1Cache, Components::FT1InfoSHA1>()) {
|
||||
if (!o.all_of<ObjComp::F::RemoteHaveBitset, Components::FT1ChunkSHA1Cache, Components::FT1InfoSHA1>()) {
|
||||
// rare case where no one else has anything
|
||||
continue;
|
||||
}
|
||||
@ -284,7 +284,7 @@ std::vector<ChunkPicker::ContentChunkR> ChunkPicker::updateChunkRequests(
|
||||
|
||||
//const auto& cc = o.get<Components::FT1ChunkSHA1Cache>();
|
||||
|
||||
const auto& others_have = o.get<Components::RemoteHaveBitset>().others;
|
||||
const auto& others_have = o.get<ObjComp::F::RemoteHaveBitset>().others;
|
||||
auto other_it = others_have.find(c);
|
||||
if (other_it == others_have.end()) {
|
||||
// rare case where the other is participating but has nothing
|
||||
|
@ -70,14 +70,6 @@ namespace Components {
|
||||
entt::dense_set<Contact3> participants;
|
||||
};
|
||||
|
||||
struct RemoteHaveBitset {
|
||||
struct Entry {
|
||||
bool have_all {false};
|
||||
BitSet have;
|
||||
};
|
||||
entt::dense_map<Contact3, Entry> others;
|
||||
};
|
||||
|
||||
struct ReRequestInfoTimer {
|
||||
float timer {0.f};
|
||||
};
|
||||
|
@ -1256,11 +1256,15 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_send_done& e) {
|
||||
auto& transfer = _sending_transfers.getTransfer(e.group_number, e.peer_number, e.transfer_id);
|
||||
|
||||
if (transfer.isChunk()) {
|
||||
// we could cheat here and assume remote has chunk now
|
||||
_os.throwEventUpdate(transfer.getChunk().content);
|
||||
|
||||
updateMessages(transfer.getChunk().content); // mostly for sent bytes
|
||||
}
|
||||
} // ignore info transfer for now
|
||||
|
||||
_sending_transfers.removePeerTransfer(e.group_number, e.peer_number, e.transfer_id);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1403,8 +1407,8 @@ bool SHA1_NGCFT1::onToxEvent(const Tox_Event_Group_Peer_Exit* e) {
|
||||
for (const auto& [_, o] : _info_to_content) {
|
||||
removeParticipation(c, o);
|
||||
|
||||
if (o.all_of<Components::RemoteHaveBitset>()) {
|
||||
o.get<Components::RemoteHaveBitset>().others.erase(c);
|
||||
if (o.all_of<ObjComp::F::RemoteHaveBitset>()) {
|
||||
o.get<ObjComp::F::RemoteHaveBitset>().others.erase(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1463,19 +1467,15 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) {
|
||||
|
||||
const size_t num_total_chunks = o.get<Components::FT1InfoSHA1>().chunks.size();
|
||||
|
||||
auto& remote_have = o.get_or_emplace<Components::RemoteHaveBitset>().others;
|
||||
auto& remote_have = o.get_or_emplace<ObjComp::F::RemoteHaveBitset>().others;
|
||||
if (!remote_have.contains(c)) {
|
||||
// init
|
||||
remote_have.emplace(c, Components::RemoteHaveBitset::Entry{false, num_total_chunks});
|
||||
remote_have.emplace(c, ObjComp::F::RemoteHaveBitset::Entry{false, num_total_chunks});
|
||||
|
||||
// new have? nice
|
||||
//c.emplace_or_replace<ChunkPickerUpdateTag>();
|
||||
}
|
||||
|
||||
if (o.all_of<ObjComp::F::TagLocalHaveAll>()) {
|
||||
return true; // we dont care beyond this point
|
||||
}
|
||||
|
||||
auto& remote_have_peer = remote_have.at(c);
|
||||
if (remote_have_peer.have_all) {
|
||||
return true; // peer somehow already had all, ignoring
|
||||
@ -1496,11 +1496,6 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) {
|
||||
a_valid_change = true;
|
||||
}
|
||||
|
||||
if (a_valid_change) {
|
||||
// new have? nice
|
||||
c.emplace_or_replace<ChunkPickerUpdateTag>();
|
||||
}
|
||||
|
||||
// check for completion?
|
||||
// TODO: optimize
|
||||
bool test_all {true};
|
||||
@ -1517,6 +1512,15 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have& e) {
|
||||
remote_have_peer.have = BitSet{};
|
||||
}
|
||||
|
||||
if (o.all_of<ObjComp::F::TagLocalHaveAll>()) {
|
||||
return true; // we dont care beyond this point
|
||||
}
|
||||
|
||||
if (a_valid_change) {
|
||||
// new have? nice
|
||||
c.emplace_or_replace<ChunkPickerUpdateTag>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1566,15 +1570,16 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_bitset& e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& remote_have = o.get_or_emplace<Components::RemoteHaveBitset>().others;
|
||||
auto& remote_have = o.get_or_emplace<ObjComp::F::RemoteHaveBitset>().others;
|
||||
if (!remote_have.contains(c)) {
|
||||
// init
|
||||
remote_have.emplace(c, Components::RemoteHaveBitset::Entry{false, num_total_chunks});
|
||||
remote_have.emplace(c, ObjComp::F::RemoteHaveBitset::Entry{false, num_total_chunks});
|
||||
}
|
||||
|
||||
auto& remote_have_peer = remote_have.at(c);
|
||||
if (!remote_have_peer.have_all) { // TODO: maybe unset with bitset?
|
||||
BitSet event_bitset{e.chunk_bitset};
|
||||
// TODO: range replace instead
|
||||
remote_have_peer.have.merge(event_bitset, e.start_chunk);
|
||||
|
||||
// check for completion?
|
||||
@ -1629,8 +1634,8 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCEXT_ft1_have_all& e) {
|
||||
// we might not know yet
|
||||
addParticipation(c, o);
|
||||
|
||||
auto& remote_have = o.get_or_emplace<Components::RemoteHaveBitset>().others;
|
||||
remote_have[c] = Components::RemoteHaveBitset::Entry{true, {}};
|
||||
auto& remote_have = o.get_or_emplace<ObjComp::F::RemoteHaveBitset>().others;
|
||||
remote_have[c] = ObjComp::F::RemoteHaveBitset::Entry{true, {}};
|
||||
|
||||
// new have? nice
|
||||
c.emplace_or_replace<ChunkPickerUpdateTag>();
|
||||
|
Loading…
Reference in New Issue
Block a user