mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-03 07:15:39 +00:00
Minor performance optimization
This commit is contained in:
parent
288d76d292
commit
b798f49512
@ -34,7 +34,7 @@ object SnodeAPI {
|
|||||||
// Settings
|
// Settings
|
||||||
private val maxRetryCount = 6
|
private val maxRetryCount = 6
|
||||||
private val minimumSnodePoolCount = 12
|
private val minimumSnodePoolCount = 12
|
||||||
private val minimumSwarmSnodeCount = 2
|
private val minimumSwarmSnodeCount = 3
|
||||||
// Use port 4433 if the API level can handle the network security configuration and enforce pinned certificates
|
// Use port 4433 if the API level can handle the network security configuration and enforce pinned certificates
|
||||||
private val seedNodePort = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) 443 else 4433
|
private val seedNodePort = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) 443 else 4433
|
||||||
private val seedNodePool by lazy {
|
private val seedNodePool by lazy {
|
||||||
@ -44,7 +44,7 @@ object SnodeAPI {
|
|||||||
setOf( "https://storage.seed1.loki.network:$seedNodePort ", "https://storage.seed3.loki.network:$seedNodePort ", "https://public.loki.foundation:$seedNodePort" )
|
setOf( "https://storage.seed1.loki.network:$seedNodePort ", "https://storage.seed3.loki.network:$seedNodePort ", "https://public.loki.foundation:$seedNodePort" )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val snodeFailureThreshold = 4
|
private val snodeFailureThreshold = 3
|
||||||
private val targetSwarmSnodeCount = 2
|
private val targetSwarmSnodeCount = 2
|
||||||
private val useOnionRequests = true
|
private val useOnionRequests = true
|
||||||
|
|
||||||
@ -252,19 +252,20 @@ object SnodeAPI {
|
|||||||
|
|
||||||
private fun removeDuplicates(publicKey: String, rawMessages: List<*>): List<*> {
|
private fun removeDuplicates(publicKey: String, rawMessages: List<*>): List<*> {
|
||||||
val receivedMessageHashValues = database.getReceivedMessageHashValues(publicKey)?.toMutableSet() ?: mutableSetOf()
|
val receivedMessageHashValues = database.getReceivedMessageHashValues(publicKey)?.toMutableSet() ?: mutableSetOf()
|
||||||
return rawMessages.filter { rawMessage ->
|
val result = rawMessages.filter { rawMessage ->
|
||||||
val rawMessageAsJSON = rawMessage as? Map<*, *>
|
val rawMessageAsJSON = rawMessage as? Map<*, *>
|
||||||
val hashValue = rawMessageAsJSON?.get("hash") as? String
|
val hashValue = rawMessageAsJSON?.get("hash") as? String
|
||||||
if (hashValue != null) {
|
if (hashValue != null) {
|
||||||
val isDuplicate = receivedMessageHashValues.contains(hashValue)
|
val isDuplicate = receivedMessageHashValues.contains(hashValue)
|
||||||
receivedMessageHashValues.add(hashValue)
|
receivedMessageHashValues.add(hashValue)
|
||||||
database.setReceivedMessageHashValues(publicKey, receivedMessageHashValues)
|
|
||||||
!isDuplicate
|
!isDuplicate
|
||||||
} else {
|
} else {
|
||||||
Log.d("Loki", "Missing hash value for message: ${rawMessage?.prettifiedDescription()}.")
|
Log.d("Loki", "Missing hash value for message: ${rawMessage?.prettifiedDescription()}.")
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
database.setReceivedMessageHashValues(publicKey, receivedMessageHashValues)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseEnvelopes(rawMessages: List<*>): List<SignalServiceProtos.Envelope> {
|
private fun parseEnvelopes(rawMessages: List<*>): List<SignalServiceProtos.Envelope> {
|
||||||
@ -305,7 +306,7 @@ object SnodeAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
when (statusCode) {
|
when (statusCode) {
|
||||||
400, 500, 503 -> { // Usually indicates that the snode isn't up to date
|
400, 500, 502, 503 -> { // Usually indicates that the snode isn't up to date
|
||||||
handleBadSnode()
|
handleBadSnode()
|
||||||
}
|
}
|
||||||
406 -> {
|
406 -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user