Skip to content

Commit

Permalink
Fix LiteClient retry
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau committed Dec 23, 2022
1 parent 34465c6 commit 6d960b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

```kotlin
dependencies {
implementation("org.ton:ton-kotlin:0.2.1")
implementation("org.ton:ton-kotlin:0.2.2")
}
```

Expand All @@ -21,7 +21,7 @@ https://github.com/andreypfau/ton-kotlin/wiki/TON-Kotlin-documentation

<!-- Badges -->

[maven-central]: https://search.maven.org/artifact/io.github.andreypfau/org.ton/ton-kotlin/0.2.1/pom
[maven-central]: https://search.maven.org/artifact/org.ton/ton-kotlin

[license]: LICENSE
[kotlin]: http://kotlinlang.org
Expand Down
22 changes: 11 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val isCI = System.getenv("CI") == "true"

allprojects {
group = "org.ton"
version = "0.2.1"
version = "0.2.2"

apply(plugin = "kotlin-multiplatform")
apply(plugin = "kotlinx-serialization")
Expand Down Expand Up @@ -107,16 +107,16 @@ allprojects {
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/andreypfau/ton-kotlin")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
// repositories {
// maven {
// name = "GitHubPackages"
// url = uri("https://maven.pkg.github.com/andreypfau/ton-kotlin")
// credentials {
// username = System.getenv("GITHUB_ACTOR")
// password = System.getenv("GITHUB_TOKEN")
// }
// }
// }
}

signing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ public class AdnlClientImpl(
val adnlConnection = connectionPool.selectConnection(liteServerDesc)
val queryId = Bits256(Random.nextBytes(32))
val context = SupervisorJob()
val queryData = data.readBytes()
try {
return withTimeout(timeout) {
val response = adnlConnection.execute(
AdnlRequestData(
buildPacket {
AdnlMessageQuery.encodeBoxed(
this, AdnlMessageQuery(queryId, data.readBytes())
this, AdnlMessageQuery(queryId, queryData)
)
}.readBytes(),
context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public class LiteClient(
var attempts = 0
var exception: Exception? = null
var liteServer: LiteServerDesc? = null
while (attempts < 10) {
val bytes = query.readBytes()
while (attempts < maxOf(5, serverList.size)) {
try {
liteServer = serverList[currentServer++ % serverList.size]
val client = AdnlClientImpl(liteServer)
return client.sendQuery(query, 10.seconds)
return client.sendQuery(ByteReadPacket(bytes), 10.seconds)
} catch (e: Exception) {
exception = e
attempts++
Expand Down

0 comments on commit 6d960b9

Please sign in to comment.