Everyone who's ever worked with JSON, check this out...

in #steem8 years ago

Spot the error in conventions....

Clipboardimage2016-12-151719215e911.png

So transactions is an array under results containing items 0-lasttransaction. OK.

....But then operations is an array under transactions containing always a single operation, identified by its operation type in the first entry in the array. It does parse, but there's no reason at all to have the first entry in the array be that. It could quite simply be an array with a single entry containing the operation type as the first field in the array. This, like a few other things in steem's data format, doesn't make much sense.

Errors (yes, errors!) like this filter down into every aspect of downstream work.

I've never seen a trasaction with more than one operation. Which then calls into question why we aren't just listing everything under transactions arrays-- each of the array-items under transactions could be a flat listing of facts. And this would indisputably:

  • Save bandwidth
  • Speed up processing
  • reduce downstream workload
  • make the API clearer

Now the last two items, they're important. Steemit SHOULD have an application ecosystem by now, but so far, there isn't much of one. I'm claiming that this is why. Now, it's not only this..... but fixing this would be a BIG step in the right direction.

Sort:  

I've never seen a trasaction with more than one operation.

If you submit a new post with "decline payout" option, you'll see it.

//Update:

but fixing this would be a BIG step in the right direction

IMO if we just simply "fix" it as you suggested, it will definitely break all the applications built on current API set (check http://steemtools.com/). Alternatively perhaps we can use the "version" field or so to identify clients with different JSON parsers.

I agree, update: versioning API updates would be useful...minor changes on API are expected at this stages...

Sorry, I shouldn't shit in the river. That is correct.

Also, good to know that edge case, but doesn't it make hella-more sense to eliminate edge cases (eg: comment_options)?

Think wider. The capacity of multiple operations in same transaction can bring many benefits, it's not only designed for comment_options.

Does it ever get used that way, though? And why wouldn't it work out to flatten whatever combinations you have in mind? (Or otherwise simplify them)

Some reasons/senarios:

  • you only need one signature for multiple operations in one transaction, so smaller total size
  • you want the operations to be executed on the exact order you specified
  • you want multiple operations to be either all executed, or none executed
  • you don't want others execute an operation in between of your 2 operations (which is the reason for comment_option)

Steem isn't going to succeed by omitting the [0] from transactions[0]['operations'][0]['type'] from a developer perspective. IMHO being a developer is sometimes working with these limits / brainwaves from other devs, which might seem weird at first. Plus as said in previous comments, this array is actually in use and could well be used more in the future for different purposes.

As @abit correctly stated, many current apps also take into consideration this array. Additionally i think we should follow the mantra: grow first, optimize later!

Nonetheless it would be great to keep a tracklog of desired api changes and once there will be a V2 in the making with breaking changes (while keeping the old one alive) these could be implemented.

Dare me to find out?

Hi faddat! I'm not sure what you mean :) I'm not native english... I run Steemtools btw, and made a couple of read-only steem-apps which almost all needed to take into account the array[0] with the operator :) Especially http://steemstream.com/

Challenge accepted.

Pls i dont understand what challenge i set? Thx :)

So now I am going to see what happens if you have steemit, and the API actually works.

I bet the site explodes. I bet it does become the data hub steemit thought it could be.

Arrays always make sense if there's even a chance their might be more than one in the future.

Classic example: an email property field on a contact. Most systems assume there will only ever be one email per contact. Later on if they want to make a change and allow for multiple emails, it breaks everything. If, on the other hand, they start with an array, people can just hard code "get me the first entry". If they later add more, those old clients still work as always while new clients can do something more intelligent. That's just one example. JQuery has used arrays for everything and it really simplifies things. It's all a matter of perspective. To call a design preference an error is a bit dogmatic. I'm glad to see some of the comments here explain possible future evolutions of how these arrays may be used.

Mostly, I'm concerned about unneeded complexity. That's the biggest thing here. But.... yes, you could call me quite dogmatic about that, and you'd be totally right.

I've never seen a trasaction with more than one operation.

Well there are more than 1 operations in transaction. (e.g. from top of my head, authoring and default voting goes to same transaction)
And I also think, the structure may not be optimal, but I like to believe it is structured for the long term and future scaling in mind...

......but what leads you to believe that?

This isn't a feature that helps people build on steem, so it's not going to help scaling.

This isn't a feature that helps people build on steem

Sounds like you are representing all people :P

Super-interesting! Now being flagged by what look to be zombies!

https://steemit.com/@rizwanali101
https://steemit.com/@jenniferlawrence

....or celebrities. I guess I'll let you be the judge on that one. Really I have no idea what's going on with @rizwanali101 or his partner @jenniferlawrence.

I wonder what happens next.

This post has been ranked within the top 50 most undervalued posts in the second half of Dec 15. We estimate that this post is undervalued by $7.40 as compared to a scenario in which every voter had an equal say.

See the full rankings and details in The Daily Tribune: Dec 15 - Part II. You can also read about some of our methodology, data analysis and technical details in our initial post.

If you are the author and would prefer not to receive these comments, simply reply "Stop" to this comment.

  1. I don't think everyone deserves the same level of influence. At the same time it is very important that they can get the same level of influence starting from zero.
  2. of course this post is undervalued. It is highly critical of something steem-related. This is not surprising in the least bit.

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.030
BTC 58389.23
ETH 2521.57
USDT 1.00
SBD 2.35