add participation and log spam fix

This commit is contained in:
Green Sky 2024-12-11 23:23:05 +01:00
parent 100279a483
commit eb169b2779
No known key found for this signature in database
3 changed files with 14 additions and 8 deletions

View File

@ -560,9 +560,9 @@ void SHA1_NGCFT1::onSendFileHashFinished(ObjectHandle o, Message3Registry* reg_p
updateMessages(o); // nop // TODO: remove
}
void SHA1_NGCFT1::constructFileMessageInPlace(Message3Handle msg, NGCFT1_file_kind file_kind, ByteSpan file_id) {
ObjectHandle SHA1_NGCFT1::constructFileMessageInPlace(Message3Handle msg, NGCFT1_file_kind file_kind, ByteSpan file_id) {
if (file_kind != NGCFT1_file_kind::HASH_SHA1_INFO) {
return;
return {};
}
// check if content exists
@ -624,6 +624,8 @@ void SHA1_NGCFT1::constructFileMessageInPlace(Message3Handle msg, NGCFT1_file_ki
}
_os.throwEventUpdate(o);
return o;
}
bool SHA1_NGCFT1::onEvent(const ObjectStore::Events::ObjectUpdate& e) {
@ -1304,7 +1306,12 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_message& e) {
rb.try_emplace(self_c, ts);
}
constructFileMessageInPlace({reg, new_msg_e}, e.file_kind, {e.file_id, e.file_id_size});
auto o = constructFileMessageInPlace({reg, new_msg_e}, e.file_kind, {e.file_id, e.file_id_size});
if (o) {
// the other peer just sent the file message, so it is likely they have the file
addParticipation(c, o);
}
_rmm.throwEventConstruct(reg, new_msg_e);

View File

@ -108,8 +108,7 @@ class SHA1_NGCFT1 : public ToxEventI, public RegistryMessageModelEventI, public
void onSendFileHashFinished(ObjectHandle o, Message3Registry* reg_ptr, Contact3 c, uint64_t ts);
// construct the file part in a partially constructed message
// TODO: maybe return file object?
void constructFileMessageInPlace(Message3Handle msg, NGCFT1_file_kind file_kind, ByteSpan file_id);
ObjectHandle constructFileMessageInPlace(Message3Handle msg, NGCFT1_file_kind file_kind, ByteSpan file_id);
protected: // rmm events (actions)
bool sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) override;

View File

@ -8,7 +8,7 @@
// perform binary search to find the first message not newer than ts_start
template<typename View>
auto find_start_by_ts(const View& view, uint64_t ts_start) {
std::cout << "!!!! starting msg ts search, ts_start:" << ts_start << "\n";
//std::cout << "!!!! starting msg ts search, ts_start:" << ts_start << "\n";
// -> first value smaller than start ts
auto res = std::lower_bound(
@ -22,9 +22,9 @@ auto find_start_by_ts(const View& view, uint64_t ts_start) {
if (res != view.end()) {
const auto& [ts_comp] = view.get(*res);
std::cout << "!!!! first value not newer than start ts is " << ts_comp.ts << "\n";
//std::cout << "!!!! first value not newer than start ts is " << ts_comp.ts << "\n";
} else {
std::cout << "!!!! no first value not newer than start ts\n";
//std::cout << "!!!! no first value not newer than start ts\n";
}
return res;
}