Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add endpoint to get names count #1737

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

yaboiishere
Copy link
Contributor

ref: #1629

@yaboiishere yaboiishere self-assigned this Apr 23, 2024
Copy link
Contributor

@sborrazas sborrazas left a comment

Choose a reason for hiding this comment

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

There's no need to add a new endpoint, this is already exposed via totalstats endpoint here https://testnet.aeternity.io/mdw/v3/totalstats

with {:ok, filters} <- Util.convert_params(query, &convert_param/1) do
filters
|> build_height_streamer(state, nil, nil, nil)
|> then(fn streamer -> streamer.(:backward) end)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to go through all of the names? There's no limit to how many names there could be, this could take a lot of time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a slow query yeah, but the idea is so that this can be used to get all active names owned by an account. The problem with counting the results from the regular endpoint is that it's paginated and can't be counted

@yaboiishere
Copy link
Contributor Author

There's no need to add a new endpoint, this is already exposed via totalstats endpoint here https://testnet.aeternity.io/mdw/v3/totalstats

Yeah, but it can't be filtered on based on the owner

@sborrazas
Copy link
Contributor

@yaboiishere we cannot add endpoints that expose features that can be easily exploited. We also shouldn't be adding any pagination counters, that's database dependent and our current database doesn't allow it.

@yaboiishere
Copy link
Contributor Author

So i should reimplement this in some other way. Maybe it can something like the account balances where a Genserver keeps track of those and it gets updated on every relevant mutation?

@sborrazas
Copy link
Contributor

So i should reimplement this in some other way. Maybe it can something like the account balances where a Genserver keeps track of those and it gets updated on every relevant mutation?

The proper way of implementing this would be to add a new index that keeps track of all of the counters for all accounts, which will increase the size of the database. And if we do that for every paginated endpoint we will end up with a database double or triple the size, so we should avoid implementing these features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants