This repository has been archived by the owner on Apr 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing #191 : forks resolutionw. remembering semantic validity
- Loading branch information
Showing
7 changed files
with
122 additions
and
44 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
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
33 changes: 28 additions & 5 deletions
33
src/main/scala/scorex/core/consensus/ModifierSemanticValidity.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,7 +1,30 @@ | ||
package scorex.core.consensus | ||
|
||
sealed trait ModifierSemanticValidity | ||
case object Absent extends ModifierSemanticValidity | ||
case object Unknown extends ModifierSemanticValidity | ||
case object Valid extends ModifierSemanticValidity | ||
case object Invalid extends ModifierSemanticValidity | ||
sealed trait ModifierSemanticValidity { | ||
val code: Byte | ||
} | ||
|
||
object ModifierSemanticValidity { | ||
def restoreFromCode(code: Byte): ModifierSemanticValidity = code match { | ||
case b: Byte if b == Absent.code => Absent | ||
case b: Byte if b == Unknown.code => Unknown | ||
case b: Byte if b == Valid.code => Valid | ||
case b: Byte if b == Invalid.code => Invalid | ||
} | ||
} | ||
|
||
case object Absent extends ModifierSemanticValidity { | ||
override val code = 0 | ||
} | ||
|
||
case object Unknown extends ModifierSemanticValidity { | ||
override val code = 1 | ||
} | ||
|
||
case object Valid extends ModifierSemanticValidity { | ||
override val code = 2 | ||
} | ||
|
||
case object Invalid extends ModifierSemanticValidity { | ||
override val code = 3 | ||
} |