Skip to content

Commit 6f3c055

Browse files
committed
ETCM-760: Adapt impacted classes to new blacklist
1 parent be6a525 commit 6f3c055

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/main/scala/io/iohk/ethereum/blockchain/sync/SyncController.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SyncController(
9292

9393
def startRegularSync(): Unit = {
9494
val peersClient =
95-
context.actorOf(PeersClient.props(etcPeerManager, peerEventBus, syncConfig, scheduler), "peers-client")
95+
context.actorOf(PeersClient.props(etcPeerManager, peerEventBus, blacklist, syncConfig, scheduler), "peers-client")
9696
val regularSync = context.actorOf(
9797
RegularSync.props(
9898
peersClient,
@@ -101,6 +101,7 @@ class SyncController(
101101
ledger,
102102
blockchain,
103103
validators.blockValidator,
104+
blacklist,
104105
syncConfig,
105106
ommersPool,
106107
pendingTransactionsManager,

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockBroadcast.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package io.iohk.ethereum.blockchain.sync.regular
22

33
import akka.actor.ActorRef
4+
import io.iohk.ethereum.blockchain.sync.PeerListSupportNg.PeerWithInfo
45
import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcast.BlockToBroadcast
56
import io.iohk.ethereum.domain.{Block, ChainWeight}
67
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
78
import io.iohk.ethereum.network.p2p.MessageSerializable
89
import io.iohk.ethereum.network.p2p.messages.PV62.BlockHash
910
import io.iohk.ethereum.network.p2p.messages.{CommonMessages, PV62, PV64, ProtocolVersions}
10-
import io.iohk.ethereum.network.{EtcPeerManagerActor, Peer}
11+
import io.iohk.ethereum.network.{EtcPeerManagerActor, Peer, PeerId}
1112

1213
import scala.util.Random
1314

@@ -22,24 +23,24 @@ class BlockBroadcast(val etcPeerManager: ActorRef) {
2223
* @param blockToBroadcast, block to broadcast
2324
* @param handshakedPeers, to which the blocks will be broadcasted to
2425
*/
25-
def broadcastBlock(blockToBroadcast: BlockToBroadcast, handshakedPeers: Map[Peer, PeerInfo]): Unit = {
26-
val peersWithoutBlock = handshakedPeers.filter { case (_, peerInfo) =>
26+
def broadcastBlock(blockToBroadcast: BlockToBroadcast, handshakedPeers: Map[PeerId, PeerWithInfo]): Unit = {
27+
val peersWithoutBlock = handshakedPeers.filter { case (_, PeerWithInfo(_, peerInfo)) =>
2728
shouldSendNewBlock(blockToBroadcast, peerInfo)
2829
}
2930

3031
broadcastNewBlock(blockToBroadcast, peersWithoutBlock)
3132

32-
broadcastNewBlockHash(blockToBroadcast, peersWithoutBlock.keySet)
33+
broadcastNewBlockHash(blockToBroadcast, peersWithoutBlock.values.map(_.peer).toSet)
3334
}
3435

3536
private def shouldSendNewBlock(newBlock: BlockToBroadcast, peerInfo: PeerInfo): Boolean =
3637
newBlock.block.header.number > peerInfo.maxBlockNumber ||
3738
newBlock.chainWeight > peerInfo.chainWeight
3839

39-
private def broadcastNewBlock(blockToBroadcast: BlockToBroadcast, peers: Map[Peer, PeerInfo]): Unit =
40-
obtainRandomPeerSubset(peers.keySet).foreach { peer =>
40+
private def broadcastNewBlock(blockToBroadcast: BlockToBroadcast, peers: Map[PeerId, PeerWithInfo]): Unit =
41+
obtainRandomPeerSubset(peers.values.map(_.peer).toSet).foreach { peer =>
4142
val message: MessageSerializable =
42-
if (peers(peer).remoteStatus.protocolVersion == ProtocolVersions.PV64) blockToBroadcast.as64
43+
if (peers(peer.id).peerInfo.remoteStatus.protocolVersion == ProtocolVersions.PV64) blockToBroadcast.as64
4344
else blockToBroadcast.as63
4445
etcPeerManager ! EtcPeerManagerActor.SendMessage(message, peer.id)
4546
}

0 commit comments

Comments
 (0)