From 2130af3d0d7fe9c6eed6d40137ce064346713353 Mon Sep 17 00:00:00 2001 From: Srinivas Baride Date: Sat, 26 Jun 2021 10:03:17 +0530 Subject: [PATCH] Prioritize stale peer connections --- node/jobs.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/jobs.go b/node/jobs.go index c2f45d8..bf483ad 100644 --- a/node/jobs.go +++ b/node/jobs.go @@ -84,15 +84,15 @@ func (n *Node) jobUpdateSessions() error { remove, skip := func() (bool, bool) { switch { + case items[i].Download == session.Bandwidth.Upload.Int64() && items[i].ConnectedAt.Before(session.StatusAt): + n.Log().Info("Stale peer connection", "id", items[i].ID) + return true, true case !subscription.Status.Equal(hubtypes.StatusActive): n.Log().Info("Invalid subscription status", "id", items[i].ID) return true, subscription.Status.Equal(hubtypes.StatusInactive) case !session.Status.Equal(hubtypes.StatusActive): n.Log().Info("Invalid session status", "id", items[i].ID) return true, session.Status.Equal(hubtypes.StatusInactive) - case items[i].Download == session.Bandwidth.Upload.Int64() && items[i].ConnectedAt.Before(session.StatusAt): - n.Log().Info("Stale peer connection", "id", items[i].ID) - return true, false default: return false, false }