How to get the time when a block is received at a node?


Is there any variable in the bitcoind code that records the timestamp when a block is received for the first time by a particular node? To be more precise, for transactions, transaction information returned by Bitcoind JSON RPC API contains timereceived. Is there similar field for blocks in the API?

There happens to be similar existing questions in stackexchange but none of them has been appropriately answered.


Posted 2020-05-28T01:57:38.707

Reputation: 11



I don't believe this is exposed via the JSON-RPC API.

The easiest method would likely be to have a program monitoring debug.log and look for the best height update messages - they will be a few milliseconds off, since I believe those are only logged after block validation has succeeded, but it is likely the closest you can get to a per-node block receipt time, at least without monitoring the network traffic.

Raghav Sood

Posted 2020-05-28T01:57:38.707

Reputation: 15 741

Thanks. In that last line you mention "without monitoring the network traffic". It would be great if you could elaborate on how to determine the timestamps when a block is received by monitoring the network traffic. – Dragonboy – 2020-05-28T06:53:18.527