Skip to content

Commit

Permalink
fix block pool routes
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed May 5, 2018
1 parent 194a85c commit 720ef1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import akka.http.scaladsl.unmarshalling.PredefinedFromStringUnmarshallers.CsvSeq
import akka.pattern.ask
import com.github.fluency03.blockchain.api.{Blocks, Input, Message}
import com.github.fluency03.blockchain.api.actors.BlockPoolActor._
import com.github.fluency03.blockchain.api.actors.BlockchainActor.MineNextBlock
import com.github.fluency03.blockchain.api.actors.BlockchainActor
import com.github.fluency03.blockchain.core.{Block, Transaction}

import scala.concurrent.Future
Expand All @@ -28,7 +28,7 @@ trait BlockPoolRoutes extends RoutesSupport {
*/

lazy val blockPoolRoutes: Route =
path(BLOCK_POOL) {
pathPrefix(BLOCK_POOL) {
path(BLOCKS) {
parameters('hashes.as(CsvSeq[String]).?) { hashesOpt: Option[Seq[String]] =>
val blocks: Future[Blocks] = hashesOpt match {
Expand Down Expand Up @@ -64,10 +64,10 @@ trait BlockPoolRoutes extends RoutesSupport {
val maybeBlock: Future[Option[Block]] = (blockPoolActor ? GetBlock(hash)).mapTo[Option[Block]]
rejectEmptyResponse { complete(maybeBlock) }
} ~
delete {
val blockDeleted: Future[Message] = (blockPoolActor ? DeleteBlock(hash)).mapTo[Message]
onSuccess(blockDeleted) { respondOnDeletion }
}
delete {
val blockDeleted: Future[Message] = (blockPoolActor ? DeleteBlock(hash)).mapTo[Message]
onSuccess(blockDeleted) { respondOnDeletion }
}
} ~
path(TRANSACTION / Segment) { id =>
get {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait TxPoolRoutes extends RoutesSupport {
*/

lazy val txPoolRoutes: Route =
path(TX_POOL) {
pathPrefix(TX_POOL) {
path(TRANSACTIONS) {
parameters('ids.as(CsvSeq[String]).?) { idsOpt =>
val transactions: Future[Transactions] = idsOpt match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.fluency03.blockchain.api.actors
import akka.actor.{ActorRef, ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit}
import com.github.fluency03.blockchain.api.actors.BlockPoolActor._
import com.github.fluency03.blockchain.api.{FailureMsg, SuccessMsg}
import com.github.fluency03.blockchain.api._
import com.github.fluency03.blockchain.core.Block
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}

Expand All @@ -14,7 +14,9 @@ class BlockPoolActorTest extends TestKit(ActorSystem("BlocksActorTest")) with Im
shutdown()
}

val blockPoolActor: ActorRef = system.actorOf(Props[BlockPoolActor])
val blockchainActor: ActorRef = system.actorOf(Props[BlockchainActor], BLOCKCHAIN_ACTOR_NAME)
val blockPoolActor: ActorRef = system.actorOf(Props[BlockPoolActor], BLOCK_POOL_ACTOR_NAME)
val txPoolActor: ActorRef = system.actorOf(Props[TxPoolActor], TX_POOL_ACTOR_NAME)

"A BlocksActor" should {
"Respond with a Seq of Blocks." in {
Expand Down

0 comments on commit 720ef1b

Please sign in to comment.