@@ -294,7 +294,7 @@ void PacketHistory::insert(const PacketRecord &r)
294
294
295
295
/* Check if a certain node was a relayer of a packet in the history given an ID and sender
296
296
* @return true if node was indeed a relayer, false if not */
297
- bool PacketHistory::wasRelayer (const uint8_t relayer, const uint32_t id, const NodeNum sender)
297
+ bool PacketHistory::wasRelayer (const uint8_t relayer, const uint32_t id, const NodeNum sender, bool *wasSole )
298
298
{
299
299
if (!initOk ()) {
300
300
LOG_ERROR (" PacketHistory - wasRelayer: NOT INITIALIZED!" );
@@ -322,27 +322,42 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N
322
322
found->sender , found->id , found->next_hop , millis () - found->rxTimeMsec , found->relayed_by [0 ], found->relayed_by [1 ],
323
323
found->relayed_by [2 ], relayer);
324
324
#endif
325
- return wasRelayer (relayer, *found);
325
+ return wasRelayer (relayer, *found, wasSole );
326
326
}
327
327
328
328
/* Check if a certain node was a relayer of a packet in the history given iterator
329
329
* @return true if node was indeed a relayer, false if not */
330
- bool PacketHistory::wasRelayer (const uint8_t relayer, const PacketRecord &r)
330
+ bool PacketHistory::wasRelayer (const uint8_t relayer, const PacketRecord &r, bool *wasSole )
331
331
{
332
- for (uint8_t i = 0 ; i < NUM_RELAYERS; i++) {
332
+ bool found = false ;
333
+ bool other_present = false ;
334
+
335
+ for (uint8_t i = 0 ; i < NUM_RELAYERS; ++i) {
333
336
if (r.relayed_by [i] == relayer) {
334
- #if VERBOSE_PACKET_HISTORY
335
- LOG_DEBUG (" Packet History - was rel.PR.: s=%08x id=%08x rls=%02x %02x %02x / rl=%02x? YES" , r.sender , r.id ,
336
- r.relayed_by [0 ], r.relayed_by [1 ], r.relayed_by [2 ], relayer);
337
- #endif
338
- return true ;
337
+ found = true ;
338
+ } else if (r.relayed_by [i] != 0 ) {
339
+ other_present = true ;
339
340
}
340
341
}
342
+
343
+ if (wasSole) {
344
+ *wasSole = (found && !other_present);
345
+ }
346
+
341
347
#if VERBOSE_PACKET_HISTORY
342
348
LOG_DEBUG (" Packet History - was rel.PR.: s=%08x id=%08x rls=%02x %02x %02x / rl=%02x? NO" , r.sender , r.id , r.relayed_by [0 ],
343
349
r.relayed_by [1 ], r.relayed_by [2 ], relayer);
344
350
#endif
345
- return false ;
351
+
352
+ return found;
353
+ }
354
+
355
+ // Check if a certain node was the *only* relayer of a packet in the history given an ID and sender
356
+ bool PacketHistory::wasSoleRelayer (const uint8_t relayer, const uint32_t id, const NodeNum sender)
357
+ {
358
+ bool wasSole = false ;
359
+ wasRelayer (relayer, id, sender, &wasSole);
360
+ return wasSole;
346
361
}
347
362
348
363
// Remove a relayer from the list of relayers of a packet in the history given an ID and sender
0 commit comments