diff --git a/docs/com/google/bitcoin/core/BlockStore.html b/docs/com/google/bitcoin/core/BlockStore.html new file mode 100644 index 00000000..0e0b00db --- /dev/null +++ b/docs/com/google/bitcoin/core/BlockStore.html @@ -0,0 +1,294 @@ + + + +
+
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface BlockStore
+An implementor of BlockStore saves StoredBlock objects to disk. Different implementations store them in + different ways. An in-memory implementation (MemoryBlockStore) exists for unit testing but real apps will want to + use implementations that save to disk.
+ + A BlockStore is a map of hashes to StoredBlock. The hash is the double digest of the BitCoin serialization + of the block header, not the header with the extra data as well.
+ + BlockStores are thread safe. +
+ +
+
+Method Summary | +|
---|---|
+ StoredBlock |
+get(byte[] hash)
+
++ 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. |
+
+Method Detail | +
---|
+void put(StoredBlock block) + throws BlockStoreException+
+
BlockStoreException
+StoredBlock get(byte[] hash) + throws BlockStoreException+
+
BlockStoreException
+StoredBlock getChainHead() + throws BlockStoreException+
StoredBlock
that represents the top of the chain of greatest total work.
++
BlockStoreException
+void setChainHead(StoredBlock chainHead) + throws BlockStoreException+
StoredBlock
that represents the top of the chain of greatest total work.
++
BlockStoreException
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.bitcoin.core.DiskBlockStore ++
public class DiskBlockStore
+Stores the block chain to disk but still holds it in memory. This is intended for desktop apps and tests. + Constrained environments like mobile phones probably won't want to or be able to store all the block headers in RAM. +
+ +
+
+Constructor Summary | +|
---|---|
DiskBlockStore(NetworkParameters params,
+ java.io.File file)
+
++ |
+
+Method Summary | +|
---|---|
+ StoredBlock |
+get(byte[] hash)
+
++ 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 DiskBlockStore(NetworkParameters params, + java.io.File file) + throws BlockStoreException+
BlockStoreException
+Method Detail | +
---|
+public void put(StoredBlock block) + throws BlockStoreException+
BlockStore
+
put
in interface BlockStore
BlockStoreException
+public StoredBlock get(byte[] 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.
++
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 | +
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.bitcoin.core.MemoryBlockStore ++
public class MemoryBlockStore
+Keeps StoredBlock
s in memory. Used primarily for unit testing.
+
+ +
+
+Constructor Summary | +|
---|---|
MemoryBlockStore(NetworkParameters params)
+
++ |
+
+Method Summary | +|
---|---|
+ StoredBlock |
+get(byte[] hash)
+
++ 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 MemoryBlockStore(NetworkParameters params)+
+Method Detail | +
---|
+public void put(StoredBlock block) + throws BlockStoreException+
BlockStore
+
put
in interface BlockStore
BlockStoreException
+public StoredBlock get(byte[] hash) + throws BlockStoreException+
BlockStore
+
get
in interface BlockStore
BlockStoreException
+public StoredBlock getChainHead()+
BlockStore
StoredBlock
that represents the top of the chain of greatest total work.
++
getChainHead
in interface BlockStore
+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 | +
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.bitcoin.core.Sha256Hash ++
public class Sha256Hash
+A Sha256Hash just wraps a byte[] so that equals and hashcode work correctly, allowing it to be used as keys in a + map. It also checks that the length is correct and provides a bit more type safety. +
+ +
+
+Field Summary | +|
---|---|
+ byte[] |
+hash
+
++ |
+
+Constructor Summary | +|
---|---|
Sha256Hash(byte[] hash)
+
++ |
+
+Method Summary | +|
---|---|
+ boolean |
+equals(java.lang.Object other)
+
++ Returns true if the hashes are equal. |
+
+ int |
+hashCode()
+
++ Hash code of the byte array as calculated by Object.hashCode() . |
+
+ java.lang.String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
+
+Field Detail | +
---|
+public byte[] hash+
+Constructor Detail | +
---|
+public Sha256Hash(byte[] hash)+
+Method Detail | +
---|
+public boolean equals(java.lang.Object other)+
+
equals
in class java.lang.Object
+public int hashCode()+
Object.hashCode()
. Note the difference between a SHA256
+ secure hash and the type of quick/dirty hash used by the Java hashCode method which is designed for use in
+ hash tables.
++
hashCode
in class java.lang.Object
+public java.lang.String toString()+
toString
in class java.lang.Object
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.bitcoin.core.StoredBlock ++
public class StoredBlock
+Wraps a Block
object with extra data that can be derived from the block chain but is slow or inconvenient to
+ calculate. By storing it alongside the block header we reduce the amount of work required significantly.
+ Recalculation is slow because the fields are cumulative - to find the chainWork you have to iterate over every
+ block in the chain back to the genesis block, which involves lots of seeking/loading etc. So we just keep a
+ running total: it's a disk space vs cpu/io tradeoff.
+
+ StoredBlocks are put inside a BlockStore
which saves them to memory or disk.
+
+ +
+
+Constructor Summary | +|
---|---|
StoredBlock(Block header,
+ java.math.BigInteger chainWork,
+ int height)
+
++ |
+
+Method Summary | +|
---|---|
+ StoredBlock |
+build(Block block)
+
++ Creates a new StoredBlock, calculating the additional fields by adding to the values in this block. |
+
+ boolean |
+equals(java.lang.Object other)
+
++ |
+
+ java.math.BigInteger |
+getChainWork()
+
++ The total sum of work done in this block, and all the blocks below it in the chain. |
+
+ Block |
+getHeader()
+
++ The block header this object wraps. |
+
+ int |
+getHeight()
+
++ Position in the chain for this block. |
+
+ StoredBlock |
+getPrev(BlockStore store)
+
++ Given a block store, looks up the previous block in this chain. |
+
+ int |
+hashCode()
+
++ |
+
+ boolean |
+moreWorkThan(StoredBlock other)
+
++ Returns true if this objects chainWork is higher than the others. |
+
+ java.lang.String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public StoredBlock(Block header, + java.math.BigInteger chainWork, + int height)+
+Method Detail | +
---|
+public Block getHeader()+
+
+public java.math.BigInteger getChainWork()+
+
+public int getHeight()+
+
+public boolean moreWorkThan(StoredBlock other)+
+
+public boolean equals(java.lang.Object other)+
equals
in class java.lang.Object
+public int hashCode()+
hashCode
in class java.lang.Object
+public StoredBlock build(Block block) + throws VerificationException+
+
VerificationException
+public StoredBlock getPrev(BlockStore store) + throws BlockStoreException+
+
BlockStoreException
+public java.lang.String toString()+
toString
in class java.lang.Object
+
+
|
++ + | +|||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.bitcoin.examples.DumpWallet ++
public class DumpWallet
+DumpWallet loads a serialized wallet and prints information about what it contains. +
+ +
+
+Constructor Summary | +|
---|---|
DumpWallet()
+
++ |
+
+Method Summary | +|
---|---|
+static void |
+main(java.lang.String[] args)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public DumpWallet()+
+Method Detail | +
---|
+public static void main(java.lang.String[] args) + throws java.lang.Exception+
java.lang.Exception
+
+
|
++ + | +||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +