From e1f270f72627a0e6c3728fc1cf285579026fbae1 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 13 Aug 2014 14:47:15 +0200 Subject: [PATCH] Revert "PeerFilterProvider methods are called with the lock already held, so just assert on that instead of locking again." This reverts commit e888807dfd233f3500755a7aeb1f263c9ae65e4b. --- .../java/com/google/bitcoin/core/Wallet.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index b36bd649..c9ac410d 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -3648,7 +3648,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public int getBloomFilterElementCount() { - checkState(lock.isHeldByCurrentThread()); int size = keychain.getBloomFilterElementCount(); for (Transaction tx : getTransactions(false)) { for (TransactionOutput out : tx.getOutputs()) { @@ -3675,7 +3674,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public boolean isRequiringUpdateAllBloomFilter() { - checkState(lock.isHeldByCurrentThread()); return !watchedScripts.isEmpty(); } @@ -3700,17 +3698,23 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha */ @Override public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) { - checkState(lock.isHeldByCurrentThread()); - BloomFilter filter = keychain.getBloomFilter(size, falsePositiveRate, nTweak); - for (Script script : watchedScripts) { - for (ScriptChunk chunk : script.getChunks()) { - // Only add long (at least 64 bit) data to the bloom filter. - // If any long constants become popular in scripts, we will need logic - // here to exclude them. - if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) { - filter.insert(chunk.data); + BloomFilter filter; + lock.lock(); + try { + filter = keychain.getBloomFilter(size, falsePositiveRate, nTweak); + + for (Script script : watchedScripts) { + for (ScriptChunk chunk : script.getChunks()) { + // Only add long (at least 64 bit) data to the bloom filter. + // If any long constants become popular in scripts, we will need logic + // here to exclude them. + if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) { + filter.insert(chunk.data); + } } } + } finally { + lock.unlock(); } for (Transaction tx : getTransactions(false)) { for (int i = 0; i < tx.getOutputs().size(); i++) {