@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (chain == null) return; final double rate = chain.getFalsePositiveRate(); final double target = bloomFilterMerger.getBloomFilterFPRate() * MAX_FP_RATE_INCREASE; if (rate > target) { // TODO: Avoid hitting this path if the remote peer didn't acknowledge applying a new filter yet. if (log.isDebugEnabled()) log.debug("Force update Bloom filter due to high false positive rate ({} vs {})", rate, target); recalculateFastCatchupAndFilter(FilterRecalculateMode.FORCE_SEND_FOR_REFRESH); } } }
/** * Tells the PeerGroup to download only block headers before a certain time and bodies after that. Call this * before starting block chain download. * Do not use a time > NOW - 1 block, as it will break some block download logic. */ public void setFastCatchupTimeSecs(long secondsSinceEpoch) { lock.lock(); try { checkState(chain == null || !chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying"); fastCatchupTimeSecs = secondsSinceEpoch; if (downloadPeer != null) { downloadPeer.setDownloadParameters(secondsSinceEpoch, bloomFilterMerger.getLastFilter() != null); } } finally { lock.unlock(); } }
/** * <p>Sets the false positive rate of bloom filters given to peers. The default is {@link #DEFAULT_BLOOM_FILTER_FP_RATE}.</p> * * <p>Be careful regenerating the bloom filter too often, as it decreases anonymity because remote nodes can * compare transactions against both the new and old filters to significantly decrease the false positive rate.</p> * * <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, BloomFilter.BloomUpdate)} for a brief * explanation of anonymity when using bloom filters.</p> */ public void setBloomFilterFalsePositiveRate(double bloomFilterFPRate) { lock.lock(); try { bloomFilterMerger.setBloomFilterFPRate(bloomFilterFPRate); recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); } finally { lock.unlock(); } }
return; FilterMerger.Result result = bloomFilterMerger.calculate(ImmutableList.copyOf(peerFilterProviders /* COW */)); boolean send; switch (mode) {
peerDiscoverers = new CopyOnWriteArraySet<PeerDiscovery>(); runningBroadcasts = Collections.synchronizedSet(new HashSet<TransactionBroadcast>()); bloomFilterMerger = new FilterMerger(DEFAULT_BLOOM_FILTER_FP_RATE); vMinRequiredProtocolVersion = params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER);
return; FilterMerger.Result result = bloomFilterMerger.calculate(ImmutableList.copyOf(peerFilterProviders /* COW */)); boolean send; switch (mode) {
peerDiscoverers = new CopyOnWriteArraySet<>(); runningBroadcasts = Collections.synchronizedSet(new HashSet<TransactionBroadcast>()); bloomFilterMerger = new FilterMerger(DEFAULT_BLOOM_FILTER_FP_RATE); vMinRequiredProtocolVersion = params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER);
/** * Tells the PeerGroup to download only block headers before a certain time and bodies after that. Call this * before starting block chain download. * Do not use a time > NOW - 1 block, as it will break some block download logic. */ public void setFastCatchupTimeSecs(long secondsSinceEpoch) { lock.lock(); try { checkState(chain == null || !chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying"); fastCatchupTimeSecs = secondsSinceEpoch; if (downloadPeer != null) { downloadPeer.setDownloadParameters(secondsSinceEpoch, bloomFilterMerger.getLastFilter() != null); } } finally { lock.unlock(); } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (chain == null) return; final double rate = chain.getFalsePositiveRate(); final double target = bloomFilterMerger.getBloomFilterFPRate() * MAX_FP_RATE_INCREASE; if (rate > target) { // TODO: Avoid hitting this path if the remote peer didn't acknowledge applying a new filter yet. if (log.isDebugEnabled()) log.debug("Force update Bloom filter due to high false positive rate ({} vs {})", rate, target); recalculateFastCatchupAndFilter(FilterRecalculateMode.FORCE_SEND_FOR_REFRESH); } } }
/** * <p>Sets the false positive rate of bloom filters given to peers. The default is {@link #DEFAULT_BLOOM_FILTER_FP_RATE}.</p> * * <p>Be careful regenerating the bloom filter too often, as it decreases anonymity because remote nodes can * compare transactions against both the new and old filters to significantly decrease the false positive rate.</p> * * <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, BloomFilter.BloomUpdate)} for a brief * explanation of anonymity when using bloom filters.</p> */ public void setBloomFilterFalsePositiveRate(double bloomFilterFPRate) { lock.lock(); try { bloomFilterMerger.setBloomFilterFPRate(bloomFilterFPRate); recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); } finally { lock.unlock(); } }
return; FilterMerger.Result result = bloomFilterMerger.calculate(ImmutableList.copyOf(peerFilterProviders /* COW */)); boolean send; switch (mode) {
peerDiscoverers = new CopyOnWriteArraySet<PeerDiscovery>(); runningBroadcasts = Collections.synchronizedSet(new HashSet<TransactionBroadcast>()); bloomFilterMerger = new FilterMerger(DEFAULT_BLOOM_FILTER_FP_RATE);
/** * Tells the PeerGroup to download only block headers before a certain time and bodies after that. Call this * before starting block chain download. * Do not use a time > NOW - 1 block, as it will break some block download logic. */ public void setFastCatchupTimeSecs(long secondsSinceEpoch) { lock.lock(); try { checkState(chain == null || !chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying"); fastCatchupTimeSecs = secondsSinceEpoch; if (downloadPeer != null) { downloadPeer.setDownloadParameters(secondsSinceEpoch, bloomFilterMerger.getLastFilter() != null); } } finally { lock.unlock(); } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (chain == null) return; final double rate = chain.getFalsePositiveRate(); final double target = bloomFilterMerger.getBloomFilterFPRate() * MAX_FP_RATE_INCREASE; if (rate > target) { // TODO: Avoid hitting this path if the remote peer didn't acknowledge applying a new filter yet. if (log.isDebugEnabled()) log.debug("Force update Bloom filter due to high false positive rate ({} vs {})", rate, target); recalculateFastCatchupAndFilter(FilterRecalculateMode.FORCE_SEND_FOR_REFRESH); } } }
/** * <p>Sets the false positive rate of bloom filters given to peers. The default is {@link #DEFAULT_BLOOM_FILTER_FP_RATE}.</p> * * <p>Be careful regenerating the bloom filter too often, as it decreases anonymity because remote nodes can * compare transactions against both the new and old filters to significantly decrease the false positive rate.</p> * * <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, BloomFilter.BloomUpdate)} for a brief * explanation of anonymity when using bloom filters.</p> */ public void setBloomFilterFalsePositiveRate(double bloomFilterFPRate) { lock.lock(); try { bloomFilterMerger.setBloomFilterFPRate(bloomFilterFPRate); recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); } finally { lock.unlock(); } }
return; FilterMerger.Result result = bloomFilterMerger.calculate(ImmutableList.copyOf(peerFilterProviders /* COW */)); boolean send; switch (mode) {
peerDiscoverers = new CopyOnWriteArraySet<>(); runningBroadcasts = Collections.synchronizedSet(new HashSet<TransactionBroadcast>()); bloomFilterMerger = new FilterMerger(DEFAULT_BLOOM_FILTER_FP_RATE); vMinRequiredProtocolVersion = params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.BLOOM_FILTER);
/** * Tells the PeerGroup to download only block headers before a certain time and bodies after that. Call this * before starting block chain download. * Do not use a time > NOW - 1 block, as it will break some block download logic. */ public void setFastCatchupTimeSecs(long secondsSinceEpoch) { lock.lock(); try { checkState(chain == null || !chain.shouldVerifyTransactions(), "Fast catchup is incompatible with fully verifying"); fastCatchupTimeSecs = secondsSinceEpoch; if (downloadPeer != null) { downloadPeer.setDownloadParameters(secondsSinceEpoch, bloomFilterMerger.getLastFilter() != null); } } finally { lock.unlock(); } }
@Override public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) { if (chain == null) return; final double rate = chain.getFalsePositiveRate(); final double target = bloomFilterMerger.getBloomFilterFPRate() * MAX_FP_RATE_INCREASE; if (rate > target) { // TODO: Avoid hitting this path if the remote peer didn't acknowledge applying a new filter yet. if (log.isDebugEnabled()) log.debug("Force update Bloom filter due to high false positive rate ({} vs {})", rate, target); recalculateFastCatchupAndFilter(FilterRecalculateMode.FORCE_SEND_FOR_REFRESH); } } }
/** * <p>Sets the false positive rate of bloom filters given to peers. The default is {@link #DEFAULT_BLOOM_FILTER_FP_RATE}.</p> * * <p>Be careful regenerating the bloom filter too often, as it decreases anonymity because remote nodes can * compare transactions against both the new and old filters to significantly decrease the false positive rate.</p> * * <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, BloomFilter.BloomUpdate)} for a brief * explanation of anonymity when using bloom filters.</p> */ public void setBloomFilterFalsePositiveRate(double bloomFilterFPRate) { lock.lock(); try { bloomFilterMerger.setBloomFilterFPRate(bloomFilterFPRate); recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); } finally { lock.unlock(); } }