-
Notifications
You must be signed in to change notification settings - Fork 0
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
a898b18
commit d4b0531
Showing
8 changed files
with
49 additions
and
29 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
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
10 changes: 10 additions & 0 deletions
10
src/main/scala/units/client/engine/model/PayloadState.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,10 @@ | ||
package units.client.engine.model | ||
|
||
import units.BlockHash | ||
import play.api.libs.json.{Json, Reads} | ||
|
||
case class PayloadState(status: PayloadStatus, latestValidHash: Option[BlockHash], validationError: Option[String]) | ||
|
||
object PayloadState { | ||
implicit val reads: Reads[PayloadState] = Json.reads | ||
} |
17 changes: 13 additions & 4 deletions
17
src/main/scala/units/client/engine/model/PayloadStatus.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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
package units.client.engine.model | ||
|
||
import units.BlockHash | ||
import play.api.libs.json.{Json, Reads} | ||
import play.api.libs.json.Reads | ||
|
||
case class PayloadStatus(status: String, latestValidHash: Option[BlockHash], validationError: Option[String]) | ||
sealed abstract class PayloadStatus(val value: String) { | ||
override def toString: String = value | ||
} | ||
|
||
object PayloadStatus { | ||
implicit val reads: Reads[PayloadStatus] = Json.reads | ||
case object Valid extends PayloadStatus("VALID") | ||
case object Syncing extends PayloadStatus("SYNCING") | ||
case class Unexpected(override val value: String) extends PayloadStatus(value) | ||
|
||
implicit val reads: Reads[PayloadStatus] = Reads.of[String].map { | ||
case "VALID" => Valid | ||
case "SYNCING" => Syncing | ||
case other => Unexpected(other) | ||
} | ||
} |
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