From 3ca7dd7310b69eef88e104cc8b543c55f226fb7f Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Wed, 8 Sep 2021 18:42:33 +0300 Subject: [PATCH 1/3] getStatus Signed-off-by: Alex Chepurnoy --- src/main/scala/scorex/core/network/SyncTracker.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/scala/scorex/core/network/SyncTracker.scala b/src/main/scala/scorex/core/network/SyncTracker.scala index bc408878f..67f777bed 100644 --- a/src/main/scala/scorex/core/network/SyncTracker.scala +++ b/src/main/scala/scorex/core/network/SyncTracker.scala @@ -51,6 +51,13 @@ class SyncTracker(nvsRef: ActorRef, if (stableSyncRegime) networkSettings.syncIntervalStable else networkSettings.syncInterval + /** + * Get synchronization status for given connected peer + */ + def getStatus(peer: ConnectedPeer): Option[HistoryComparisonResult] = { + statuses.get(peer) + } + def updateStatus(peer: ConnectedPeer, status: HistoryComparisonResult): Unit = { val seniorsBefore = numOfSeniors() statuses += peer -> status From d8c3931f94a53242ab48bcdbe17f1fc44c297a95 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Wed, 15 Sep 2021 21:39:59 +0300 Subject: [PATCH 2/3] protected vals for SyncTracker Signed-off-by: Alex Chepurnoy --- src/main/scala/scorex/core/network/SyncTracker.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/scorex/core/network/SyncTracker.scala b/src/main/scala/scorex/core/network/SyncTracker.scala index 67f777bed..74e1b41d1 100644 --- a/src/main/scala/scorex/core/network/SyncTracker.scala +++ b/src/main/scala/scorex/core/network/SyncTracker.scala @@ -25,14 +25,14 @@ class SyncTracker(nvsRef: ActorRef, import History._ import scorex.core.utils.TimeProvider.Time - private var schedule: Option[Cancellable] = None + protected var schedule: Option[Cancellable] = None - private val statuses = mutable.Map[ConnectedPeer, HistoryComparisonResult]() - private val lastSyncSentTime = mutable.Map[ConnectedPeer, Time]() + protected val statuses = mutable.Map[ConnectedPeer, HistoryComparisonResult]() + protected val lastSyncSentTime = mutable.Map[ConnectedPeer, Time]() - private var lastSyncInfoSentTime: Time = 0L + protected var lastSyncInfoSentTime: Time = 0L - private var stableSyncRegime = false + protected var stableSyncRegime = false def scheduleSendSyncInfo(): Unit = { schedule foreach { From 55aca5ebced2ffea96b2af4fafac71d6cf324e63 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Thu, 30 Sep 2021 23:46:10 +0300 Subject: [PATCH 3/3] no private methods in SyncTracker --- src/main/scala/scorex/core/network/SyncTracker.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/scorex/core/network/SyncTracker.scala b/src/main/scala/scorex/core/network/SyncTracker.scala index 74e1b41d1..7627edc48 100644 --- a/src/main/scala/scorex/core/network/SyncTracker.scala +++ b/src/main/scala/scorex/core/network/SyncTracker.scala @@ -96,14 +96,14 @@ class SyncTracker(nvsRef: ActorRef, def elapsedTimeSinceLastSync(): Long = timeProvider.time() - lastSyncInfoSentTime - private def outdatedPeers(): Seq[ConnectedPeer] = + protected def outdatedPeers(): Seq[ConnectedPeer] = lastSyncSentTime.filter(t => (timeProvider.time() - t._2).millis > maxInterval()).keys.toSeq def peersByStatus: Map[HistoryComparisonResult, Iterable[ConnectedPeer]] = statuses.groupBy(_._2).mapValues(_.keys).view.force - private def numOfSeniors(): Int = statuses.count(_._2 == Older) + protected def numOfSeniors(): Int = statuses.count(_._2 == Older) /** * Return the peers to which this node should send a sync signal, including: