Create MySQL store and refactored H2 & Postgres stores

1) Refactored PostgresFullPrunedBlockStore and H2FullPrunedBlockStore into a generic DatabaseFullPrunedBlockStore class.
2) H2FullPrunedBlockStore now supports calculateBalanceForAddress() method.
3) Created an additional store for MySQL (MySQLFullPrunedBlockStore) and unit test.
4) Fixed unit test PostgresFullPrunedBlockStoreTest, second time execution was failing due to not clearing down the tables correctly.
5) Added methods getOpenTransactionOutputs() & deleteStore() to base class DatabaseFullPrunedBlockStore.
I’ve updated the pull request, hopefully I’ve covered all your feedback :)

Thanks for taking the time to review.

I’m also trying to and get something through that will break backward compatibility (all depends which way it goes really) -so I’ll make a note of this.  If I get the go ahead to change I’ll remember to change this as well, in for a penny, in for a pound. Maybe I should say, in for a satoshi, in for a bitcoin :)

https://groups.google.com/forum/#!topic/bitcoinj/r2jiin9mTA4

K

On 30 Oct 2014, at 12:15, Andreas Schildbach <notifications@github.com> wrote:

> In core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java:
> 
> > +    /**
> > +     * Calculate the balance for a coinbase, to-address, or p2sh address.
> > +     *
> > +     * <p>This handles the case when the database query
> > +     * {@link org.bitcoinj.store.DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns the sum (balance) as a
> > +     * number (use calculateClientSide=false) or all the open output record/s 'value' as stored within the database in
> > +     * binary format (use calculateClientSide=true), i.e. So the balances is summed on the client side,
> > +     * within this method.</p>
> > +     *
> > +     * @param address The address to calculate the balance of
> > +     * @param calculateClientSide Flag to indicate if the DB returns the raw value/s or the actual balance (summed)
> > +     * @return The balance of the address supplied.  If the address has not been seen,
> > +     *         or there are no outputs open for this address, the return value is 0.
> > +     * @throws BlockStoreException If there is an error getting the balance.
> > +     */
> > +    protected BigInteger calculateBalanceForAddress(Address address, boolean calculateClientSide) throws BlockStoreException {
> Ok sorry, then lets keep it as it is.
> 
> —
> Reply to this email directly or view it on GitHub.
>