Skip to content

Commit

Permalink
[ETCM-355] Remove capabilities from EtcHandshakerConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-golebiewski committed Jun 30, 2021
1 parent c627fe8 commit 4aef984
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
override val blockchainReader: BlockchainReader = CommonFakePeer.this.blockchainReader
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
override val blockchainConfig: BlockchainConfig = Config.blockchains.blockchainConfig
override val capabilities: List[Capability] = blockchainConfig.capabilities
}

lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ object DumpChainApp
override val blockchainReader: BlockchainReader = DumpChainApp.blockchainReader
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
override val blockchainConfig: BlockchainConfig = Config.blockchains.blockchainConfig
override val capabilities: List[Capability] = blockchainConfig.capabilities
}

lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ trait EtcHandshakerConfiguration {
val appStateStorage: AppStateStorage
val peerConfiguration: PeerConfiguration
val forkResolverOpt: Option[ForkResolver]
val capabilities: List[Capability]
val blockchainConfig: BlockchainConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ case class EtcHelloExchangeState(handshakerConfiguration: EtcHandshakerConfigura
override def applyResponseMessage: PartialFunction[Message, HandshakerState[PeerInfo]] = { case hello: Hello =>
log.debug("Protocol handshake finished with peer ({})", hello)
// FIXME in principle this should be already negotiated
Capability.negotiate(hello.capabilities.toList, handshakerConfiguration.capabilities) match {
Capability.negotiate(hello.capabilities.toList, handshakerConfiguration.blockchainConfig.capabilities) match {
case Some(ProtocolVersions.ETC64) => EtcNodeStatus64ExchangeState(handshakerConfiguration)
case Some(ProtocolVersions.ETH63) => EtcNodeStatus63ExchangeState(handshakerConfiguration)
case Some(ProtocolVersions.ETH64) => EthNodeStatus64ExchangeState(handshakerConfiguration)
Expand Down Expand Up @@ -56,7 +56,7 @@ case class EtcHelloExchangeState(handshakerConfiguration: EtcHandshakerConfigura
Hello(
p2pVersion = EtcHelloExchangeState.P2pVersion,
clientId = Config.clientId,
capabilities = handshakerConfiguration.capabilities,
capabilities = handshakerConfiguration.blockchainConfig.capabilities,
listenPort = listenPort,
nodeId = ByteString(nodeStatus.nodeId)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ trait HandshakerBuilder {
override val blockchain: Blockchain = self.blockchain
override val blockchainReader: BlockchainReader = self.blockchainReader
override val appStateStorage: AppStateStorage = self.storagesInstance.storages.appStateStorage
override val capabilities: List[Capability] = self.blockchainConfig.capabilities
override val blockchainConfig: BlockchainConfig = self.blockchainConfig
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ class EtcHandshakerSpec extends AnyFlatSpec with Matchers {
override val peerConfiguration: PeerConfiguration = Config.Network.peer
override val blockchain: Blockchain = TestSetup.this.blockchain
override val appStateStorage: AppStateStorage = TestSetup.this.storagesInstance.storages.appStateStorage
override val capabilities: List[Capability] = pv
override val blockchainReader: BlockchainReader = TestSetup.this.blockchainReader
override val blockchainConfig: BlockchainConfig = TestSetup.this.blockchainConfig
override val blockchainConfig: BlockchainConfig = TestSetup.this.blockchainConfig.copy(capabilities = pv)
}

val etcHandshakerConfigurationWithResolver = new MockEtcHandshakerConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,7 @@ class PeerActorSpec
override val blockchain: Blockchain = self.blockchain
override val blockchainReader: BlockchainReader = self.blockchainReader
override val appStateStorage: AppStateStorage = self.storagesInstance.storages.appStateStorage
override val capabilities: List[Capability] = List(protocol)
override val blockchainConfig: BlockchainConfig = self.blockchainConfig
override val blockchainConfig: BlockchainConfig = self.blockchainConfig.copy(capabilities = List(protocol))
}

val handshaker = EtcHandshaker(handshakerConfiguration)
Expand Down

0 comments on commit 4aef984

Please sign in to comment.