From 5e884fd3eec14159abc2d3318b1ded884cfec478 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 23 Oct 2024 13:46:00 +0200 Subject: [PATCH] dont delay recv_done and check on init info --- solanaceae/ngc_ft1/ngcft1.cpp | 24 ++++++++++++++++-------- solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/solanaceae/ngc_ft1/ngcft1.cpp b/solanaceae/ngc_ft1/ngcft1.cpp index ade1c83..14f665e 100644 --- a/solanaceae/ngc_ft1/ngcft1.cpp +++ b/solanaceae/ngc_ft1/ngcft1.cpp @@ -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; diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index 5f1b6be..e04aad0 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -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(e.file_kind), e.file_id, e.file_id_size, o.get().data.size(), &transfer_id - ); - - _sending_transfers.emplaceInfo( - e.group_number, e.peer_number, - transfer_id, - SendingTransfers::Entry::Info{ - o.get().data - } - ); + )) { + _sending_transfers.emplaceInfo( + e.group_number, e.peer_number, + transfer_id, + SendingTransfers::Entry::Info{ + o.get().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