更快的初始区块下载(快 5 倍)
原始发布页
打开来源页面查看 1 个交叉存档
通过调整一些数据库设置,我把初始区块下载速度提高到了大约 5 倍。现在大约 30 分钟就能下载完。
数据库默认会把每个区块同步写入磁盘,但这并非必要。我修改了设置,让它在内存中缓存改动,再成批写出。区块仍然以事务方式写入,所以要么完整改动全部发生,要么完全不发生;无论哪种情况,数据都会保持在有效状态。
我只在初始区块下载期间启用了这项改动。当你距离最新区块不到 2000 个区块时,这些改动会关闭,速度也会降回原来的方式。
如果你想开始使用,我做了一个测试版本:
http://www.bitcoin.org/download/bitcoin-0.3.2.5-win32.ziphttp://www.bitcoin.org/download/bitcoin-0.3.2.5-linux.tar.gz
这些二进制文件还包含加文·安德烈森的 JSON-RPC HTTP 身份验证功能,以及 0.3.2 中其他重要的安全改进。
过去 24 小时里,我一直在做一项测试:当它尝试进行初始区块下载时,每隔 2-60 秒随机终止并重启它(可怜的家伙),到现在一直没出问题。
它处理 wallet.dat 的方式没有任何变化。这项改动只针对 blk*.dat 和并不关键的 addr.dat。如果 blk*.dat 出了问题,你随时可以删除它,让它重新下载。
英文原文
展开英文原文
By making some adjustments to the database settings, I was able to make the initial block download about 5 times faster. It downloads in about 30 minutes.
The database default had it writing each block to disk synchronously, which is not necessary. I changed the settings to let it cache the changes in memory and write them out in a batch. Blocks are still written transactionally, so either the complete change occurs or none of it does, in either case the data is left in a valid state.
I only enabled this change during the initial block download. When you come within 2000 blocks of the latest block, these changes turn off and it slows down to the old way.
I built a test build if you'd like to start using it:
http://www.bitcoin.org/download/bitcoin-0.3.2.5-win32.ziphttp://www.bitcoin.org/download/bitcoin-0.3.2.5-linux.tar.gz
These binaries also include Gavin Andresen's JSON-RPC HTTP authentication feature and the other important security improvements from 0.3.2.
I've been running a test over the last 24 hours that kills and restarts it randomly every 2-60 seconds (poor thing) while it's trying to do an initial block download and it's been fine.
There are no changes to the way it handles wallet.dat. This change is only for blk*.dat and the non-critical addr.dat. You can always delete blk*.dat if it gets screwed up and let it re-download.