refactor: deduplicate primary parent view selection in Collect

Replace the inline loop with a call to the existing primaryParentView()
helper so the selection algorithm lives in exactly one place.
This commit is contained in:
nemunaire 2026-05-16 13:14:05 +08:00
commit 7e8faa7169

View file

@ -89,13 +89,7 @@ func (p *delegationProvider) Collect(ctx context.Context, opts sdk.CheckerOption
} }
// If no parent answered with an NS RRset, skip Phase B; rules flag the gap. // If no parent answered with an NS RRset, skip Phase B; rules flag the gap.
var primary *ParentView primary := primaryParentView(data.ParentViews)
for i := range data.ParentViews {
if data.ParentViews[i].UDPNSError == "" && len(data.ParentViews[i].NS) > 0 {
primary = &data.ParentViews[i]
break
}
}
if primary == nil { if primary == nil {
return data, nil return data, nil
} }