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

Commit 8ddf4af

Browse files
authored
Merge pull request #364 from scasplte2/move_peerSync_creation
moved peerSynchronizer creation to app
2 parents 1cfffb3 + 29429ce commit 8ddf4af

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/main/scala/scorex/core/app/Application.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ trait Application extends ScorexLogging {
4040

4141
protected val features: Seq[PeerFeature]
4242
protected val additionalMessageSpecs: Seq[MessageSpec[_]]
43+
private val featureSerializers: PeerFeature.Serializers = features.map(f => f.featureId -> f.serializer).toMap
4344

4445
//p2p
4546
private val upnpGateway: Option[UPnPGateway] = if (settings.network.upnpEnabled) UPnP.getValidGateway(settings.network) else None
@@ -50,7 +51,6 @@ trait Application extends ScorexLogging {
5051
val invSpec = new InvSpec(settings.network.maxInvObjects)
5152
val requestModifierSpec = new RequestModifierSpec(settings.network.maxInvObjects)
5253
val modifiersSpec = new ModifiersSpec(settings.network.maxPacketSize)
53-
val featureSerializers: PeerFeature.Serializers = features.map(f => f.featureId -> f.serializer).toMap
5454
Seq(
5555
GetPeersSpec,
5656
new PeersSpec(featureSerializers, settings.network.maxPeerSpecObjects),
@@ -89,6 +89,9 @@ trait Application extends ScorexLogging {
8989
val networkControllerRef: ActorRef = NetworkControllerRef(
9090
"networkController", settings.network, peerManagerRef, scorexContext)
9191

92+
val peerSynchronizer: ActorRef = PeerSynchronizerRef("PeerSynchronizer",
93+
networkControllerRef, peerManagerRef, settings.network, featureSerializers)
94+
9295
lazy val combinedRoute: Route = CompositeHttpService(actorSystem, apiRoutes, settings.restApi, swaggerConfig).compositeRoute
9396

9497
def run(): Unit = {

src/main/scala/scorex/core/network/NetworkController.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ class NetworkController(settings: NetworkSettings,
6161
private var connections = Map.empty[InetSocketAddress, ConnectedPeer]
6262
private var unconfirmedConnections = Set.empty[InetSocketAddress]
6363

64-
//todo: make usage more clear, now we're relying on preStart logic in a actor which is described by a never used val
65-
private val featureSerializers: PeerFeature.Serializers = scorexContext.features.map(f => f.featureId -> f.serializer).toMap
66-
private val peerSynchronizer: ActorRef = PeerSynchronizerRef("PeerSynchronizer", self, peerManagerRef, settings,
67-
featureSerializers)
68-
6964
//check own declared address for validity
7065
validateDeclaredAddress()
7166

src/test/scala/scorex/network/NetworkControllerSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ class NetworkControllerSpec extends NetworkTests {
292292
"networkController", settings.network,
293293
peerManagerRef, scorexContext, tcpManagerProbe.testActor)
294294

295+
val peerSynchronizer: ActorRef = PeerSynchronizerRef("PeerSynchronizer",
296+
networkControllerRef, peerManagerRef, settings.network, featureSerializers)
297+
295298

296299
tcpManagerProbe.expectMsg(Bind(networkControllerRef, settings.network.bindAddress, options = Nil))
297300

0 commit comments

Comments
 (0)