mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +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, _ ->
|
val result = listOf( guardSnode ) + (0 until (pathSize - 1)).mapIndexed() { index, _ ->
|
||||||
var pathSnode = unusedSnodes.getRandomElement()
|
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
|
// to help with an issue that will disappear once the nodes are all updated
|
||||||
if(index == pathSize - 2) {
|
if(index == pathSize - 2) {
|
||||||
// because we are now grabbing the whole node pool there should always
|
val suitableSnodes = unusedSnodes.filter { Util.compareVersions(it.version, "2.8.0") >= 0 }
|
||||||
// be a node that is above version 2.8.0
|
pathSnode = if (suitableSnodes.isNotEmpty()) {
|
||||||
while(Util.compareVersions(pathSnode.version, "2.8.0") < 0) {
|
suitableSnodes.random()
|
||||||
pathSnode = unusedSnodes.getRandomElement()
|
} else {
|
||||||
|
throw InsufficientSnodesException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove the snode from the unused list and return it
|
||||||
unusedSnodes = unusedSnodes.minus(pathSnode)
|
unusedSnodes = unusedSnodes.minus(pathSnode)
|
||||||
pathSnode
|
pathSnode
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user