mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 10:05:15 +00:00
Tweak to snode filtering
This commit is contained in:
parent
2644e7c11a
commit
af9f581f18
@ -194,16 +194,18 @@ object OnionRequestAPI {
|
||||
val result = listOf( guardSnode ) + (0 until (pathSize - 1)).mapIndexed() { index, _ ->
|
||||
var pathSnode = unusedSnodes.getRandomElement()
|
||||
|
||||
// we want to make sure the last node in the path is above version 2.8.0
|
||||
// For the last node: We need to make sure the version is >= 2.8.0
|
||||
// to help with an issue that will disappear once the nodes are all updated
|
||||
if(index == pathSize - 2) {
|
||||
// because we are now grabbing the whole node pool there should always
|
||||
// be a node that is above version 2.8.0
|
||||
while(Util.compareVersions(pathSnode.version, "2.8.0") < 0) {
|
||||
pathSnode = unusedSnodes.getRandomElement()
|
||||
val suitableSnodes = unusedSnodes.filter { Util.compareVersions(it.version, "2.8.0") >= 0 }
|
||||
pathSnode = if (suitableSnodes.isNotEmpty()) {
|
||||
suitableSnodes.random()
|
||||
} else {
|
||||
throw InsufficientSnodesException()
|
||||
}
|
||||
}
|
||||
|
||||
// remove the snode from the unused list and return it
|
||||
unusedSnodes = unusedSnodes.minus(pathSnode)
|
||||
pathSnode
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user