fix: add nodeDBbyNodeNum temp var to avoid concurrent modifications

pull/610/head
andrekir 2023-04-01 06:43:41 -03:00
rodzic 8154d3a10f
commit e6d19d9e6d
1 zmienionych plików z 1 dodań i 11 usunięć

Wyświetl plik

@ -309,6 +309,7 @@ class MeshService : Service(), Logging {
/// Save information about our mesh to disk, so we will have it when we next start the service (even before we hear from our device)
private fun saveSettings() {
myNodeInfo?.let { myInfo ->
val nodeDBbyNodeNum = nodeDBbyNodeNum.toMap()
val settings = MeshServiceSettingsData(
myInfo = myInfo,
nodeDB = nodeDBbyNodeNum.values.toTypedArray(),
@ -392,17 +393,6 @@ class MeshService : Service(), Logging {
/// Map a nodenum to a node, or throw an exception if not found
private fun toNodeInfo(n: Int) = nodeDBbyNodeNum[n] ?: throw NodeNumNotFoundException(n)
/**
* Return the nodeinfo for the local node, or null if not found
*/
private val localNodeInfo
get(): NodeInfo? =
try {
toNodeInfo(myNodeNum)
} catch (ex: Exception) {
null
}
/** Map a nodeNum to the nodeId string
If we have a NodeInfo for this ID we prefer to return the string ID inside the user record.
but some nodes might not have a user record at all (because not yet received), in that case, we return