Unify pinned and discovery checks code