diff --git a/core/src/main/java/com/google/bitcoin/core/AbstractBlockChain.java b/core/src/main/java/com/google/bitcoin/core/AbstractBlockChain.java
index e0808fb57..5b00d49a8 100644
--- a/core/src/main/java/com/google/bitcoin/core/AbstractBlockChain.java
+++ b/core/src/main/java/com/google/bitcoin/core/AbstractBlockChain.java
@@ -408,7 +408,7 @@ public abstract class AbstractBlockChain {
i--; // Listener removed itself and it was not the last one.
break;
}
- listener.notifyNewBestBlock(newStoredBlock.getHeader());
+ listener.notifyNewBestBlock(newStoredBlock);
if (i == listeners.size()) {
break; // Listener removed itself and it was the last one.
} else if (listeners.get(i) != listener) {
diff --git a/core/src/main/java/com/google/bitcoin/core/AbstractBlockChainListener.java b/core/src/main/java/com/google/bitcoin/core/AbstractBlockChainListener.java
index 92f5264a4..f8a44fdda 100644
--- a/core/src/main/java/com/google/bitcoin/core/AbstractBlockChainListener.java
+++ b/core/src/main/java/com/google/bitcoin/core/AbstractBlockChainListener.java
@@ -22,7 +22,7 @@ import java.util.List;
* Default no-op implementation of {@link BlockChainListener}.
*/
public class AbstractBlockChainListener implements BlockChainListener {
- public void notifyNewBestBlock(Block block) throws VerificationException {
+ public void notifyNewBestBlock(StoredBlock block) throws VerificationException {
}
public void reorganize(StoredBlock splitPoint, List
Used to update confidence data in each transaction and last seen block hash. Triggers auto saving. * Invokes the onWalletChanged event listener if there were any affected transactions.
+ * @param block */ - public synchronized void notifyNewBestBlock(Block block) throws VerificationException { + public synchronized void notifyNewBestBlock(StoredBlock block) throws VerificationException { // Check to see if this block has been seen before. - Sha256Hash newBlockHash = block.getHash(); + Sha256Hash newBlockHash = block.getHeader().getHash(); if (newBlockHash.equals(getLastBlockSeenHash())) return; // Store the new block hash. @@ -1072,7 +1073,7 @@ public class Wallet implements Serializable, BlockChainListener { // notify the tx confidence of work done twice, it'd result in miscounting. ignoreNextNewBlock.remove(tx.getHash()); } else { - tx.getConfidence().notifyWorkDone(block); + tx.getConfidence().notifyWorkDone(block.getHeader()); } } queueAutoSave(); @@ -2207,7 +2208,7 @@ public class Wallet implements Serializable, BlockChainListener { } } } - notifyNewBestBlock(b.getHeader()); + notifyNewBestBlock(b); } // Find the transactions that didn't make it into the new chain yet. For each input, try to connect it to the @@ -2409,10 +2410,8 @@ public class Wallet implements Serializable, BlockChainListener { } /** - * Gets a bloom filter that contains all of the public keys from this wallet, - * and which will provide the given false-positive rate. - * - * See the docs for {@link BloomFilter#BloomFilter(int, double)} for a brief explanation of anonymity when using bloom filters. + * Gets a bloom filter that contains all of the public keys from this wallet, and which will provide the given + * false-positive rate. See the docs for {@link BloomFilter} for a brief explanation of anonymity when using filters. */ public BloomFilter getBloomFilter(double falsePositiveRate) { return getBloomFilter(getBloomFilterElementCount(), falsePositiveRate, (long)(Math.random()*Long.MAX_VALUE)); diff --git a/core/src/test/java/com/google/bitcoin/core/WalletTest.java b/core/src/test/java/com/google/bitcoin/core/WalletTest.java index 08ac5e520..a1f12d3f8 100644 --- a/core/src/test/java/com/google/bitcoin/core/WalletTest.java +++ b/core/src/test/java/com/google/bitcoin/core/WalletTest.java @@ -71,7 +71,7 @@ public class WalletTest { BlockPair bp = createFakeBlock(blockStore, tx); wallet.receiveFromBlock(tx, bp.storedBlock, type); if (type == AbstractBlockChain.NewBlockType.BEST_CHAIN) - wallet.notifyNewBestBlock(bp.block); + wallet.notifyNewBestBlock(bp.storedBlock); } return tx; } @@ -154,7 +154,7 @@ public class WalletTest { BlockPair bp = createFakeBlock(blockStore, t2, t3); wallet.receiveFromBlock(t2, bp.storedBlock, AbstractBlockChain.NewBlockType.BEST_CHAIN); wallet.receiveFromBlock(t3, bp.storedBlock, AbstractBlockChain.NewBlockType.BEST_CHAIN); - wallet.notifyNewBestBlock(bp.block); + wallet.notifyNewBestBlock(bp.storedBlock); assertTrue(wallet.isConsistent()); } @@ -308,9 +308,9 @@ public class WalletTest { wallet.commitTx(send2); sendMoneyToWallet(send2, AbstractBlockChain.NewBlockType.BEST_CHAIN); assertEquals(bitcoinValueToFriendlyString(wallet.getBalance()), "0.80"); - Block b4 = createFakeBlock(blockStore).block; + BlockPair b4 = createFakeBlock(blockStore); confTxns.clear(); - wallet.notifyNewBestBlock(b4); + wallet.notifyNewBestBlock(b4.storedBlock); assertEquals(3, confTxns.size()); }