Skip to content

Commit

Permalink
Fix - initial url is not set for http web3j service
Browse files Browse the repository at this point in the history
  • Loading branch information
valentunn committed Dec 29, 2023
1 parent 5744229 commit 3a0c2ea
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class BalancingHttpWeb3jService(
val payload: String = objectMapper.writeValueAsString(request)

val result = nodeSwitcher.makeRetryingRequest { url ->
Log.d("RX", "Found url for ${request.method} (${request.id}): $url")
val call = createHttpCall(payload, url)

call.execute().parseSingleResponse(responseType)
Expand Down Expand Up @@ -132,6 +133,8 @@ class BalancingHttpWeb3jService(
retriableProcessResponse: (okhttp3.Response) -> T,
nonRetriableProcessResponse: (T) -> Unit
) {
Log.d("RX", "Current node url: ${nodeSwitcher.getCurrentNodeUrl()}")

val url = nodeSwitcher.getCurrentNodeUrl() ?: return

val call = createHttpCall(payload, url)
Expand Down Expand Up @@ -275,8 +278,7 @@ private class NodeSwitcher(
balanceStrategy = strategy

nodeIterator = balanceStrategy.generateNodeIterator(saturatedNodes)

// we do not update currentNode since we want to be lazy here - only update node if it is failing
selectNextNode()
}

@Synchronized
Expand All @@ -286,6 +288,10 @@ private class NodeSwitcher(

@Suppress
fun markCurrentNodeNotAccessible() {
selectNextNode()
}

private fun selectNextNode() {
currentNodeUrl = nodeIterator?.next()?.saturatedUrl
}
}
Expand Down

0 comments on commit 3a0c2ea

Please sign in to comment.