From 4cb583810c50dadd6794e1118d80088f685db729 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Sun, 16 Jun 2019 10:30:28 +0200 Subject: [PATCH] fix /block --- src/main/scala/hackhack/AppRegistry.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/hackhack/AppRegistry.scala b/src/main/scala/hackhack/AppRegistry.scala index 58bb3dc..bc64f67 100644 --- a/src/main/scala/hackhack/AppRegistry.scala +++ b/src/main/scala/hackhack/AppRegistry.scala @@ -181,14 +181,14 @@ class AppRegistry[F[_]: Monad: Concurrent: ContextShift: Timer: LiftIO]( } } - def getBlock(name: String, height: Long) = + def getBlock(name: String, height: Long): EitherT[F, Throwable, String] = for { appOpt <- EitherT.right(apps.get.flatMap(map => Traverse[Option].sequence(map.get(name).map(_.get)))) app <- appOpt .fold(new Exception(s"There is no app $name").asLeft[App])(_.asRight) .toEitherT[F] - block <- rpc(name, app.peer, s"/block?height=$height") + block <- rpc(name, app.peer, s"/block", "height" -> "10") } yield block.spaces2 private def log(str: String) = EitherT(IO(println(str)).attempt.to[F]) @@ -227,10 +227,11 @@ class AppRegistry[F[_]: Monad: Concurrent: ContextShift: Timer: LiftIO]( private def rpc(appName: String, peer: Peer, - path: String): EitherT[F, Throwable, Json] = + path: String, + params: (String, String)*): EitherT[F, Throwable, Json] = Backoff.default.retry( sttp - .get(peer.RpcUri.path(path)) + .get(peer.RpcUri.path(path).params(params : _*)) .send[EitherT[F, Throwable, ?]] .subflatMap( _.body