-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
23 changed files
with
227 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
src/main/scala/com/fluency03/blockchain/api/routes/package.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,59 @@ | ||
package com.fluency03.blockchain.api | ||
|
||
import akka.http.scaladsl.model.{StatusCode, StatusCodes} | ||
|
||
package object routes { | ||
|
||
// generics | ||
val SLASH = "/" | ||
val GENERIC = "generic" | ||
val TO_SHA256 = "to-sha256" | ||
val TO_BASE64 = "to-base64" | ||
val FROM_BASE64 = "from-base64" | ||
val TO_EPOCH_TIME = "to-epoch-time" | ||
val TIME_FROM_EPOCH = "time-from-epoch" | ||
|
||
// blockchain | ||
val BLOCKCHAIN = "blockchain" | ||
|
||
// block | ||
val BLOCKS = "blocks" | ||
val BLOCK = "block" | ||
|
||
// network | ||
val PEERS = "peers" | ||
val PEER = "peer" | ||
|
||
// transaction | ||
val TRANSACTIONS = "transactions" | ||
val TRANSACTION = "transaction" | ||
|
||
/** | ||
* Concatenate a seq of String segments into full API path | ||
*/ | ||
def pathOf(seg: String*): String = SLASH + seg.mkString(SLASH) | ||
|
||
/** | ||
* Return either SuccessMsg (if fun successfully returned a String) or FailureMsg (if fun failed). | ||
*/ | ||
def failsafeMsg(fun: => String): Message = | ||
try { SuccessMsg(fun) } | ||
catch { | ||
case e: Exception => FailureMsg(e.getMessage) | ||
} | ||
|
||
/** | ||
* Return either SuccessMsg (if fun successfully returned a String) or FailureMsg (if fun failed). | ||
*/ | ||
def failsafeResp(fun: => String): (StatusCode, Message) = | ||
try { (StatusCodes.OK, SuccessMsg(fun)) } | ||
catch { | ||
case e: Exception => (StatusCodes.InternalServerError, FailureMsg(e.getMessage)) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
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
3 changes: 0 additions & 3 deletions
3
src/main/scala/com/fluency03/blockchain/core/Blockchain.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
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.