Don't ever delete own node from DB (#3122)

This commit is contained in:
Jonathan Bennett
2024-01-22 20:13:27 -06:00
committed by GitHub
parent 6b5101ec67
commit 4ae5443c3b
2 changed files with 5 additions and 2 deletions

View File

@@ -879,10 +879,11 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
if ((*numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < meshtastic_NodeInfoLite_size * 3)) {
if (screen)
screen->print("warning: node_db_lite full! erasing oldest entry\n");
LOG_INFO("warning: node_db_lite full! erasing oldest entry\n");
// look for oldest node and erase it
uint32_t oldest = UINT32_MAX;
int oldestIndex = -1;
for (int i = 0; i < *numMeshNodes; i++) {
for (int i = 1; i < *numMeshNodes; i++) {
if (meshNodes[i].last_heard < oldest) {
oldest = meshNodes[i].last_heard;
oldestIndex = i;
@@ -926,4 +927,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
LOG_ERROR("A critical failure occurred, portduino is exiting...");
exit(2);
#endif
}
}