Skip to content

Commit 31d7b63

Browse files
committed
ETCM-168: ENR content constructor.
1 parent 1ab041f commit 31d7b63

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scalanet/discovery/src/io/iohk/scalanet/discovery/ethereum/EthereumNodeRecord.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ object EthereumNodeRecord {
2525
// Normally clients treat the values as RLP, however we don't have access to the RLP types here, hence it's just bytes.
2626
attrs: SortedMap[ByteVector, ByteVector]
2727
)
28+
object Content {
29+
def apply(seq: Long, attrs: (ByteVector, ByteVector)*): Content =
30+
Content(seq, SortedMap(attrs: _*))
31+
}
2832

2933
object Keys {
3034
private def key(k: String): ByteVector =
@@ -61,14 +65,14 @@ object EthereumNodeRecord {
6165
def apply(signature: Signature, seq: Long, attrs: (ByteVector, ByteVector)*): EthereumNodeRecord =
6266
EthereumNodeRecord(
6367
signature,
64-
EthereumNodeRecord.Content(seq, SortedMap(attrs: _*))
68+
EthereumNodeRecord.Content(seq, attrs: _*)
6569
)
6670

6771
def apply(privateKey: PrivateKey, seq: Long, attrs: (ByteVector, ByteVector)*)(
6872
implicit sigalg: SigAlg,
6973
codec: Codec[Content]
7074
): Attempt[EthereumNodeRecord] = {
71-
val content = EthereumNodeRecord.Content(seq, SortedMap(attrs: _*))
75+
val content = EthereumNodeRecord.Content(seq, attrs: _*)
7276
codec.encode(content).map { data =>
7377
val sig = sigalg.removeRecoveryId(sigalg.sign(privateKey, data))
7478
EthereumNodeRecord(sig, content)

0 commit comments

Comments
 (0)