omgnetwork / elixir-omg

OMG-Network repository of Watcher and Watcher Info
https://omg.network
Apache License 2.0
211 stars 59 forks source link

Watcher API responses redefinition #266

Closed pnowosie closed 5 years ago

pnowosie commented 5 years ago

I'd like to start a discussion to redefine data WatcherAPI returns to make it align better for new database structure.

Proposed changes

You can take a look at swagger definition changes in commit or review it in SwaggerUI

jarindr commented 5 years ago

I love this, some question before we go further:

pnowosie commented 5 years ago

Yeah - sorry it's a little hard to think of it from git-diff. So Transaction is there as well and contains mostly the same data but nicely structured. TransactionItem is a new structure for items of the list of transactions (e.g.: /transactions?address=) and is limited to most important data.

kevsul commented 5 years ago

I understand that you want to reduce the amount of data returned for each transaction in the list, but I wonder if the reduced data is useful at all?

I can think of 2 reasons you would want to get a list of txs for an account: a BlockExplorer and a Wallet. In both cases you would want to show the value (and currency) of the tx, and whether it's incoming or outgoing e.g. 0x742d35cc6634c0532925a3b844bc454e4438f44e

It's a lot of traffic if the client has to make separate call for each transaction to get the missing details...

You could try to calculate the value in the watcher and add that to TransactionItem. But I'd be inclined to just send the entire Transaction and let the client do it.

pnowosie commented 5 years ago

I can agree to the point that whether transaction list is filtered by particular account address, at least direction currency and amount of value (sent/received) by address is the interesting part. However in more general case with n-inputs and k-outputs this is probably a waste of throughput as we couldn't present these data on the list.

kevsul commented 5 years ago

Ok, so if the address is passed in, then the server can calculate value, currency and direction and include them in the returned data. value is the amount sent or received by the address.

If the address isn't passed in then direction is meaningless, and value is the sum of all the outputs.

Note that value is slightly different in each case...

pnowosie commented 5 years ago

Yeah, what adds even more complexity here is there could be different currencies used in the inputs & outputs - so summing them up isn't possible...

pnowosie commented 5 years ago

Closing as API specification already defines data for the Watcher endpoints