Skip to content

Conversation

@DarkLord017
Copy link
Contributor

Fixes #147

Provider filtering feature:

  • Added a new ProviderFilterOptions interface in sp-registry/types.ts to specify filtering criteria such as type, location, piece size, IPNI support, service status, price, proving period, and randomization.
  • Implemented the providerFiltering method in SPRegistryService to filter providers according to the given options and optionally randomize the output.
  • Added a private _shuffle utility method to randomize provider lists when requested.
    )

@BigLep
Copy link
Contributor

BigLep commented Dec 17, 2025

@DarkLord017 : Thank you for contributing. My guess is this PR won't get looked at for a bit because #147 isn't in our GA milestone. Just letting you know to set expectations.

@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Dec 17, 2025
private _shuffle<T>(array: T[]): T[] {
// Fisher-Yates shuffle
const arr = array.slice()
for (let i = arr.length - 1; i > 0; i--) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually write this loop condition like for (let i = arr.length; i-- > 0;)

return providers
}

private _shuffle<T>(array: T[]): T[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be static because it doesn't use this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving it to rand.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

)
})

return filter.randomize ? this._shuffle(result) : result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the order without randomize well-defined?

* @param filter - Filtering options
* @returns Filtered list of providers
*/
async providerFiltering(filter?: ProviderFilterOptions): Promise<ProviderInfo[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want a different name for this method, like filterProviders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

return result
}
}
/** * Filter providers based on criteria
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this appears to be missing a newline

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Feb 3, 2026
// Fisher-Yates shuffle
const arr = array.slice()
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

Add provider filtering and matching endpoint to Synapse API

3 participants