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

Commit

Permalink
const length for magic
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Nov 27, 2020
1 parent acbd40c commit 9166d3f
Showing 1 changed file with 2 additions and 5 deletions.
@@ -1,12 +1,10 @@
package scorex.core.network.peer

import java.net.{InetAddress, InetSocketAddress}

import scorex.core.network.PeerFeature
import scorex.core.network.PeerFeature.Id
import scorex.core.network.message.Message
import scorex.util.serialization._
import scorex.core.serialization.ScorexSerializer
import scorex.util.Extensions._

/**
* This peer feature allows to more reliably detect connections to self node and connections from other network
Expand All @@ -26,13 +24,12 @@ object SessionIdPeerFeature {

object SessionIdPeerFeatureSerializer extends ScorexSerializer[SessionIdPeerFeature] {
override def serialize(obj: SessionIdPeerFeature, w: Writer): Unit = {
w.putInt(obj.networkMagic.size)
w.putBytes(obj.networkMagic)
w.putLong(obj.sessionId)
}

override def parse(r: Reader): SessionIdPeerFeature = {
val networkMagic = r.getBytes(r.getInt())
val networkMagic = r.getBytes(Message.MagicLength)
val sessionId = r.getLong()
SessionIdPeerFeature(networkMagic, sessionId)
}
Expand Down

0 comments on commit 9166d3f

Please sign in to comment.