3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00

PeerFilterProvider methods are called with the lock already held, so just assert on that instead of locking again.

This commit is contained in:
Mike Hearn 2014-08-12 18:32:51 +02:00
parent f6b2fa5a2b
commit e888807dfd

View File

@ -3648,6 +3648,7 @@ 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()) {
@ -3674,6 +3675,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
*/
@Override
public boolean isRequiringUpdateAllBloomFilter() {
checkState(lock.isHeldByCurrentThread());
return !watchedScripts.isEmpty();
}
@ -3698,11 +3700,8 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
*/
@Override
public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) {
BloomFilter filter;
lock.lock();
try {
filter = keychain.getBloomFilter(size, falsePositiveRate, 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.
@ -3713,9 +3712,6 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
}
}
}
} finally {
lock.unlock();
}
for (Transaction tx : getTransactions(false)) {
for (int i = 0; i < tx.getOutputs().size(); i++) {
TransactionOutput out = tx.getOutputs().get(i);