Skip to content

Commit 4c300d4

Browse files
committed
[ETCM-841] Apply PR remarks
1 parent d26626b commit 4c300d4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/main/scala/io/iohk/ethereum/network/rlpx/RLPxConnectionHandler.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class RLPxConnectionHandler(
104104

105105
case Failure(ex) =>
106106
log.debug(
107-
s"[Stopping Connection] Init AuthHandshaker message handling failed for peer {} due to {}",
107+
"[Stopping Connection] Init AuthHandshaker message handling failed for peer {} due to {}",
108108
peerId,
109109
ex.getMessage
110110
)
@@ -132,7 +132,7 @@ class RLPxConnectionHandler(
132132

133133
case Failure(ex) =>
134134
log.debug(
135-
s"[Stopping Connection] Response AuthHandshaker message handling failed for peer {} due to {}",
135+
"[Stopping Connection] Response AuthHandshaker message handling failed for peer {} due to {}",
136136
peerId,
137137
ex.getMessage
138138
)
@@ -154,25 +154,25 @@ class RLPxConnectionHandler(
154154
}
155155

156156
def handleTimeout: Receive = { case AuthHandshakeTimeout =>
157-
log.debug(s"[Stopping Connection] Auth handshake timeout for peer {}", peerId)
157+
log.debug("[Stopping Connection] Auth handshake timeout for peer {}", peerId)
158158
context.parent ! ConnectionFailed
159159
context stop self
160160
}
161161

162162
def processHandshakeResult(result: AuthHandshakeResult, remainingData: ByteString): Unit =
163163
result match {
164164
case AuthHandshakeSuccess(secrets, remotePubKey) =>
165-
log.debug(s"Auth handshake succeeded for peer {}", peerId)
165+
log.debug("Auth handshake succeeded for peer {}", peerId)
166166
context.parent ! ConnectionEstablished(remotePubKey)
167167
// following the specification at https://github.com/ethereum/devp2p/blob/master/rlpx.md#initial-handshake
168168
// point 6 indicates that the next messages needs to be initial 'Hello'
169169
// Unfortunately it is hard to figure out the proper order for messages to be handled in.
170170
// FrameCodec assumes that bytes will arrive in the expected order
171171
// To alleviate potential lapses in order each chunk of data needs to be passed to FrameCodec immediately
172-
extractHello(extractor(secrets), remainingData, None, 0)
172+
extractHello(extractor(secrets), remainingData)
173173

174174
case AuthHandshakeError =>
175-
log.debug(s"[Stopping Connection] Auth handshake failed for peer {}", peerId)
175+
log.debug("[Stopping Connection] Auth handshake failed for peer {}", peerId)
176176
context.parent ! ConnectionFailed
177177
context stop self
178178
}
@@ -201,7 +201,7 @@ class RLPxConnectionHandler(
201201

202202
case AckTimeout(ackSeqNumber) if cancellableAckTimeout.exists(_.seqNumber == ackSeqNumber) =>
203203
cancellableAckTimeout.foreach(_.cancellable.cancel())
204-
log.error(s"[Stopping Connection] Sending 'Hello' to {} failed", peerId)
204+
log.error("[Stopping Connection] Sending 'Hello' to {} failed", peerId)
205205
context stop self
206206
case Received(data) =>
207207
extractHello(extractor, data, cancellableAckTimeout, seqNumber)
@@ -210,8 +210,8 @@ class RLPxConnectionHandler(
210210
private def extractHello(
211211
extractor: HelloCodec,
212212
data: ByteString,
213-
cancellableAckTimeout: Option[CancellableAckTimeout],
214-
seqNumber: Int
213+
cancellableAckTimeout: Option[CancellableAckTimeout] = None,
214+
seqNumber: Int = 0
215215
): Unit = {
216216
extractor.readHello(data) match {
217217
case Some((hello, restFrames)) =>
@@ -229,12 +229,12 @@ class RLPxConnectionHandler(
229229
seqNumber = seqNumber
230230
)
231231
case None =>
232-
log.debug(s"[Stopping Connection] Unable to negotiate protocol with {}", peerId)
232+
log.debug("[Stopping Connection] Unable to negotiate protocol with {}", peerId)
233233
context.parent ! ConnectionFailed
234234
context stop self
235235
}
236236
case None =>
237-
log.debug(s"[Stopping Connection] Did not find 'Hello' in message from {}", peerId)
237+
log.debug("[Stopping Connection] Did not find 'Hello' in message from {}", peerId)
238238
context become awaitInitialHello(extractor, cancellableAckTimeout, seqNumber)
239239
}
240240
}
@@ -255,7 +255,7 @@ class RLPxConnectionHandler(
255255
context.parent ! MessageReceived(message)
256256

257257
case Failure(ex) =>
258-
log.info(s"Cannot decode message from {}, because of {}", peerId, ex.getMessage)
258+
log.info("Cannot decode message from {}, because of {}", peerId, ex.getMessage)
259259
// break connection in case of failed decoding, to avoid attack which would send us garbage
260260
context stop self
261261
}
@@ -303,7 +303,7 @@ class RLPxConnectionHandler(
303303

304304
case AckTimeout(ackSeqNumber) if cancellableAckTimeout.exists(_.seqNumber == ackSeqNumber) =>
305305
cancellableAckTimeout.foreach(_.cancellable.cancel())
306-
log.debug(s"[Stopping Connection] Write to {} failed", peerId)
306+
log.debug("[Stopping Connection] Write to {} failed", peerId)
307307
context stop self
308308
}
309309
}
@@ -325,7 +325,7 @@ class RLPxConnectionHandler(
325325
): Unit = {
326326
val out = messageCodec.encodeMessage(messageToSend)
327327
connection ! Write(out, Ack)
328-
log.debug(s"Sent message: {} to {}", messageToSend.underlyingMsg.toShortString, peerId)
328+
log.debug("Sent message: {} to {}", messageToSend.underlyingMsg.toShortString, peerId)
329329

330330
val timeout = system.scheduler.scheduleOnce(rlpxConfiguration.waitForTcpAckTimeout, self, AckTimeout(seqNumber))
331331
context become handshaked(
@@ -349,7 +349,7 @@ class RLPxConnectionHandler(
349349

350350
def handleWriteFailed: Receive = { case CommandFailed(cmd: Write) =>
351351
log.debug(
352-
s"[Stopping Connection] Write to peer {} failed, trying to send {}",
352+
"[Stopping Connection] Write to peer {} failed, trying to send {}",
353353
peerId,
354354
Hex.toHexString(cmd.data.toArray[Byte])
355355
)
@@ -358,10 +358,10 @@ class RLPxConnectionHandler(
358358

359359
def handleConnectionClosed: Receive = { case msg: ConnectionClosed =>
360360
if (msg.isPeerClosed) {
361-
log.debug(s"[Stopping Connection] Connection with {} closed by peer", peerId)
361+
log.debug("[Stopping Connection] Connection with {} closed by peer", peerId)
362362
}
363363
if (msg.isErrorClosed) {
364-
log.debug(s"[Stopping Connection] Connection with {} closed because of error {}", peerId, msg.getErrorCause)
364+
log.debug("[Stopping Connection] Connection with {} closed because of error {}", peerId, msg.getErrorCause)
365365
}
366366

367367
context stop self

0 commit comments

Comments
 (0)