Bitcoind statistics

3

I need to get some values to find how updated my bitcoind client is.

For example, I would like the GUI to tell me:

  1. If it is up to date. If not, show blocks/total blocks
  2. How many blocks have been downloaded
  3. The time that the last received block was generated.

Are there commands available in the JSON API to get this information? Or how else can I achieve this?

Regards

lbo

Posted 2012-03-09T10:37:18.470

Reputation: 31

I was under the impression that version 5+ of the client (bitcoin-qt) offers all these capabilities. Am I wrong?ripper234 2012-03-09T12:37:42.907

The client can't possibly tell if it's up to date in terms of blocks. The only way the client can know a block exists is to validate it. The only way to validate a block is to have it already. The client has no other mechanism to become convinced that it's not already current. (The exception would be if there was a checkpoint ahead of it.)David Schwartz 2012-03-10T05:44:27.663

How does Bitcoin-QR know it is "out of sync"? And it also says something like ~24 block(s) remaining.kermit 2012-10-28T14:39:26.763

Answers

1

You probably need to read: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

You'll probably like the methods getblockcount and getblocknumber.

I don't think the API can give you the latest blocknumber until it's been updated, but you can find it on http://bitcoinwatch.com/ -> blocks -> count.

neofutur

Posted 2012-03-09T10:37:18.470

Reputation: 1 495

more details ( from #bitcoin-dev on IRC, thanks to sturles ) : the client can't know for sure until all the blocks are verified, but it can report what other clients claim they have. A malicious client can report arbitrary numbers to your client, so the bitcoin client can not be sure until the last block is verified. It can also make a guesstimate based on the current time and the age of the last verified block.neofutur 2012-03-09T11:45:17.947

so your best guess will probably be to get the latest block number from a trusted provider ( bitcoinwatch.com is just an example)neofutur 2012-03-09T11:47:19.737

Thanks for your reply.

I read that API command list but it is pretty vague.

The whole idea of doing this was to avoid using any 3rd party :(

How can I make a guestimate? How can I get the last verified block?

Cheers. – lbo 2012-03-09T11:51:35.320

you have no way to be sure of it until your local client have verifieds all the blocks; other clients can lie to you, but having a look at the client code and debug.log, you could find that other nodes are sending you messages like "version message: version 32300,blocks=170346", they tell you their version and blockcount, you can ignore old version clients and decide that all the latest version ones should have the latest block.neofutur 2012-03-09T12:26:19.110

2

having this option ( downloaded XXX/YYYY blocks ) could really be useful for bitcoin users, if you can implement it as an API call, please fork https://github.com/bitcoin/bitcoin and send a pull request to share your good idea with others !

neofutur 2012-03-09T12:28:32.773