《详解比特币白皮书》-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.

为了实现这个而无需破坏区块哈希,交易记录被哈希到Merkle树中,区块哈希只保留根节点

 

Old blocks can then be compacted by stubbing off branches of the tree. 

旧区可以通裁剪掉枝来压缩。中间节点的哈希没必要保存。

The interior hashes do not need to be stored.

 

Merkle Tree),又被称哈希、可信构上是一棵完全二叉,每个点都有一个哈希与之对应,叶子点的哈希需要认证的数据行哈希运算得到的,而中间节点的哈希是由其子点的哈希值联行哈希运算得到的。

如果不用Merkle树,而是用一种扁平的结构来存储哈希值,例如把所有交易的打包哈希成一个哈希值,类似一个列表的结构。这种情况下验证任一笔交易,都需要存储其他所有交易数据。

作者已经说的很明白,采用Merkle树的目的之一就是为了节省空间。如图,为了验证交易Tx3并不需要保持完整的树,只需要保存Tx3和根节点以及路径上相关的哈希值,就能逐层验证Tx3。Merkle树还有一个特色,就是可以快速定位出错的数据。假如Tx3被篡改,那么Hash3、Hash23、Root Hash这一个路径上的哈希值都会对不上。

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. 

在没有交易记录的情况下,区块头部的体80。如果我10钟产生一个区80* 6 * 24 * 365 = 4.2MB每年。

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. 

按照2008算机系典型搭售2GB内存,以及摩定律预测当前增每年1.2GB,那么就算将全部区块头部放入内存也不成问题

注:在有交易记录的情况下,平均每个交易至少250,按平均每个区包含2000个交易来估算,包含完整交易记录的区大小相当于区块头的数千倍。随着交易的不断生,存的占用会越来越大。比特采用Merkle树来节约空间,即不要求每个节点都储存完整的区块链数据,那么如何在不下载全部交易记录的情况下来验证交易呢?于是就引出了下一章的SPV……

猜你喜欢

转载自blog.csdn.net/q602968956/article/details/85028645