steemit / devportal

Steem Platform Developer Documentation.
https://developers.steem.io
MIT License
122 stars 74 forks source link

Recipe: evaluate get_state's functionality equivalence in the rest of the api #283

Closed relativityboy closed 6 years ago

relativityboy commented 6 years ago

Use of get_state is considered lazy, but is a key api call that many developers use.

As a dev, I want to know, in theory how I could replace get_state call, so that at the end of the process I have an object that is equivalent to the object it returns.

AC

inertia186 commented 6 years ago

If get_state were to become deprecated right now, what are the method calls needed to replace the current functionality? Let's look at it:

time curl -s --data '{"jsonrpc":"2.0", "method":"condenser_api.get_state", "params":["/@inertia"], "id":1}' https://api.steemit.com

That returns a huge 250k response, with this execution time for me:

real    0m2.026s
user    0m0.053s
sys 0m0.071s

In my opinion, the things that are critical to provide an alternative for would be content and accounts:

image

Everything else can be queried separately or by using json-rpc-batch if you really want all of those keys in one API result.

Even the content result can be simulated with get_blog.

One of the things that is harder to simulate with one API call is accounts, specifically, the transfer_history, market_history, post_history, vote_history, other_history, witness_votes, and tags_usage keys:

image

Most of these can be simulated with get_account_history, but it's rather clunky, for example:

https://developers.steem.io/tutorials-ruby/get_account_comments#making-the-api-call

In the ruby tutorial, I intentionally avoided using get_state to do something that the js tutorial did using get_state:

https://developers.steem.io/tutorials-javascript/get_account_comments#query

All this to say, is it better to direct app developers away from get_state and over to get_account_history or are we going to offer a new API call?

inertia186 commented 6 years ago

Might affect #242.

relativityboy commented 6 years ago

Some supporting materials:

https://github.com/steemit/condenser/issues/2899 https://github.com/steemit/condenser/issues/2684 https://github.com/steemit/condenser/issues/2244

relativityboy commented 6 years ago

Results

We should write a tutorial (JS & Ruby preferred) that re-builds most of get_state with the different calls @inertia186 outlined above in a somewhat interactive, step-wise basis starting with the fast calls, and moves on to the slower ones. I could imagine as an option us using pure node (no express) for JS and just keeping things at cli level.

The focus will be to show developers how much better their app can be if they abandon get_state... and if we find that the thought is incorrect while writing the tutorial we file bugs and get them fixed.