Skip to content

Commit 8648b65

Browse files
committed
[ETCM-841] Apply PR remarks
1 parent 23dc4d2 commit 8648b65

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

src/main/scala/io/iohk/ethereum/network/handshaker/EtcHelloExchangeState.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ case class EtcHelloExchangeState(handshakerConfiguration: EtcHandshakerConfigura
3232
case Some(ProtocolVersions.ETH63) => EtcNodeStatus63ExchangeState(handshakerConfiguration)
3333
case _ =>
3434
log.debug(
35-
s"Connected peer does not support ${ProtocolVersions.ETH63} / ${ProtocolVersions.ETC64} protocol. Disconnecting."
35+
s"Connected peer does not support {} / {} protocol. Disconnecting.",
36+
ProtocolVersions.ETH63,
37+
ProtocolVersions.ETC64
3638
)
3739
DisconnectedState(Disconnect.Reasons.IncompatibleP2pProtocolVersion)
3840
}

src/main/scala/io/iohk/ethereum/network/p2p/messages/Capability.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import io.iohk.ethereum.rlp.{RLPEncodeable, RLPException, RLPList, RLPSerializab
77
case class Capability(name: String, version: Byte)
88

99
object Capability {
10-
def negotiate(c1: List[Capability], c2: List[Capability]): Option[Capability] = {
10+
def negotiate(c1: List[Capability], c2: List[Capability]): Option[Capability] =
1111
c1.intersect(c2).maxByOption(_.version) // FIXME ignores branches and other protocols
12-
}
1312

1413
private val pattern = "(.*)/(\\d*)".r
1514

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ class RLPxConnectionHandler(
9999

100100
case Failure(ex) =>
101101
log.debug(
102-
s"[Stopping Connection] Init AuthHandshaker message handling failed for peer $peerId due to ${ex.getMessage}"
102+
s"[Stopping Connection] Init AuthHandshaker message handling failed for peer {} due to {}",
103+
peerId,
104+
ex.getMessage
103105
)
104106
context.parent ! ConnectionFailed
105107
context stop self
@@ -125,7 +127,9 @@ class RLPxConnectionHandler(
125127

126128
case Failure(ex) =>
127129
log.debug(
128-
s"[Stopping Connection] Response AuthHandshaker message handling failed for peer $peerId due to ${ex.getMessage}"
130+
s"[Stopping Connection] Response AuthHandshaker message handling failed for peer {} due to {}",
131+
peerId,
132+
ex.getMessage
129133
)
130134
context.parent ! ConnectionFailed
131135
context stop self
@@ -145,15 +149,15 @@ class RLPxConnectionHandler(
145149
}
146150

147151
def handleTimeout: Receive = { case AuthHandshakeTimeout =>
148-
log.debug(s"[Stopping Connection] Auth handshake timeout for peer $peerId")
152+
log.debug(s"[Stopping Connection] Auth handshake timeout for peer {}", peerId)
149153
context.parent ! ConnectionFailed
150154
context stop self
151155
}
152156

153157
def processHandshakeResult(result: AuthHandshakeResult, remainingData: ByteString): Unit =
154158
result match {
155159
case AuthHandshakeSuccess(secrets, remotePubKey) =>
156-
log.debug(s"Auth handshake succeeded for peer $peerId")
160+
log.debug(s"Auth handshake succeeded for peer {}", peerId)
157161
context.parent ! ConnectionEstablished(remotePubKey)
158162
if (remainingData.nonEmpty)
159163
context.self ! Received(remainingData)
@@ -162,7 +166,7 @@ class RLPxConnectionHandler(
162166
context become awaitInitialHello(extractor(secrets))
163167

164168
case AuthHandshakeError =>
165-
log.debug(s"[Stopping Connection] Auth handshake failed for peer $peerId")
169+
log.debug(s"[Stopping Connection] Auth handshake failed for peer {}", peerId)
166170
context.parent ! ConnectionFailed
167171
context stop self
168172
}
@@ -201,7 +205,7 @@ class RLPxConnectionHandler(
201205

202206
case AckTimeout(ackSeqNumber) if cancellableAckTimeout.exists(_.seqNumber == ackSeqNumber) =>
203207
cancellableAckTimeout.foreach(_.cancellable.cancel())
204-
log.error(s"[Stopping Connection] Sending 'Hello' to $peerId failed")
208+
log.error(s"[Stopping Connection] Sending 'Hello' to {} failed", peerId)
205209
context stop self
206210

207211
}
@@ -227,12 +231,12 @@ class RLPxConnectionHandler(
227231
seqNumber = seqNumber
228232
)
229233
case None =>
230-
log.debug(s"[Stopping Connection] Unable to negotiate protocol with $peerId")
234+
log.debug(s"[Stopping Connection] Unable to negotiate protocol with {}", peerId)
231235
context.parent ! ConnectionFailed
232236
context stop self
233237
}
234238
case None =>
235-
log.debug(s"[Stopping Connection] Did not find 'Hello' in message from $peerId")
239+
log.debug(s"[Stopping Connection] Did not find 'Hello' in message from {}", peerId)
236240
context become awaitInitialHello(extractor, cancellableAckTimeout, seqNumber)
237241
}
238242
}
@@ -253,7 +257,7 @@ class RLPxConnectionHandler(
253257
context.parent ! MessageReceived(message)
254258

255259
case Failure(ex) =>
256-
log.info(s"Cannot decode message from $peerId, because of ${ex.getMessage}")
260+
log.info(s"Cannot decode message from {}, because of {}", peerId, ex.getMessage)
257261
// break connection in case of failed decoding, to avoid attack which would send us garbage
258262
context stop self
259263
}
@@ -301,7 +305,7 @@ class RLPxConnectionHandler(
301305

302306
case AckTimeout(ackSeqNumber) if cancellableAckTimeout.exists(_.seqNumber == ackSeqNumber) =>
303307
cancellableAckTimeout.foreach(_.cancellable.cancel())
304-
log.debug(s"[Stopping Connection] Write to $peerId failed")
308+
log.debug(s"[Stopping Connection] Write to {} failed", peerId)
305309
context stop self
306310
}
307311
}
@@ -323,7 +327,7 @@ class RLPxConnectionHandler(
323327
): Unit = {
324328
val out = messageCodec.encodeMessage(messageToSend)
325329
connection ! Write(out, Ack)
326-
log.debug(s"Sent message: ${messageToSend.underlyingMsg.toShortString} to $peerId")
330+
log.debug(s"Sent message: {} to {}", messageToSend.underlyingMsg.toShortString, peerId)
327331

328332
val timeout = system.scheduler.scheduleOnce(rlpxConfiguration.waitForTcpAckTimeout, self, AckTimeout(seqNumber))
329333
context become handshaked(
@@ -347,17 +351,19 @@ class RLPxConnectionHandler(
347351

348352
def handleWriteFailed: Receive = { case CommandFailed(cmd: Write) =>
349353
log.debug(
350-
s"[Stopping Connection] Write to peer $peerId failed, trying to send ${Hex.toHexString(cmd.data.toArray[Byte])}"
354+
s"[Stopping Connection] Write to peer {} failed, trying to send {}",
355+
peerId,
356+
Hex.toHexString(cmd.data.toArray[Byte])
351357
)
352358
context stop self
353359
}
354360

355361
def handleConnectionClosed: Receive = { case msg: ConnectionClosed =>
356362
if (msg.isPeerClosed) {
357-
log.debug(s"[Stopping Connection] Connection with $peerId closed by peer")
363+
log.debug(s"[Stopping Connection] Connection with {} closed by peer", peerId)
358364
}
359365
if (msg.isErrorClosed) {
360-
log.debug(s"[Stopping Connection] Connection with $peerId closed because of error ${msg.getErrorCause}")
366+
log.debug(s"[Stopping Connection] Connection with {} closed because of error {}", peerId, msg.getErrorCause)
361367
}
362368

363369
context stop self

0 commit comments

Comments
 (0)