func (s *scheduler) filterParents(peer *resource.Peer, blocklist set.SafeSet) []*resource.Peer {
	var parents []*resource.Peer
	var parentIDs []string
	peer.Task.Peers.Range(func(_, value interface{}) bool {
		parent, ok := value.(*resource.Peer)
		if !ok {
			return true
		}

		if blocklist.Contains(parent.ID) {
			peer.Log.Infof("parent %s is not selected because it is in blocklist", parent.ID)
			return true
		}

		if parent == peer {
			peer.Log.Info("parent is not selected because it is same")
			return true
		}

		if s.evaluator.IsBadNode(parent) {
			peer.Log.Infof("parent %s is not selected because it is bad node", parent.ID)
			return true
		}

		if parent.IsDescendant(peer) {
			peer.Log.Infof("parent %s is not selected because it is descendant", parent.ID)
			return true
		}

		if parent.IsAncestor(peer) {
			peer.Log.Infof("parent %s is not selected because it is ancestor", parent.ID)
			return true
		}

		if parent.Host.FreeUploadLoad() <= 0 {
			peer.Log.Infof("parent %s is not selected because its free upload is empty", parent.ID)
			return true
		}

		parents = append(parents, parent)
		parentIDs = append(parentIDs, parent.ID)
		return true
	})

	peer.Log.Infof("candidate parents include %#v", parentIDs)
	return parents
}
// Filter the parent that can be scheduled
Filter the parent that can be scheduled
// Filter the parent that can be scheduled
func (s *scheduler) filterParents(peer *resource.Peer, blocklist set.SafeSet) []*resource.Peer {
	var parents []*resource.Peer
	var parentIDs []string
	peer.Task.Peers.Range(func(_, value interface{}) bool {
		parent, ok := value.(*resource.Peer)
		if !ok {
			return true
		}
		if blocklist.Contains(parent.ID) {
			peer.Log.Infof("parent %s is not selected because it is in blocklist", parent.ID)
			return true
		}
		if parent == peer {
			peer.Log.Info("parent is not selected because it is same")
			return true
		}
		if s.evaluator.IsBadNode(parent) {
			peer.Log.Infof("parent %s is not selected because it is bad node", parent.ID)
			return true
		}
		if parent.IsDescendant(peer) {
			peer.Log.Infof("parent %s is not selected because it is descendant", parent.ID)
			return true
		}
		if parent.IsAncestor(peer) {
			peer.Log.Infof("parent %s is not selected because it is ancestor", parent.ID)
			return true
		}
		if parent.Host.FreeUploadLoad() <= 0 {
			peer.Log.Infof("parent %s is not selected because its free upload is empty", parent.ID)
			return true
		}
		parents = append(parents, parent)
		parentIDs = append(parentIDs, parent.ID)
		return true
	})
	peer.Log.Infof("candidate parents include %#v", parentIDs)
	return parents
}
func ( s * scheduler ) filterParents ( peer * resource . Peer , blocklist set . SafeSet ) [ ] * resource . Peer { var parents [ ] * resource . Peer var parentIDs [ ] string peer . Task . Peers . Range ( func ( _ , value interface { } ) bool { parent , ok := value . ( * resource . Peer ) if ! ok { return true } if blocklist . Contains ( parent . ID ) { peer . Log . Infof ( " " , parent . ID ) return true } if parent == peer { peer . Log . Info ( " " ) return true } if s . evaluator . IsBadNode ( parent ) { peer . Log . Infof ( " " , parent . ID ) return true } if parent . IsDescendant ( peer ) { peer . Log . Infof ( " " , parent . ID ) return true } if parent . IsAncestor ( peer ) { peer . Log . Infof ( " " , parent . ID ) return true } if parent . Host . FreeUploadLoad ( ) <= 0 { peer . Log . Infof ( " " , parent . ID ) return true } parents = append ( parents , parent ) parentIDs = append ( parentIDs , parent . ID ) return true } ) peer . Log . Infof ( " " , parentIDs ) return parents }
Filter the parent that can be scheduled
Filter the parent that can be scheduled