Number of coins mined
-
So I'm working on an about page for my upcoming Burst site, and I'd like to show a realtime counter of how many coins have been mined, similar to http://burstcoin.biz/stats. However when I run (my version) of the getBlockReward() code in https://github.com/burst-team/burstcoin/blob/master/src/java/nxt/BlockImpl.java and loop through all the blocks, the total is always higher than what burstcoin.biz displays.
For example, at block 364983 burstcoin.biz reports 1777179682 available Burst. However my calculations put it at 1778139360.
Am I doing something wrong or is burstcoin.biz off?
-
burstcoin.biz is probably off. :)
You can also check the coinmarketcap api: https://api.coinmarketcap.com/v1/ticker/burst/
-
@daWallet coinmarketcap.com displays yet another number, though it appears to be the same as burstcoin.biz, just delayed by a few blocks. So that makes me think I'm doing something wrong.
Yet when I calculate the total coins generated by looping through blocks 1 - 1944000, I get exactly the number of coins advertised to be created: 2158812800. So for now I'm going to run with it.
-
@FlippyCakes all of these databases rely on caching the blockchain. into a sql table.
so you get differences.
burstcoin.biz has this problem with the block explorer when the network forks. some of the transactions inside the explorer actually dont exist and some of the ones aint in the explorer do exist.
this is why your number differs from the rest as it also records blocks that wasnt won and have been won. its pretty confusing.
its always best to go straight off the chain. using the method you have is probably best.
the only issue with this is you have to recalculate it everytime cause the moment you store this in a sql database you will come accross the problems above
-
@Lexicon Yeah, I'm pretty sure I've got an accurate number. I've just stored the coins in existence at a particular height and then it's trivial to calculate those up to the current chain height and add the two numbers.
-
@FlippyCakes that sir is exactly how it should be done :)
