7. Reclaiming Disk Space
Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space. To facilitate this without breaking the block's hash, transactions are hashed in a Merkle Tree [7][2][5], with only the root included in the block's hash. Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do not need to be stored.
如果最近的交易已经被纳入了足够多的区块之中,那么就可以丢弃该交易之前的数据,以回收硬盘空间。 为了同时确保不损害区块的随机散列值,交易信息被随机散列时,被构建成一种梅克尔树(Merkle tree)的形态,使得只有根被纳入了区块的随机散列值。通过将该树的分支拔除的方法,老区块就能被压缩。而内部的随机散列值是不必保存的。
A block header with no transactions would be about 80 bytes. If we suppose blocks are generated every 10 minutes, 80 bytes * 6 * 24 * 365 = 4.2MB per year. With computer systems typically selling with 2GB of RAM as of 2008, and Moore's Law predicting current growth of 1.2GB per year, storage should not be a problem even if the block headers must be kept in memory.
不含交易信息的区块头大小仅有 80 字节。如果我们设定区块生成的速率为每 10 分钟一个,那么每一年产生的数据位 4.2MB。(80 bytes * 6 * 24 * 365 = 4.2MB)。2008 年,PC 系统通常的内存容量为 2GB,按照摩尔定律的预言,即使将全部的区块头存储于内存之中都不是问题。
网友评论