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.
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.