public class MemoryBlockStore extends Object implements BlockStore
StoredBlocks in memory. Used primarily for unit testing.| Constructor and Description |
|---|
MemoryBlockStore(NetworkParameters params) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the store.
|
StoredBlock |
get(Sha256Hash hash)
Returns the StoredBlock given a hash.
|
StoredBlock |
getChainHead()
Returns the
StoredBlock that represents the top of the chain of greatest total work. |
NetworkParameters |
getParams()
Get the
NetworkParameters of this store. |
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. |
public MemoryBlockStore(NetworkParameters params)
public void put(StoredBlock block) throws BlockStoreException
BlockStoreput in interface BlockStoreBlockStoreExceptionpublic StoredBlock get(Sha256Hash hash) throws BlockStoreException
BlockStoreget in interface BlockStoreBlockStoreExceptionpublic StoredBlock getChainHead() throws BlockStoreException
BlockStoreStoredBlock that represents the top of the chain of greatest total work. Note that this
can be arbitrarily expensive, you probably should use AbstractBlockChain.getChainHead()
or perhaps AbstractBlockChain.getBestChainHeight() which will run in constant time and
not take any heavyweight locks.getChainHead in interface BlockStoreBlockStoreExceptionpublic void setChainHead(StoredBlock chainHead) throws BlockStoreException
BlockStoreStoredBlock that represents the top of the chain of greatest total work.setChainHead in interface BlockStoreBlockStoreExceptionpublic void close()
BlockStoreclose in interface BlockStorepublic NetworkParameters getParams()
BlockStoreNetworkParameters of this store.getParams in interface BlockStoreCopyright © 2015. All rights reserved.