const hashCount: number = 30
const saturate = (barefilter: NameFilter): NameFilter {
// Get the lower bound of remaining elements
const lowerBound = Math.floor((max - barefilter.popcount()) / hashCount)
// Quickly jump to the lower bound
for (i = 0; i < lowerBound; i++) {
filter = filter.add(sha(filter.toBytes()))
// Step more slowly though until comparison reached
return saturatedUnderMax(filter)
// Closest without going over
const saturateUnderMax = (filter: NameFilter): NameFilter {
const newFilter = filter.add(sha(filter.toBytes()))
if (popcount(newFilter) > max) return filter
saturatedUnderMax(newFilter)