Skip to content

Commit fec5168

Browse files
committed
ETCM-446: Configure 12 hour stats duration.
1 parent f0f09dc commit fec5168

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/main/resources/application.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ mantis {
177177

178178
# Resolution of moving window of peer statistics.
179179
# Will be multiplied by `stat-slot-count` to give the overall length of peer statistics availability.
180-
stat-slot-duration = 1.minute
180+
stat-slot-duration = 10.minutes
181+
181182
# How many slots of peer statistics to keep in the moving window, e.g. 60 * 1.minute to keep stats for the last hour with 1 minute resolution.
182-
stat-slot-count = 60
183+
stat-slot-count = 72
183184
}
184185

185186
rpc {

src/main/scala/io/iohk/ethereum/network/PeerManagerActor.scala

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class PeerManagerActor(
271271
handshakedPeer.ref ! PeerActor.DisconnectPeer(Disconnect.Reasons.TooManyPeers)
272272

273273
// It looks like all incoming slots are taken; try to make some room.
274-
schedulePruningIncomingPeers()
274+
self ! SchedulePruneIncomingPeers
275275

276276
context become listening(connectedPeers)
277277

@@ -302,18 +302,18 @@ class PeerManagerActor(
302302
(pendingPeer, newConnectedPeers)
303303
}
304304

305-
/** Ask for statistics and try to prune incoming peers when they arrive. */
306-
private def schedulePruningIncomingPeers(): Unit = {
307-
implicit val timeout: Timeout = Timeout(peerConfiguration.updateNodesInterval)
308-
// Picking the minimum pruning age is fair for anyone
309-
val window = peerConfiguration.minPruneAge
310-
(peerStatistics ? PeerStatisticsActor.GetStatsForAll(window))
311-
.mapTo[PeerStatisticsActor.StatsForAll]
312-
.map(PruneIncomingPeers(_))
313-
.pipeTo(self)
314-
}
315-
316305
private def handlePruning(connectedPeers: ConnectedPeers): Receive = {
306+
case SchedulePruneIncomingPeers =>
307+
implicit val timeout: Timeout = Timeout(peerConfiguration.updateNodesInterval)
308+
309+
// Ask for the whole statistics duration, we'll use averages to make it fair.
310+
val window = peerConfiguration.statSlotCount * peerConfiguration.statSlotDuration
311+
312+
(peerStatistics ? PeerStatisticsActor.GetStatsForAll(window))
313+
.mapTo[PeerStatisticsActor.StatsForAll]
314+
.map(PruneIncomingPeers(_))
315+
.pipeTo(self)
316+
317317
case PruneIncomingPeers(PeerStatisticsActor.StatsForAll(stats)) =>
318318
val prunedConnectedPeers = pruneIncomingPeers(connectedPeers, stats)
319319

@@ -505,6 +505,7 @@ object PeerManagerActor {
505505

506506
case class PeerAddress(value: String) extends BlackListId
507507

508+
case object SchedulePruneIncomingPeers
508509
case class PruneIncomingPeers(stats: PeerStatisticsActor.StatsForAll)
509510

510511
/** Number of new connections the node should try to open at any given time. */

0 commit comments

Comments
 (0)