Skip to content

Commit 8bbc7b8

Browse files
committed
ETCM-168: Log what a failed Packet looks like.
1 parent 8bb4a6f commit 8bbc7b8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scalanet/discovery/src/io/iohk/scalanet/discovery/ethereum/v4/DiscoveryNetwork.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ object DiscoveryNetwork {
134134
}
135135

136136
case Attempt.Failure(err) =>
137-
Task.raiseError(
138-
new PacketException(s"Failed to unpack message: $err")
139-
)
137+
Task(logger.debug(s"Failed to unpack packet: $err; ${packet.show}")) >>
138+
Task.raiseError(new PacketException(s"Failed to unpack message: $err"))
140139
}
141140
}
142141

scalanet/discovery/src/io/iohk/scalanet/discovery/ethereum/v4/Packet.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.iohk.scalanet.discovery.ethereum.v4
22

3+
import cats.Show
34
import io.iohk.scalanet.discovery.hash.{Hash, Keccak256}
45
import io.iohk.scalanet.discovery.crypto.{SigAlg, PrivateKey, PublicKey, Signature}
56
import scodec.bits.BitVector
@@ -86,4 +87,8 @@ object Packet {
8687
publicKey <- sigalg.recoverPublicKey(packet.signature, packet.data)
8788
payload <- codec.decodeValue(packet.data)
8889
} yield (payload, publicKey)
90+
91+
implicit val show: Show[Packet] = Show.show[Packet] { p =>
92+
s"""Packet(hash = hex"${p.hash.toHex}", signature = hex"${p.signature.toHex}", data = hex"${p.data.toHex}")"""
93+
}
8994
}

0 commit comments

Comments
 (0)