discovery: only replace stale active syncer if disconnected

In this commit, we address a bug where we'd attempt to replace the
stale active syncer when it transitioned to a passive syncer. This
replacement logic is only intended to happen when the active syncer
disconnects, as rotateActiveSyncerCandidate chooses and queues its own
replacement.
This commit is contained in:
Wilmer Paulino 2019-04-03 16:43:31 -07:00
parent 2cc6687ff3
commit 46ceaf8cf6
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -353,19 +353,20 @@ func (m *SyncManager) roundRobinHandler() {
// the set of inactive syncers.
if staleActiveSyncer.transitioned {
m.inactiveSyncers[s.cfg.peerPub] = s
} else {
// Otherwise, since the peer is disconnecting,
// we'll attempt to find a passive syncer that
// can replace it.
newActiveSyncer := m.chooseRandomSyncer(nil, false)
if newActiveSyncer != nil {
m.queueActiveSyncer(newActiveSyncer)
}
}
// Remove the internal active syncer references for this
// peer.
delete(m.pendingActiveSyncers, s.cfg.peerPub)
delete(m.activeSyncers, s.cfg.peerPub)
// We'll then attempt to find a passive syncer that can
// replace the stale active syncer.
newActiveSyncer := m.chooseRandomSyncer(nil, false)
if newActiveSyncer != nil {
m.queueActiveSyncer(newActiveSyncer)
}
m.Unlock()
// Signal to the caller that they can now proceed since