fix(mesh): markSeen je zase idempotentní, jinak si send path ujídá dedup okno
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ce9270ff21
commit
99981ff69b
2 files changed
+49
No files matched your search
@@ -52,6 +52,23 @@ public:
|
||||
void markSeen(const mesh::Packet* packet) override {
|
||||
uint8_t hash[MAX_HASH_SIZE];
|
||||
packet->calculatePacketHash(hash);
|
||||
|
||||
// CUSTOM (TeTeHacko): idempotent, the way the single hasSeen() this replaced
|
||||
// was -- that one inserted only when the hash was absent. 1.17 split it into
|
||||
// wasSeen() + markSeen(), and while every receive-side caller still gates on
|
||||
// !wasSeen(), the SEND paths (Mesh::sendFlood, sendDirect, sendZeroHop) call
|
||||
// this one unguarded. Every re-send of the same packet then occupies another
|
||||
// slot of a fixed 160-entry ring, which shortens the dedup window and lets a
|
||||
// late echo of our own flood read as new traffic -- and on a repeater that
|
||||
// means rebroadcasting it.
|
||||
//
|
||||
// Cost is one extra 160x8 byte scan per send, which is nothing against LoRa
|
||||
// airtime. Fix taken from ALLFATHER-BV/meshcomod e62be9b (MIT).
|
||||
const uint8_t* sp = _hashes;
|
||||
for (int i = 0; i < MAX_PACKET_HASHES; i++, sp += MAX_HASH_SIZE) {
|
||||
if (memcmp(hash, sp, MAX_HASH_SIZE) == 0) return; // already recorded
|
||||
}
|
||||
|
||||
memcpy(&_hashes[_next_idx * MAX_HASH_SIZE], hash, MAX_HASH_SIZE);
|
||||
_next_idx = (_next_idx + 1) % MAX_PACKET_HASHES;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user