diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 08f127db0..89fd59e39 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1345,30 +1345,6 @@ bool NodeDB::saveNodeDatabaseToDisk() return saveProto(nodeDatabaseFileName, nodeDatabaseSize, &meshtastic_NodeDatabase_msg, &nodeDatabase, false); } -void NodeDB::sortMeshDB() -{ - if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) { - lastSort = millis(); - std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) { - if (a.num == myNodeInfo.my_node_num) { - return true; - } - if (b.num == myNodeInfo.my_node_num) { - return false; - } - bool aFav = a.is_favorite; - bool bFav = b.is_favorite; - if (aFav != bFav) - return aFav; - if (a.last_heard == 0 || a.last_heard == UINT32_MAX) - return false; - if (b.last_heard == 0 || b.last_heard == UINT32_MAX) - return true; - return a.last_heard > b.last_heard; - }); - } -} - bool NodeDB::saveToDiskNoRetry(int saveWhat) { bool success = true; @@ -1698,6 +1674,30 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp) } } +void NodeDB::sortMeshDB() +{ + if (!Throttle::isWithinTimespanMs(lastSort, 1000 * 5)) { + lastSort = millis(); + std::sort(meshNodes->begin(), meshNodes->end(), [](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) { + if (a.num == myNodeInfo.my_node_num) { + return true; + } + if (b.num == myNodeInfo.my_node_num) { + return false; + } + bool aFav = a.is_favorite; + bool bFav = b.is_favorite; + if (aFav != bFav) + return aFav; + if (a.last_heard == 0 || a.last_heard == UINT32_MAX) + return false; + if (b.last_heard == 0 || b.last_heard == UINT32_MAX) + return true; + return a.last_heard > b.last_heard; + }); + } +} + uint8_t NodeDB::getMeshNodeChannel(NodeNum n) { const meshtastic_NodeInfoLite *info = getMeshNode(n);