Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
pushAllwithNoAck
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Nov 2, 2020
1 parent 64f1a76 commit a44ed7f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/scala/scorex/core/network/PeerConnectionHandler.scala
Expand Up @@ -143,7 +143,8 @@ class PeerConnectionHandler(val settings: NetworkSettings,

case CloseConnection =>
log.info(s"Enforced to abort communication with: " + connectionId + ", switching to closing mode")
if (outMessagesBuffer.isEmpty) connection ! Close
pushAllWithNoAck()
connection ! Close

case ReceivableMessages.Ack(_) => // ignore ACKs in stable mode

Expand Down Expand Up @@ -176,10 +177,8 @@ class PeerConnectionHandler(val settings: NetworkSettings,

case CloseConnection =>
log.info(s"Enforced to abort communication with: " + connectionId + s", switching to closing mode")
pushAllWithNoAck()
connection ! Close

// writeAll()
// context become closingWithNonEmptyBuffer
}

def remoteInterface: Receive = {
Expand Down Expand Up @@ -229,6 +228,12 @@ class PeerConnectionHandler(val settings: NetworkSettings,
}
}

private def pushAllWithNoAck(): Unit = {
outMessagesBuffer.foreach { case (_, msg) =>
connection ! Write(msg, NoAck)
}
}

private def createHandshakeMessage() = {
Handshake(
PeerSpec(
Expand Down Expand Up @@ -263,7 +268,6 @@ object PeerConnectionHandler {
}

object PeerConnectionHandlerRef {

def props(settings: NetworkSettings,
networkControllerRef: ActorRef,
peerManagerRef: ActorRef,
Expand All @@ -288,5 +292,4 @@ object PeerConnectionHandlerRef {
connectionDescription: ConnectionDescription)
(implicit system: ActorSystem, ec: ExecutionContext): ActorRef =
system.actorOf(props(settings, networkControllerRef, peerManagerRef, scorexContext, connectionDescription), name)

}

0 comments on commit a44ed7f

Please sign in to comment.