-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETCM-355] Send fork id in the Status message
- Loading branch information
1 parent
e72902b
commit 8c9fbe9
Showing
9 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/scala/io/iohk/ethereum/network/handshaker/EthNodeStatus64ExchangeState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.iohk.ethereum.network.handshaker | ||
|
||
import io.iohk.ethereum.forkid.ForkId | ||
import io.iohk.ethereum.network.EtcPeerManagerActor.{PeerInfo, RemoteStatus} | ||
import io.iohk.ethereum.network.p2p.messages.{BaseETH6XMessages, ProtocolVersions, ETH64} | ||
import io.iohk.ethereum.network.p2p.{Message, MessageSerializable} | ||
|
||
case class EthNodeStatus64ExchangeState( | ||
handshakerConfiguration: EtcHandshakerConfiguration | ||
) extends EtcNodeStatusExchangeState[ETH64.Status] { | ||
|
||
import handshakerConfiguration._ | ||
|
||
def applyResponseMessage: PartialFunction[Message, HandshakerState[PeerInfo]] = { case status: ETH64.Status => | ||
// TODO: validate fork id of the remote peer | ||
applyRemoteStatusMessage(RemoteStatus(status)) | ||
} | ||
|
||
override protected def createStatusMsg(): MessageSerializable = { | ||
val bestBlockHeader = getBestBlockHeader() | ||
val chainWeight = blockchain.getChainWeightByHash(bestBlockHeader.hash).get | ||
val genesisHash = blockchain.genesisHeader.hash | ||
|
||
val status = ETH64.Status( | ||
protocolVersion = ProtocolVersions.ETH64.version, | ||
networkId = peerConfiguration.networkId, | ||
totalDifficulty = chainWeight.totalDifficulty, | ||
bestHash = bestBlockHeader.hash, | ||
genesisHash = genesisHash, | ||
forkId = ForkId.create(genesisHash, blockchainConfig)(blockchain.getBestBlockNumber()) | ||
) | ||
|
||
log.debug(s"Sending status $status") | ||
status | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters