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 @@ + + + + + +BlockStore + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.core +
+Interface BlockStore

+
+
All Known Implementing Classes:
DiskBlockStore, MemoryBlockStore
+
+
+
+
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
+ StoredBlockget(byte[] hash) + +
+          Returns the StoredBlock given a hash.
+ StoredBlockgetChainHead() + +
+          Returns the StoredBlock that represents the top of the chain of greatest total work.
+ voidput(StoredBlock block) + +
+          Saves the given block header+extra data.
+ voidsetChainHead(StoredBlock chainHead) + +
+          Sets the StoredBlock that represents the top of the chain of greatest total work.
+  +

+ + + + + + + + +
+Method Detail
+ +

+put

+
+void put(StoredBlock block)
+         throws BlockStoreException
+
+
Saves the given block header+extra data. The key isn't specified explicitly as it can be calculated from the + StoredBlock directly. Can throw if there is a problem with the underlying storage layer such as running out of + disk space. +

+

+ +
Throws: +
BlockStoreException
+
+
+
+ +

+get

+
+StoredBlock get(byte[] hash)
+                throws BlockStoreException
+
+
Returns the StoredBlock given a hash. The returned values block.getHash() method will be equal to the + parameter. If no such block is found, returns null. +

+

+ +
Throws: +
BlockStoreException
+
+
+
+ +

+getChainHead

+
+StoredBlock getChainHead()
+                         throws BlockStoreException
+
+
Returns the StoredBlock that represents the top of the chain of greatest total work. +

+

+ +
Throws: +
BlockStoreException
+
+
+
+ +

+setChainHead

+
+void setChainHead(StoredBlock chainHead)
+                  throws BlockStoreException
+
+
Sets the StoredBlock that represents the top of the chain of greatest total work. +

+

+ +
Throws: +
BlockStoreException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/google/bitcoin/core/DiskBlockStore.html b/docs/com/google/bitcoin/core/DiskBlockStore.html new file mode 100644 index 00000000..f6191ab1 --- /dev/null +++ b/docs/com/google/bitcoin/core/DiskBlockStore.html @@ -0,0 +1,357 @@ + + + + + +DiskBlockStore + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.core +
+Class DiskBlockStore

+
+java.lang.Object
+  extended by com.google.bitcoin.core.DiskBlockStore
+
+
+
All Implemented Interfaces:
BlockStore
+
+
+
+
public class DiskBlockStore
extends java.lang.Object
implements BlockStore
+ + +

