bosnet / sebak

SEBAK, the next BOScoin Blockchain
https://devteam.blockchainos.org
GNU General Public License v3.0
44 stars 15 forks source link

[Debate] Features and responsabilities of the SEBAK API #867

Open dahemmer opened 5 years ago

dahemmer commented 5 years ago

I'm creating this issue to debate the features and responsabilities of the SEBAK API.

The SEBAK API provides endpoints to obtain data such as blocks, transactions, operations, accounts, etc. This allows third parties to get the SEBAK blockchain state in real-time.

Third parties currently have two options to query data, through path parameters and through query parameters.

Path parameters

  1. /blocks/{height} returns the block for the provided height
  2. /accounts/{address} returns the account for the provided address
  3. /transactions/{hash} returns the transaction for the provided hash

Query parameters

  1. limit=x returns x amount of records
  2. reverse=x sorts data in x order
  3. cursor=x returns data starting from cursor x

While these options allow third parties to retrieve specific information, they don't provide many ways to query the data. If a third party for example wants to obtain all accounts having a balance > 10000 BOS, then there is no way to actually to retrieve this data through the use of the SEBAK API. This is just one example, but the possibilities could be endless as far as querying options are concerned.

Will the SEBAK API ever expose endpoints and query parameters for statistical purposes and data analysis? Would that be considered as a (future) responsability of the SEBAK API?

Geod24 commented 5 years ago

In short - no.

Every capability that the API exposes means more storage used, or more computing power. If we expose the ability to get all accounts with a balance > 10k, it means we either need to maintain an index, or iterate over all the account when this information is requested.

Which is fine in an API server, but Sebak is the core node of BOSnet. We had discussions about splitting the two (Horizon/Stellar-core like), but didn't have time to address it before BOSCON. If/When this is done, that's definitely somewhere where we will have more freedom.

spikeekips commented 5 years ago

This issue, extending the capability of API will be always welcome. As you suggested API should provide the sophisticated way to get the specific data. As @Geod24 said, devteam already have discussed how to extend API and how to make node to be simpler. At this time, I suggest to use watcher mode + jsonrpc for storage. You can run SEBAK node as watcher mode and you can access the node storage thru jsonrpc.

anarcher commented 5 years ago

Sometimes, I feel that RPC or GraphQL is better than REST API for supporting like balance > 10000 BOS . But I am not sure that queries like balance > 10000 BOS is available with generally blockchain nodes such as btcd or ethd.