-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
# Conflicts: # Readme.md
- Loading branch information
Showing
10 changed files
with
279 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# PermaScorex | ||
# Lagonaki | ||
|
||
This is permacoin implementation on top of Scorex framework. | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
app { | ||
product = "Scorex" | ||
release = "Lagonaki" | ||
version = "1.2.2" | ||
consensusAlgo = "perma" | ||
} |
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
103 changes: 103 additions & 0 deletions
103
src/main/scala/scorex/lagonaki/http/DebugApiRoute.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,103 @@ | ||
package scorex.lagonaki.http | ||
|
||
import javax.ws.rs.Path | ||
|
||
import akka.actor.ActorRefFactory | ||
import com.wordnik.swagger.annotations._ | ||
import play.api.libs.json.Json | ||
import scorex.api.http._ | ||
import scorex.app.Application | ||
import scorex.crypto.encode.Base58 | ||
import scorex.crypto.hash.FastCryptographicHash | ||
import scorex.transaction.state.database.blockchain.StoredState | ||
import spray.routing.Route | ||
|
||
@Api(value = "/debug", description = "Debug methods", position = 1) | ||
case class DebugApiRoute(override val application: Application)(implicit val context: ActorRefFactory) | ||
extends ApiRoute with CommonTransactionApiFunctions { | ||
|
||
implicit lazy val transactionModule = application.transactionModule | ||
lazy val wallet = application.wallet | ||
|
||
override lazy val route = pathPrefix("debug") { | ||
blocks ~ state ~ stateAt ~ info ~ settings | ||
} | ||
|
||
@Path("/blocks/{howMany}") | ||
@ApiOperation(value = "Blocks", notes = "Get sizes and full hashes for last blocks", httpMethod = "GET") | ||
@ApiImplicitParams(Array( | ||
new ApiImplicitParam( | ||
name = "howMany", | ||
value = "How many last blocks to take", | ||
required = true, | ||
dataType = "String", | ||
paramType = "path") | ||
)) | ||
def blocks: Route = { | ||
path("blocks" / IntNumber) { case howMany => | ||
jsonRoute { | ||
Json.arr(application.blockStorage.history.lastBlocks(howMany).map { block => | ||
val bytes = block.bytes | ||
Json.obj(bytes.length.toString -> Base58.encode(FastCryptographicHash(bytes))) | ||
}).toString() | ||
} | ||
} | ||
} | ||
|
||
@Path("/state") | ||
@ApiOperation(value = "State", notes = "Get current state", httpMethod = "GET") | ||
@ApiResponses(Array( | ||
new ApiResponse(code = 200, message = "Json state") | ||
)) | ||
def state: Route = { | ||
path("state") { | ||
jsonRoute { | ||
application.blockStorage.state.toString | ||
} | ||
} | ||
} | ||
|
||
@Path("/state/{height}") | ||
@ApiOperation(value = "State at block", notes = "Get state at specified height", httpMethod = "GET") | ||
@ApiImplicitParams(Array( | ||
new ApiImplicitParam(name = "height", value = "height", required = true, dataType = "Int", paramType = "path") | ||
)) | ||
def stateAt: Route = { | ||
path("state" / IntNumber) { case height => | ||
jsonRoute { | ||
application.blockStorage.state.asInstanceOf[StoredState].toJson(Some(height)).toString | ||
} | ||
} | ||
} | ||
|
||
@Path("/info") | ||
@ApiOperation(value = "State", notes = "All info you need to debug", httpMethod = "GET") | ||
@ApiResponses(Array( | ||
new ApiResponse(code = 200, message = "Json state") | ||
)) | ||
def info: Route = { | ||
path("info") { | ||
jsonRoute { | ||
val state = application.blockStorage.state.asInstanceOf[StoredState] | ||
Json.obj( | ||
"stateHeight" -> state.stateHeight, | ||
"stateHash" -> state.hash | ||
).toString | ||
} | ||
} | ||
} | ||
|
||
@Path("/settings") | ||
@ApiOperation(value = "State", notes = "Settings file", httpMethod = "GET") | ||
@ApiResponses(Array( | ||
new ApiResponse(code = 200, message = "Json state") | ||
)) | ||
def settings: Route = { | ||
path("settings") { | ||
jsonRoute { | ||
application.settings.settingsJSON.toString() | ||
} | ||
} | ||
} | ||
|
||
} |
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,65 @@ | ||
package scorex.lagonaki.http | ||
|
||
import javax.ws.rs.Path | ||
|
||
import akka.actor.ActorRefFactory | ||
import akka.pattern.ask | ||
import com.wordnik.swagger.annotations._ | ||
import play.api.libs.json.Json | ||
import scorex.api.http.{ApiRoute, CommonApiFunctions} | ||
import scorex.app.Application | ||
import scorex.consensus.mining.BlockGeneratorController._ | ||
import scorex.lagonaki.settings.Constants | ||
import scorex.network.HistorySynchronizer | ||
import spray.routing.Route | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
@Api(value = "scorex", description = "General commands & information", position = 0) | ||
case class ScorexApiRoute(override val application: Application)(implicit val context: ActorRefFactory) | ||
extends ApiRoute with CommonApiFunctions { | ||
|
||
override lazy val route = | ||
pathPrefix("scorex") { | ||
scorex ~ status ~ version | ||
} | ||
|
||
@Path("/version") | ||
@ApiOperation(value = "Version", notes = "get Scorex version", httpMethod = "GET") | ||
@ApiResponses(Array( | ||
new ApiResponse(code = 200, message = "Json Scorex version") | ||
)) | ||
def version: Route = { | ||
path("version") { | ||
jsonRoute { | ||
Json.obj("version" -> Constants.AgentName).toString() | ||
} | ||
} | ||
} | ||
|
||
@Path("/stop") | ||
@ApiOperation(value = "Stop", notes = "Stop the app", httpMethod = "POST") | ||
def scorex: Route = path("stop") { | ||
jsonRoute({ | ||
Future(application.stopAll()) | ||
Json.obj("stopped" -> true).toString() | ||
}, post) | ||
} | ||
|
||
@Path("/status") | ||
@ApiOperation(value = "Status", notes = "Get status of the running core(Offline/Syncing/Generating)", httpMethod = "GET") | ||
def status: Route = path("status") { | ||
jsonRoute { | ||
def bgf = (application.blockGenerator ? GetStatus).map(_.toString) | ||
def hsf = (application.historySynchronizer ? HistorySynchronizer.GetStatus).map(_.toString) | ||
|
||
Future.sequence(Seq(bgf, hsf)).map { case statusesSeq => | ||
Json.obj( | ||
"block_generator_status" -> statusesSeq.head, | ||
"history_synchronization_status" -> statusesSeq.tail.head | ||
).toString() | ||
} | ||
} | ||
} | ||
} |
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,17 @@ | ||
package scorex.lagonaki.settings | ||
|
||
import com.typesafe.config.ConfigFactory | ||
import scorex.utils.ScorexLogging | ||
|
||
/** | ||
* System constants here. | ||
*/ | ||
|
||
object Constants extends ScorexLogging { | ||
private val appConf = ConfigFactory.load().getConfig("app") | ||
|
||
val Product = appConf.getString("product") | ||
val Release = appConf.getString("release") | ||
val VersionString = appConf.getString("version") | ||
val AgentName = s"$Product - $Release v. $VersionString" | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/scala/scorex/lagonaki/settings/LagonakiSettings.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,7 @@ | ||
package scorex.lagonaki.settings | ||
|
||
import scorex.perma.settings.PermaSettings | ||
import scorex.settings.Settings | ||
import scorex.transaction.TransactionSettings | ||
|
||
class LagonakiSettings(override val filename: String) extends Settings with TransactionSettings with PermaSettings |