Author

Topic: How can i calculate the average blocks per a day by just data from rpc commands (Read 183 times)

legendary
Activity: 1624
Merit: 2481
How can i calculate the average blocks per a day by just data from rpc commands. I would also like to calculate the average time per a block this way as well any idea ?

The average amount of blocks per day and the average time per block are calculated using the same 2 variables: Time and Number of blocks.

You can accomplish this by comparing the height each 24 hours.

You can use this command to get the current height:

Code:
getblockcount

The first time measuring, you just write down the number.
24 hours later you can again execute the command and subtract this number from the old one. What you get are the number of blocks in the last 24 hours.

This information is enough to calculate all data you want.
sr. member
Activity: 310
Merit: 727
---------> 1231006505
How can i calculate the average blocks per a day by just data from rpc commands. I would also like to calculate the average time per a block this way as well any idea ?
You can accomplish this if you save some data as response from the "getblock" rpc call. Afaik there is no direct way of doing this by only using one of more rpc calls.

Code:
bitcoin-cli getblock "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"

Gives as result:
Result (for verbosity = 1):
{
  "hash" : "hash",     (string) the block hash (same as provided)
  ],
  "time" : ttt,          (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)
   .....
}
For each block in a 24-hour time frame you store the block along with it's timestamp. When you have those two it shouldn't be hard to calculate the average blocks per day when you do this over a longer period of time. Based on the interval between stored block times it should also be easy to calculate the average time per block.

But, just a reminder: On average Bitcoin aims for a block time of 10 minutes. So even without calculation the numbers you are looking for are:
  • Average blocks per day: 6*24= 144
  • Average block time: 10 minutes

If you want to see the real numbers for a period of time you can obviously calculate them as I explained in the first part. Otherwise just stick with the already known and aimed for averages.
member
Activity: 113
Merit: 10
How can i calculate the average blocks per a day by just data from rpc commands. I would also like to calculate the average time per a block this way as well any idea ?

Am having trouble finding fast ways to do this or a way at all. If you want to do this there must be a good way. And for coins that aren't just btc
Jump to: