In bitcoinj, why is MemoryBlockStore not used by default?

3

My understanding of bitcoinj is that it is used to implement a "thin client" that doesn't store the entire blockchain- just the headers.

When I use the WalletAppKit, it creates a file "default.spvchain" that is 626Kib. This could easily fit in memory, so why is SPVBlockStore (using memory mapped file) used? Wouldn't MemoryBlockStore be a better choice?

yzernik

Posted 2013-10-24T06:18:27.463

Reputation: 173

Answers

1

If you don't persist the headers in some way then you'd have to reload them each time you launched. Loading the headers from scratch isn't a free operation. Its not just a matter of downloading 626k. It may be a small amount of data in the end but each header still needs to be verified (targets calculated and checked, etc). Not only that, but there are less obvious privacy implications of requesting the block chain from the network each time.

SPVBlockStore still uses memory mapped IO so its not like you take a performance hit, it just makes subsequent launches of the software faster.

jwsample

Posted 2013-10-24T06:18:27.463

Reputation: 154