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) { if (transfer.state == Group::Peer::RecvTransfer::State::FINISHING) {
transfer.finishing_timer -= time_delta; transfer.finishing_timer -= time_delta;
if (transfer.finishing_timer <= 0.f) { if (transfer.finishing_timer <= 0.f) {
dispatch( //dispatch(
NGCFT1_Event::recv_done, // NGCFT1_Event::recv_done,
Events::NGCFT1_recv_done{ // Events::NGCFT1_recv_done{
group_number, peer_number, // group_number, peer_number,
uint8_t(idx) // uint8_t(idx)
} // }
); //);
peer.recv_transfers.at(idx).reset(); 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) { bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
#if !NDEBUG #if !NDEBUG
//std::cout << "NGCFT1: got FT1_DATA\n"; //std::cout << "NGCFT1: got FT1_DATA " << e.sequence_id << "\n";
#endif #endif
if (e.data.empty()) { 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 // 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 // or implement a dedicated finished that needs to be acked
transfer.finishing_timer = 0.5f; // TODO: we are receiving, we dont know delay 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; return true;

View File

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