public class LevelDBBlockStore extends java.lang.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,
java.io.File directory)
Creates a LevelDB SPV block store using the JNI/C++ version of LevelDB.
|
LevelDBBlockStore(Context context,
java.io.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, java.io.File directory) throws BlockStoreException
BlockStoreException
public LevelDBBlockStore(Context context, java.io.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 java.io.IOException
java.io.IOException
public NetworkParameters getParams()
BlockStore
NetworkParameters
of this store.getParams
in interface BlockStore