+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
+ StoredBlockget(byte[] hash) + +
+          Returns the StoredBlock given a hash.
+ StoredBlockgetChainHead() + +
+          Returns the StoredBlock that represents the top of the chain of greatest total work.
+ voidput(StoredBlock block) + +
+          Saves the given block header+extra data.
+ voidsetChainHead(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
+ +

+DiskBlockStore

+
+public DiskBlockStore(NetworkParameters params,
+                      java.io.File file)
+               throws BlockStoreException
+
+
+ +
Throws: +
BlockStoreException
+
+ + + + + + + + +
+Method Detail
+ +

+put

+
+public void put(StoredBlock block)
+         throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Saves the given block header+extra data. The key isn't specified explicitly as it can be calculated from the + StoredBlock directly. Can throw if there is a problem with the underlying storage layer such as running out of + disk space. +

+

+
Specified by:
put in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+
+ +

+get

+
+public StoredBlock get(byte[] hash)
+                throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Returns the StoredBlock given a hash. The returned values block.getHash() method will be equal to the + parameter. If no such block is found, returns null. +

+

+
Specified by:
get in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+
+ +

+getChainHead

+
+public StoredBlock getChainHead()
+                         throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Returns the StoredBlock that represents the top of the chain of greatest total work. +

+

+
Specified by:
getChainHead in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+
+ +

+setChainHead

+
+public void setChainHead(StoredBlock chainHead)
+                  throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Sets the StoredBlock that represents the top of the chain of greatest total work. +

+

+
Specified by:
setChainHead in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/google/bitcoin/core/MemoryBlockStore.html b/docs/com/google/bitcoin/core/MemoryBlockStore.html new file mode 100644 index 00000000..a046ec0a --- /dev/null +++ b/docs/com/google/bitcoin/core/MemoryBlockStore.html @@ -0,0 +1,346 @@ + + + + + +MemoryBlockStore + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.core +
+Class MemoryBlockStore

+
+java.lang.Object
+  extended by com.google.bitcoin.core.MemoryBlockStore
+
+
+
All Implemented Interfaces:
BlockStore
+
+
+
+
public class MemoryBlockStore
extends java.lang.Object
implements BlockStore
+ + +

+Keeps StoredBlocks in memory. Used primarily for unit testing. +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
MemoryBlockStore(NetworkParameters params) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StoredBlockget(byte[] hash) + +
+          Returns the StoredBlock given a hash.
+ StoredBlockgetChainHead() + +
+          Returns the StoredBlock that represents the top of the chain of greatest total work.
+ voidput(StoredBlock block) + +
+          Saves the given block header+extra data.
+ voidsetChainHead(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
+ +

+MemoryBlockStore

+
+public MemoryBlockStore(NetworkParameters params)
+
+
+ + + + + + + + +
+Method Detail
+ +

+put

+
+public void put(StoredBlock block)
+         throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Saves the given block header+extra data. The key isn't specified explicitly as it can be calculated from the + StoredBlock directly. Can throw if there is a problem with the underlying storage layer such as running out of + disk space. +

+

+
Specified by:
put in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+
+ +

+get

+
+public StoredBlock get(byte[] hash)
+                throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Returns the StoredBlock given a hash. The returned values block.getHash() method will be equal to the + parameter. If no such block is found, returns null. +

+

+
Specified by:
get in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+
+ +

+getChainHead

+
+public StoredBlock getChainHead()
+
+
Description copied from interface: BlockStore
+
Returns the StoredBlock that represents the top of the chain of greatest total work. +

+

+
Specified by:
getChainHead in interface BlockStore
+
+
+
+
+
+
+ +

+setChainHead

+
+public void setChainHead(StoredBlock chainHead)
+                  throws BlockStoreException
+
+
Description copied from interface: BlockStore
+
Sets the StoredBlock that represents the top of the chain of greatest total work. +

+

+
Specified by:
setChainHead in interface BlockStore
+
+
+ +
Throws: +
BlockStoreException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/google/bitcoin/core/Sha256Hash.html b/docs/com/google/bitcoin/core/Sha256Hash.html new file mode 100644 index 00000000..6d967726 --- /dev/null +++ b/docs/com/google/bitcoin/core/Sha256Hash.html @@ -0,0 +1,345 @@ + + + + + +Sha256Hash + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.core +
+Class Sha256Hash

+
+java.lang.Object
+  extended by com.google.bitcoin.core.Sha256Hash
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class Sha256Hash
extends java.lang.Object
implements java.io.Serializable
+ + +

+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. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + +
+Field Summary
+ byte[]hash + +
+           
+  + + + + + + + + + + +
+Constructor Summary
Sha256Hash(byte[] hash) + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ booleanequals(java.lang.Object other) + +
+          Returns true if the hashes are equal.
+ inthashCode() + +
+          Hash code of the byte array as calculated by Object.hashCode().
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+hash

+
+public byte[] hash
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Sha256Hash

+
+public Sha256Hash(byte[] hash)
+
+
+ + + + + + + + +
+Method Detail
+ +

+equals

+
+public boolean equals(java.lang.Object other)
+
+
Returns true if the hashes are equal. +

+

+
Overrides:
equals in class java.lang.Object
+
+
+
+
+
+
+ +

+hashCode

+
+public int hashCode()
+
+
Hash code of the byte array as calculated by 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. +

+

+
Overrides:
hashCode in class java.lang.Object
+
+
+
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/google/bitcoin/core/StoredBlock.html b/docs/com/google/bitcoin/core/StoredBlock.html new file mode 100644 index 00000000..c9bd4bc7 --- /dev/null +++ b/docs/com/google/bitcoin/core/StoredBlock.html @@ -0,0 +1,466 @@ + + + + + +StoredBlock + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.core +
+Class StoredBlock

+
+java.lang.Object
+  extended by com.google.bitcoin.core.StoredBlock
+
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class StoredBlock
extends java.lang.Object
implements java.io.Serializable
+ + +

+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. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
StoredBlock(Block header, + java.math.BigInteger chainWork, + int height) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StoredBlockbuild(Block block) + +
+          Creates a new StoredBlock, calculating the additional fields by adding to the values in this block.
+ booleanequals(java.lang.Object other) + +
+           
+ java.math.BigIntegergetChainWork() + +
+          The total sum of work done in this block, and all the blocks below it in the chain.
+ BlockgetHeader() + +
+          The block header this object wraps.
+ intgetHeight() + +
+          Position in the chain for this block.
+ StoredBlockgetPrev(BlockStore store) + +
+          Given a block store, looks up the previous block in this chain.
+ inthashCode() + +
+           
+ booleanmoreWorkThan(StoredBlock other) + +
+          Returns true if this objects chainWork is higher than the others.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+StoredBlock

+
+public StoredBlock(Block header,
+                   java.math.BigInteger chainWork,
+                   int height)
+
+
+ + + + + + + + +
+Method Detail
+ +

+getHeader

+
+public Block getHeader()
+
+
The block header this object wraps. The referenced block object must not have any transactions in it. +

+

+
+
+
+
+
+
+
+ +

+getChainWork

+
+public java.math.BigInteger getChainWork()
+
+
The total sum of work done in this block, and all the blocks below it in the chain. Work is a measure of how + many tries are needed to solve a block. If the target is set to cover 10% of the total hash value space, + then the work represented by a block is 10. +

+

+
+
+
+
+
+
+
+ +

+getHeight

+
+public int getHeight()
+
+
Position in the chain for this block. The genesis block has a height of zero. +

+

+
+
+
+
+
+
+
+ +

+moreWorkThan

+
+public boolean moreWorkThan(StoredBlock other)
+
+
Returns true if this objects chainWork is higher than the others. +

+

+
+
+
+
+
+
+
+ +

+equals

+
+public boolean equals(java.lang.Object other)
+
+
+
Overrides:
equals in class java.lang.Object
+
+
+
+
+
+
+ +

+hashCode

+
+public int hashCode()
+
+
+
Overrides:
hashCode in class java.lang.Object
+
+
+
+
+
+
+ +

+build

+
+public StoredBlock build(Block block)
+                  throws VerificationException
+
+
Creates a new StoredBlock, calculating the additional fields by adding to the values in this block. +

+

+
+
+
+ +
Throws: +
VerificationException
+
+
+
+ +

+getPrev

+
+public StoredBlock getPrev(BlockStore store)
+                    throws BlockStoreException
+
+
Given a block store, looks up the previous block in this chain. Convenience method for doing + store.get(this.getHeader().getPrevBlockHash()). +

+

+
+
+
+ +
Returns:
the previous block in the chain or null if it was not found in the store. +
Throws: +
BlockStoreException
+
+
+
+ +

+toString

+
+public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/docs/com/google/bitcoin/examples/DumpWallet.html b/docs/com/google/bitcoin/examples/DumpWallet.html new file mode 100644 index 00000000..83dab644 --- /dev/null +++ b/docs/com/google/bitcoin/examples/DumpWallet.html @@ -0,0 +1,255 @@ + + + + + +DumpWallet + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.google.bitcoin.examples +
+Class DumpWallet

+
+java.lang.Object
+  extended by com.google.bitcoin.examples.DumpWallet
+
+
+
+
public class DumpWallet
extends java.lang.Object
+ + +

+DumpWallet loads a serialized wallet and prints information about what it contains. +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
DumpWallet() + +
+           
+  + + + + + + + + + + + +
+Method Summary
+static voidmain(java.lang.String[] args) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+DumpWallet

+
+public DumpWallet()
+
+
+ + + + + + + + +
+Method Detail
+ +

+main

+
+public static void main(java.lang.String[] args)
+                 throws java.lang.Exception
+
+
+ +
Throws: +
java.lang.Exception
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + +