5

For bitcoin-cli getblock, what's the difference between "time" and "mediantime"?

If i'm looking for a strictly increasing series of timestamps, is one better to choose than the other?

1 Answer 1

8

mediantime is better for your purpose. The timestamp is chosen by the miners, and has some restrictions on it such as it can't be too far in the future/past (no more than 2 hours into the future), but it is not strictly increasing. Mediantime, on the other hand, is. Mediantime is the median time of the past 11 block timestamps, and a block must have a timestamp greater than that median time, so the mediantime always increases.

3
  • So it's possible to have a higher block with a lower time than a lower block?!
    – M.K. Safi
    Commented Feb 21, 2020 at 4:57
  • Correct, as long as it obeys the other rules Commented Feb 22, 2020 at 21:58
  • To add to this answer, it would be good to reference BIP113 which explains a bit more on how GetMedianTimePast is used: github.com/bitcoin/bips/blob/master/bip-0113.mediawiki
    – SondreB
    Commented Apr 30, 2020 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.