-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6aa0fa
commit 46fb287
Showing
17 changed files
with
245 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...rc/main/scala/io/constellationnetwork/currency/l0/http/routes/ValidationErrorRoutes.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.constellationnetwork.currency.l0.http.routes | ||
|
||
import java.time.Instant | ||
|
||
import cats.effect.Async | ||
import cats.syntax.flatMap._ | ||
|
||
import io.constellationnetwork.node.shared.domain.block.processing.BlockRejectionReason | ||
import io.constellationnetwork.node.shared.infrastructure.consensus.ValidationErrorStorage | ||
import io.constellationnetwork.node.shared.snapshot.currency | ||
import io.constellationnetwork.node.shared.snapshot.currency.CurrencySnapshotEvent | ||
import io.constellationnetwork.routes.internal._ | ||
|
||
import eu.timepit.refined.auto._ | ||
import io.circe.syntax.EncoderOps | ||
import io.circe.{Encoder, Json} | ||
import org.http4s.HttpRoutes | ||
import org.http4s.circe.CirceEntityEncoder._ | ||
import org.http4s.dsl.Http4sDsl | ||
|
||
final case class ValidationErrorRoutes[F[_]: Async]( | ||
currencySnapshotValidationErrorStorage: ValidationErrorStorage[F, CurrencySnapshotEvent, Option[BlockRejectionReason]] | ||
) extends Http4sDsl[F] | ||
with PublicRoutes[F] { | ||
|
||
implicit val encoder: Encoder[(CurrencySnapshotEvent, Option[BlockRejectionReason], Instant)] = | ||
new Encoder[(CurrencySnapshotEvent, Option[BlockRejectionReason], Instant)] { | ||
override def apply(a: (CurrencySnapshotEvent, Option[BlockRejectionReason], Instant)): Json = Json.obj( | ||
( | ||
"block", | ||
a._1 match { | ||
case currency.BlockEvent(value) => value.asJson | ||
case currency.DataApplicationBlockEvent(_) => Json.Null | ||
case currency.CurrencyMessageEvent(_) => Json.Null | ||
} | ||
), | ||
("timestamp", a._3.asJson) | ||
) | ||
} | ||
|
||
override protected val prefixPath: InternalUrlPrefix = "/currency" | ||
|
||
override protected val public: HttpRoutes[F] = HttpRoutes.of[F] { | ||
case GET -> Root / "validation-errors" => | ||
currencySnapshotValidationErrorStorage.allValidationErrors.flatMap(Ok(_)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.