Skip to content

区块数减 1 ​

原始发布页

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

我想把状态栏中显示的区块数量减 1。首次加载程序时,它将显示 0 个区块而不是 1 个: “0 个连接 0 个区块 0 笔交易”

它一直是“nBestHeight + 1”,因为把创世区块也算进去了。严格来说,没错,创世区块也是一个区块。它是一个硬编码的区块,是你的起点。你不可能没有创世区块。也许可以把它想成一枚参照币,用来衡量其他币。人们想看的区块计数,是他们已经下载的区块数量。

主要好处是,区块数将等于当前最佳区块的区块编号。如果区块数是 10,那么你拥有的最高区块编号就是 10。这意味着你有区块 10,而没有区块 11。

这会减少我们在这里遇到的困惑:

引用 kencausey 于 2010年8月15日 11:45:26 PM 的发言

引用 davidonpda 于 2010年8月15日 11:31:37 PM 的发言

……它已经在区块 74638 上了。我猜这意味着该区块现在是好区块了?

我自己对此也有些困惑,并在 #bitcoin-dev 中得到了澄清:

坏区块的编号是 74638,最后一个好区块是 74637。编号从 0 开始,所以当你的客户端显示有 74638 个区块时,意味着你拥有的区块截至编号 74637,也就是最后一个好区块。

英文原文 ​

展开英文原文

I'd like to reduce the number of blocks displayed in the status bar by 1. When you first load the program, it'll display 0 blocks instead of 1: "0 connections 0 blocks 0 transactions"

It's always been "nBestHeight + 1" because it's counting the genesis block. Technically, yes, the genesis block is a block. It's a hardcoded block that you start out with. You can't not have the genesis block. Maybe think of it as a reference coin that you measure other coins against. The block count people are looking for is the number of blocks they've downloaded.

The main benefit is that blocks will be equal to the block number of the current best block. If blocks is 10, then the highest block number you have is 10. It means you have block 10 and you don't have block 11.

It would reduce the confusion we had here:

Quote from: kencausey on August 15, 2010, 11:45:26 PM

Quote from: davidonpda on August 15, 2010, 11:31:37 PM

... It already is on block 74638. I assume that means that block is now a good one?

I had some confusion on this myself and got clarification in #bitcoin-dev:

The bad block was number 74638, the last good one was 74637. The numbers start at 0, so when your client shows there are 74638 blocks then that means you have up to block number 74637, the last good one.

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