mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
Bloom filtering: add a convenience BloomFilter.insert(ECKey) method.
This commit is contained in:
parent
843e785daf
commit
8d83f4d25b
@ -228,6 +228,12 @@ public class BloomFilter extends Message {
|
||||
Utils.setBitLE(data, hash(i, object));
|
||||
}
|
||||
|
||||
/** Inserts the given key and equivalent hashed form (for the address). */
|
||||
public void insert(ECKey key) {
|
||||
insert(key.getPubKey());
|
||||
insert(key.getPubKeyHash());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this filter to match all objects. A Bloom filter which matches everything may seem pointless, however,
|
||||
* it is useful in order to reduce steady state bandwidth usage when you want full blocks. Instead of receiving
|
||||
|
@ -531,10 +531,8 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
lock.lock();
|
||||
try {
|
||||
BloomFilter filter = new BloomFilter(size, falsePositiveRate, tweak);
|
||||
for (ECKey key : hashToKeys.values()) {
|
||||
filter.insert(key.getPubKey());
|
||||
filter.insert(key.getPubKeyHash());
|
||||
}
|
||||
for (ECKey key : hashToKeys.values())
|
||||
filter.insert(key);
|
||||
return filter;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user