Bitcoin Forum
August 02, 2021, 07:21:33 AM
 News: Latest Bitcoin Core release: 0.21.1 [Torrent]
 Home Help Search Login Register More
 Pages: [1]
 Author Topic: How can i calculate the average blocks per a day by just data from rpc commands  (Read 153 times)
mrmetech
Member

Offline

Activity: 114
Merit: 10

 August 25, 2018, 03:32:28 AM

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

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
TheArchaeologist
Full Member

Offline

Activity: 210
Merit: 459

---------> 1231006505

 August 26, 2018, 08:31:07 AM

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:

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.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
bob123
Legendary

Offline

Activity: 1582
Merit: 2356

 August 29, 2018, 10:53:20 AM

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.

 ░░░░░▄▄██████▄▄░░▄████▀▀▀▀▀▀████▄░███▀░░░░░░░░░░▀█▀████░░░▄██████▄▄░░░██░░░░░█████████░░░░██▌░░░░█████████████████░░░░█████████████████░░░░░███████████████████▄░░▀██████▀░░░████▀█▄▄░░░░░░░░░░▄███░░▀████▄▄▄▄▄▄████▀░░░░░▀▀██████▀▀ .ChipMixer.{ MIXING REINVENTED FOR YOUR PRIVACY #.ChipMixer. ░░░░░▄▄██████▄▄░░▄████▀▀▀▀▀▀████▄░███▀░░░░░░░░░░▀█▀████░░░▄██████▄▄░░░██░░░░░█████████░░░░██▌░░░░█████████████████░░░░█████████████████░░░░░███████████████████▄░░▀██████▀░░░████▀█▄▄░░░░░░░░░░▄███░░▀████▄▄▄▄▄▄████▀░░░░░▀▀██████▀▀
 Pages: [1]