Optimization: stop relaying when reply is received (#3753)

This commit is contained in:
GUVWAF 2024-05-01 03:07:15 +02:00 committed by GitHub
parent 21311bbeda
commit e51ee91c39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,11 +35,10 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
{ {
bool isAck = bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0);
((c && c->error_reason == meshtastic_Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK if (isAckorReply && p->to != getNodeNum() && p->to != NODENUM_BROADCAST) {
if (isAck && p->to != getNodeNum()) { // do not flood direct message that is ACKed or replied to
// do not flood direct message that is ACKed LOG_DEBUG("Receiving an ACK or reply not for me, but don't need to rebroadcast this direct message anymore.\n");
LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
} }
if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {