diff --git a/src/main/scala/scorex/network/BlockchainSynchronizer.scala b/src/main/scala/scorex/network/BlockchainSynchronizer.scala index f59027b3a6a..137fba11045 100755 --- a/src/main/scala/scorex/network/BlockchainSynchronizer.scala +++ b/src/main/scala/scorex/network/BlockchainSynchronizer.scala @@ -48,9 +48,12 @@ class BlockchainSynchronizer(application: Application) extends ViewSynchronizer start(GettingExtension) { _ => val lastIds = history.lastBlockIds(application.settings.synchronizationSettings.maxRollback) - val msg = Message(GetSignaturesSpec, Right(lastIds), None) - networkControllerRef ! NetworkController.SendToNetwork(msg, SendToChosen(peerScores.keys.toSeq)) + + val max = peerScores.maxBy(_._2) + val maxPeers = peerScores.filter(_._2 == max._2) + + networkControllerRef ! NetworkController.SendToNetwork(msg, SendToChosen(maxPeers.keys.toSeq)) gettingExtension(lastIds.map(InnerId), peerScores.map(peer => peer._1 -> Peer(peer._2))) } @@ -237,8 +240,8 @@ class BlockchainSynchronizer(application: Application) extends ViewSynchronizer val sortedByScore = updatedPeers.toSeq.sortBy(_._2.score).map(_._1) - sortedByScore.filterNot(_ == active).headOption - .orElse(sortedByScore.headOption) + sortedByScore.filterNot(_ == active).lastOption + .orElse(sortedByScore.lastOption) .map(newActive => ps.copy(active = newActive, peers = updatedPeers)) }