public class LevelDBBlockStore extends Object implements BlockStore
SPVBlockStore
. If all you want is a regular wallet you don't need this class: it exists for
specialised applications where you need to quickly verify a standalone SPV proof.Constructor and Description |
---|
LevelDBBlockStore(Context context,
File directory)
Creates a LevelDB SPV block store using the JNI/C++ version of LevelDB.
|
LevelDBBlockStore(Context context,
File directory,
org.iq80.leveldb.DBFactory dbFactory)
Creates a LevelDB SPV block store using the given factory, which is useful if you want a pure Java version.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the store.
|
void |
destroy() |
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 |
reset()
Erases the contents of the database (but NOT the underlying files themselves) and then reinitialises with the genesis block.
|
void |
setChainHead(StoredBlock chainHead)
Sets the
StoredBlock that represents the top of the chain of greatest total work. |
public LevelDBBlockStore(Context context, File directory) throws BlockStoreException
BlockStoreException
public LevelDBBlockStore(Context context, File directory, org.iq80.leveldb.DBFactory dbFactory) throws BlockStoreException
BlockStoreException
public void put(StoredBlock block) throws BlockStoreException
BlockStore
put
in interface BlockStore
BlockStoreException
@Nullable 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 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() throws BlockStoreException
BlockStore
close
in interface BlockStore
BlockStoreException
public void reset() throws BlockStoreException
BlockStoreException
public void destroy() throws IOException
IOException
public NetworkParameters getParams()
BlockStore
NetworkParameters
of this store.getParams
in interface BlockStore
Copyright © 2016. All rights reserved.