public class MemoryBlockStore extends java.lang.Object implements BlockStore
StoredBlock
s 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 final void put(StoredBlock block) throws BlockStoreException
BlockStore
put
in interface BlockStore
BlockStoreException
public StoredBlock get(Sha256Hash hash) 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. 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 BlockStore
BlockStoreException
public final void setChainHead(StoredBlock chainHead) throws BlockStoreException
BlockStore
StoredBlock
that represents the top of the chain of greatest total work.setChainHead
in interface BlockStore
BlockStoreException
public void close()
BlockStore
close
in interface BlockStore
public NetworkParameters getParams()
BlockStore
NetworkParameters
of this store.getParams
in interface BlockStore