|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.bitcoin.core.BoundedOverheadBlockStore
public class BoundedOverheadBlockStore
Stores the block chain to disk.
This implementation is designed to have constant memory usage, regardless of the size of the block chain being stored. It exploits operating system level buffering and the fact that get() requests are, in normal usage, localized in chain space.
Blocks are stored sequentially. Most blocks are fetched out of a small in-memory cache. The slowest part is traversing difficulty transition points, which requires seeking backwards over around 2000 blocks. On a Google Nexus S phone this takes a couple of seconds. On a MacBook Pro it takes around 50msec.
The store has much room for optimization. Expanding the size of the cache will likely allow us to traverse difficulty transitions without using too much memory and without hitting the disk at all, for the case of initial block chain download. Storing the hashes on disk would allow us to avoid deserialization and hashing which is expensive on Android.
Constructor Summary | |
---|---|
BoundedOverheadBlockStore(NetworkParameters params,
File file)
|
Method Summary | |
---|---|
StoredBlock |
get(byte[] hashBytes)
Returns the StoredBlock given a hash. |
StoredBlock |
getChainHead()
Returns the StoredBlock that represents the top of the chain of greatest total work. |
void |
put(StoredBlock block)
Saves the given block header+extra data. |
void |
setChainHead(StoredBlock chainHead)
Sets the StoredBlock that represents the top of the chain of greatest total work. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BoundedOverheadBlockStore(NetworkParameters params, File file) throws BlockStoreException
BlockStoreException
Method Detail |
---|
public void put(StoredBlock block) throws BlockStoreException
BlockStore
put
in interface BlockStore
BlockStoreException
public StoredBlock get(byte[] hashBytes) throws BlockStoreException
BlockStore
get
in interface BlockStore
BlockStoreException
public StoredBlock getChainHead() throws BlockStoreException
BlockStore
StoredBlock
that represents the top of the chain of greatest total work.
getChainHead
in interface BlockStore
BlockStoreException
public void setChainHead(StoredBlock chainHead) throws BlockStoreException
BlockStore
StoredBlock
that represents the top of the chain of greatest total work.
setChainHead
in interface BlockStore
BlockStoreException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |