Skip to content

Commit

Permalink
optimize p2p
Browse files Browse the repository at this point in the history
  • Loading branch information
leasontou committed Sep 20, 2019
1 parent f9cc27b commit f136abe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/jvm/src/main/scala/jbok/core/peer/PeerManager.scala
Expand Up @@ -4,7 +4,7 @@ import cats.effect._
import cats.implicits._
import fs2._
import jbok.common.log.Logger
import jbok.core.messages.{SignedTransactions, Status}
import jbok.core.messages.{NewBlock, SignedTransactions, Status}
import jbok.core.models.Block
import jbok.core.peer.PeerSelector.PeerSelector
import jbok.core.queue.Producer
Expand Down Expand Up @@ -53,6 +53,12 @@ final class PeerManager[F[_]](
_ <- selected.traverse(_.markTxs(stxs))
_ <- log.d(s"distribute ${stxs} to ${selected} end")
}yield()
case Request(_, NewBlock.name, _, _) =>
for {
newBlock <- message.as[NewBlock]
blockHeader = newBlock.block.header
_ <- selected.traverse(_.markBlock(blockHeader.hash,blockHeader.number))
}yield ()
case _ => F.unit
}
}else F.unit
Expand Down
Expand Up @@ -46,6 +46,7 @@ final class BlockExecutor[F[_]](
def handleReceivedBlock(received: ReceivedBlock[F]): F[List[Block]] =
for {
result <- importBlock(received.block)
_ <- received.peer.markBlock(received.block.header.hash,received.block.header.number)
} yield result

def handleSyncBlocks(requested: SyncBlocks[F]): F[List[Block]] =
Expand Down
2 changes: 1 addition & 1 deletion project/DockerSettings.scala
Expand Up @@ -6,7 +6,7 @@ import sbt.Keys._
object DockerSettings {
val settings = Seq(
packageName in Docker := "iotchain/"+Settings.projectName,
version in Docker := "v1.0.4.r7",
version in Docker := "v1.0.4.release",
dockerCommands := Seq(
Cmd("FROM", "openjdk:8-jre"),
Cmd("RUN", "groupadd -r iotchain && useradd -r -g iotchain iotchain"),
Expand Down

0 comments on commit f136abe

Please sign in to comment.