dont delay recv_done and check on init info

This commit is contained in:
Green Sky 2024-10-23 13:46:00 +02:00
parent 9a4be575ba
commit 5e884fd3ee
No known key found for this signature in database
2 changed files with 26 additions and 18 deletions

View File

@ -210,13 +210,13 @@ void NGCFT1::iteratePeer(float time_delta, uint32_t group_number, uint32_t peer_
if (transfer.state == Group::Peer::RecvTransfer::State::FINISHING) {
transfer.finishing_timer -= time_delta;
if (transfer.finishing_timer <= 0.f) {
dispatch(
NGCFT1_Event::recv_done,
Events::NGCFT1_recv_done{
group_number, peer_number,
uint8_t(idx)
}
);
//dispatch(
// NGCFT1_Event::recv_done,
// Events::NGCFT1_recv_done{
// group_number, peer_number,
// uint8_t(idx)
// }
//);
peer.recv_transfers.at(idx).reset();
}
@ -543,7 +543,7 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_init_ack& e) {
bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
#if !NDEBUG
//std::cout << "NGCFT1: got FT1_DATA\n";
//std::cout << "NGCFT1: got FT1_DATA " << e.sequence_id << "\n";
#endif
if (e.data.empty()) {
@ -602,6 +602,14 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
// TODO: keep around for remote timeout + delay + offset, so we can be sure all acks where received
// or implement a dedicated finished that needs to be acked
transfer.finishing_timer = 0.5f; // TODO: we are receiving, we dont know delay
dispatch(
NGCFT1_Event::recv_done,
Events::NGCFT1_recv_done{
e.group_number, e.peer_number,
e.transfer_id
}
);
}
return true;

View File

@ -687,21 +687,21 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_request& e) {
// TODO: queue instead
//queueUpRequestInfo(e.group_number, e.peer_number, info_hash);
uint8_t transfer_id {0};
_nft.NGC_FT1_send_init_private(
if (_nft.NGC_FT1_send_init_private(
e.group_number, e.peer_number,
static_cast<uint32_t>(e.file_kind),
e.file_id, e.file_id_size,
o.get<Components::FT1InfoSHA1Data>().data.size(),
&transfer_id
);
_sending_transfers.emplaceInfo(
e.group_number, e.peer_number,
transfer_id,
SendingTransfers::Entry::Info{
o.get<Components::FT1InfoSHA1Data>().data
}
);
)) {
_sending_transfers.emplaceInfo(
e.group_number, e.peer_number,
transfer_id,
SendingTransfers::Entry::Info{
o.get<Components::FT1InfoSHA1Data>().data
}
);
}
const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number);
_tox_peer_to_contact[combine_ids(e.group_number, e.peer_number)] = c; // workaround