From a38a4578c37a505d750c45c43a36c7d2d1de52ee Mon Sep 17 00:00:00 2001 From: Gaius Date: Fri, 19 Jan 2024 16:43:30 +0800 Subject: [PATCH] feat: CanAddPeerEdge is moved to the end of filter (#3036) Signed-off-by: Gaius --- scheduler/scheduling/scheduling.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scheduler/scheduling/scheduling.go b/scheduler/scheduling/scheduling.go index cb7d4bd58..56eede253 100644 --- a/scheduler/scheduling/scheduling.go +++ b/scheduler/scheduling/scheduling.go @@ -516,12 +516,6 @@ func (s *scheduling) filterCandidateParents(peer *resource.Peer, blocklist set.S continue } - // Candidate parent can add edge with peer. - if !peer.Task.CanAddPeerEdge(candidateParent.ID, peer.ID) { - peer.Log.Debugf("can not add edge with parent %s", candidateParent.ID) - continue - } - // Candidate parent host is not allowed to be the same as the peer host, // because dfdaemon cannot handle the situation // where two tasks are downloading and downloading each other. @@ -562,6 +556,12 @@ func (s *scheduling) filterCandidateParents(peer *resource.Peer, blocklist set.S continue } + // Candidate parent can add edge with peer. + if !peer.Task.CanAddPeerEdge(candidateParent.ID, peer.ID) { + peer.Log.Debugf("can not add edge with parent %s", candidateParent.ID) + continue + } + candidateParents = append(candidateParents, candidateParent) candidateParentIDs = append(candidateParentIDs, candidateParent.ID) }