Skip to content

Commit

Permalink
HttpEngineApiClient: added timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
vsuharnikov committed Nov 11, 2024
1 parent a692b69 commit 2dc311a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/units/client/engine/HttpEngineApiClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
}

def getBlockByHash(hash: BlockHash): JobResult[Option[EcBlock]] = {
sendRequest[GetBlockByHashRequest, EcBlock](GetBlockByHashRequest(hash))
sendRequest[GetBlockByHashRequest, EcBlock](GetBlockByHashRequest(hash), NonBlockExecutionTimeout)
.leftMap(err => ClientError(s"Error getting block by hash $hash: $err"))
}

def getBlockByHashJson(hash: BlockHash): JobResult[Option[JsObject]] = {
sendRequest[GetBlockByHashRequest, JsObject](GetBlockByHashRequest(hash))
sendRequest[GetBlockByHashRequest, JsObject](GetBlockByHashRequest(hash), NonBlockExecutionTimeout)
.leftMap(err => ClientError(s"Error getting block json by hash $hash: $err"))
}

Expand All @@ -101,12 +101,12 @@ class HttpEngineApiClient(val config: JsonRpcClient.Config, val backend: SttpBac
getBlockByHash(hash).map(_.isDefined)

private def getBlockByNumberJson(number: String): JobResult[Option[JsObject]] = {
sendRequest[GetBlockByNumberRequest, JsObject](GetBlockByNumberRequest(number))
sendRequest[GetBlockByNumberRequest, JsObject](GetBlockByNumberRequest(number), NonBlockExecutionTimeout)
.leftMap(err => ClientError(s"Error getting block by number $number: $err"))
}

override def getLogs(hash: BlockHash, address: EthAddress, topic: String): JobResult[List[GetLogsResponseEntry]] =
sendRequest[GetLogsRequest, List[GetLogsResponseEntry]](GetLogsRequest(hash, address, List(topic)))
sendRequest[GetLogsRequest, List[GetLogsResponseEntry]](GetLogsRequest(hash, address, List(topic)), NonBlockExecutionTimeout)
.leftMap(err => ClientError(s"Error getting block logs by hash $hash: $err"))
.map(_.getOrElse(List.empty))

Expand Down

0 comments on commit 2dc311a

Please sign in to comment.