Skip to content

回复:难度 ​

原始发布页

打开来源页面
查看 1 个交叉存档

你看错代码了。下面才是适用的代码:

代码:

bool CBlock::CheckBlock() const
{
...
// Check timestamp
if (nTime > GetAdjustedTime() + 2 \* 60 \* 60)
return error("CheckBlock() : block timestamp too far in the future");
...

bool CBlock::AcceptBlock()
{
...
// Check timestamp against prev
if (nTime <= pindexPrev->GetMedianTimePast())
return error("AcceptBlock() : block's timestamp is too early");

时间戳最多只能超前 2 小时。它可以早于前一个区块,但必须晚于最近 11 个区块时间戳的中位数。之所以这样处理,是为了在前一个区块的时间过度超前时,能在下一个区块中把时间纠正回来,就像这次发生的情况一样。

英文原文 ​

展开英文原文

You were looking at the wrong code. Here's the code that applies:

Code:

bool CBlock::CheckBlock() const { ... // Check timestamp if (nTime > GetAdjustedTime() + 2 * 60 * 60) return error("CheckBlock() : block timestamp too far in the future"); ...

bool CBlock::AcceptBlock() { ... // Check timestamp against prev if (nTime <= pindexPrev->GetMedianTimePast()) return error("AcceptBlock() : block's timestamp is too early");

The timestamp is limited to up to 2 hours in the future. It can be earlier than the previous block, but it must be greater than the median of the last 11 blocks. The reason for doing it that way is so the time can get corrected in the next block if the previous block had the time too far in the future, like what happened.

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。