SnodeAPI scope

This commit is contained in:
SessionHero01 2024-10-30 16:24:43 +11:00
parent 3870ea42b7
commit 905acab3f4
No known key found for this signature in database

View File

@ -138,7 +138,7 @@ object SnodeAPI {
JsonUtil.fromJson(it.body ?: throw Error.Generic, Map::class.java) JsonUtil.fromJson(it.body ?: throw Error.Generic, Map::class.java)
} }
else -> GlobalScope.asyncPromise { else -> scope.asyncPromise {
HTTP.execute( HTTP.execute(
HTTP.Verb.POST, HTTP.Verb.POST,
url = "${snode.address}:${snode.port}/storage_rpc/v1", url = "${snode.address}:${snode.port}/storage_rpc/v1",
@ -191,7 +191,7 @@ object SnodeAPI {
} }
internal fun getRandomSnode(): Promise<Snode, Exception> = internal fun getRandomSnode(): Promise<Snode, Exception> =
snodePool.takeIf { it.size >= minimumSnodePoolCount }?.secureRandom()?.let { Promise.of(it) } ?: GlobalScope.asyncPromise { snodePool.takeIf { it.size >= minimumSnodePoolCount }?.secureRandom()?.let { Promise.of(it) } ?: scope.asyncPromise {
val target = seedNodePool.random() val target = seedNodePool.random()
Log.d("Loki", "Populating snode pool using: $target.") Log.d("Loki", "Populating snode pool using: $target.")
val url = "$target/json_rpc" val url = "$target/json_rpc"
@ -240,7 +240,7 @@ object SnodeAPI {
} }
// Public API // Public API
fun getAccountID(onsName: String): Promise<String, Exception> = GlobalScope.asyncPromise { fun getAccountID(onsName: String): Promise<String, Exception> = scope.asyncPromise {
val validationCount = 3 val validationCount = 3
val accountIDByteCount = 33 val accountIDByteCount = 33
// Hash the ONS name using BLAKE2b // Hash the ONS name using BLAKE2b