sebak icon indicating copy to clipboard operation
sebak copied to clipboard

Total Balance in node info API

Open spikeekips opened this issue 7 years ago • 2 comments

Total increased balance = Initial balance + block inflation + PF inflation

spikeekips avatar Dec 05 '18 07:12 spikeekips

I am a little bit confused about this feature; it also can be served by explorer like 3rd party service.

spikeekips avatar Dec 05 '18 09:12 spikeekips

I am a little bit confused about this feature; it also can be served by explorer like 3rd party service.

The total balance could indeed be calculated by third parties since we know all variables. The calculations will be pure, as they will always result in the same output based on those variables.

In its current state, third parties would need to do manual updates when inflation through PF occurs. A developer must know the information below before he can manually add the inflation:

  1. Inflation ratio
  2. Block height of the inflation start
  3. Block height of the inflation end (or duration in blocks)
  4. Current block height

For each new inflation, a developer would have to manually add it to the other inflation calculations, unless that information becomes available through some endpoint. The block inflation, for example, is currently available through the GET https://mainnet.blockchainos.org endpoint:

{
  ...
  "policy": {
    ...
    "initial-balance": "5000000000000000",
    "inflation-ratio": "0.00000010000000000",
    "block-height-end-of-inflation": 36000000
  },
  "block": {
    ...
    "height": 152964
  }
}

Information like this allows third parties to calculate rewards in an automated way (the only thing missing in the above example is the start block height of inflation). If an endpoint or json object would be added to get all inflation variables (for block inflation, PF inflation, ...), third parties could automatically calculate the inflation at any given block height.

The question is, would it be worth the hassle to actually build and provide such endpoints / json objects to calculate the total supply if the API itself can actually do that? It might be worth it if you ever need to be able to provide information about all past, current and present inflations.

It basically comes down to where you want to put the responsibility of calculating the supply:

  1. Do you want to make it easy for third parties? Calculate and provide the total supply through the API.
  2. Do you want third parties to be able to calculate the supply in an automated way? Provide the inflation information through the API.
  3. Do you want third parties to be able to calculate the supply in a manual way? Provide the inflation information through public channels such as the official websites.

dahemmer avatar Dec 06 '18 05:12 dahemmer