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

Process iterator in RPC result #583

Merged
merged 10 commits into from
Apr 20, 2021
Merged

Conversation

shargon
Copy link
Member

@shargon shargon commented Apr 15, 2021

Alternative to #577

@shargon shargon requested a review from erikzhang April 15, 2021 07:37
@shargon shargon mentioned this pull request Apr 15, 2021
@erikzhang
Copy link
Member

If you return the values of the iterator directly, the developer will not be able to distinguish whether the method returns an array or an iterator.

@shargon
Copy link
Member Author

shargon commented Apr 15, 2021

If you return the values of the iterator directly, the developer will not be able to distinguish whether the method returns an array or an iterator.

I think that api users doesn't care about the low level type, they want the value. Otherwise you will need to know first that it's an iterator result in order to make a different call.

@erikzhang
Copy link
Member

At least we should not modify its type.

{
  "type": "InteropInterface",
  "value": []
}

@satoshichou
Copy link
Contributor

satoshichou commented Apr 16, 2021

I tried modules, making everything to config is not a good way, and server can't modify config when it's running a node. I find more and more paramaters are added to config.json, it's too complex for reading and understanding for a new developer. I like the style of #577 much more. Should give rights to user but not limit it from server, that's why choose iteratror but not list, right?

@superboyiii
Copy link
Member

As @satoshichou said, I totally agree. Don't make config too heavy and user could choose how much times iterator could run.

@shargon
Copy link
Member Author

shargon commented Apr 16, 2021

Don't make config too heavy

Anyway an output limit it's a good choice.

and user could choose how much times iterator could run.

The cost of this "feature" it's to choose a different method if you call an specific one, harder for developers, there are any use case for return an specific index? the server will process all of them in order to fetch them, this process can be delegated to the client.

@steven1227
Copy link
Member

steven1227 commented Apr 16, 2021

I agree with @superboyiii and @satoshichou and I prefer that Pull Request

@erikzhang
Copy link
Member

erikzhang commented Apr 17, 2021

I support @shargon's solution. Because if you use index, it may cause data inconsistency. For example, if I call invokeiterator twice, the first request is 1~100, and the second request is 101~200. But if a new database insertion or deletion occurs between the two requests, the data returned between these two requests is inconsistent.

@nicolegys
Copy link
Contributor

I'm confused about MaxResultItems. My test shows that when I set the value 10, if the amount of return result is more than 10, I will get this returned "stack": "error: invalid operation". I think it should return the first 10 result and give a message, to tell the user that there are still some data not showed.

Co-authored-by: Satoshi Chou <82646971+satoshichou@users.noreply.github.com>
@nicolegys
Copy link
Contributor

There's a boundary case. If the value of MaxResultItems is just enough to iterate over the data, the return result still shows the warning.

erikzhang
erikzhang previously approved these changes Apr 19, 2021
{
json["warning"] = warning;
}
json["stack"] = new JArray(engine.ResultStack.Select(p => ToJson(p, settings.MaxResultItems)));
Copy link
Member Author

Choose a reason for hiding this comment

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

Now is not a MaxResultItems it's a MaxIteratorResultItems

Copy link
Member

Choose a reason for hiding this comment

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

Yes. We should rename it.

nicolegys
nicolegys previously approved these changes Apr 20, 2021
Copy link
Contributor

@nicolegys nicolegys left a comment

Choose a reason for hiding this comment

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

Test pass, just need to rename the parameter.

@nicolegys
Copy link
Contributor

Since this solution not supports index, when the amount of data is very large, does user need to run his own node to get the complete data?

@erikzhang
Copy link
Member

Since this solution not supports index, when the amount of data is very large, does user need to run his own node to get the complete data?

Yes. I think public nodes are not suitable for running high-load tasks.

@shargon shargon merged commit 4359882 into neo-project:master Apr 20, 2021
@shargon shargon deleted the process-iterator branch April 20, 2021 08:49
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.

6 participants