public void recalculateFastCatchupAndFilter(FilterRecalculateMode mode){
  lock.lock();
  try {
    if (chain != null && chain.shouldVerifyTransactions())     return;
    log.info("Recalculating filter in mode {}",mode);
    long earliestKeyTimeSecs=Long.MAX_VALUE;
    int elements=0;
    boolean requiresUpdateAll=false;
    for (    PeerFilterProvider p : peerFilterProviders) {
      earliestKeyTimeSecs=Math.min(earliestKeyTimeSecs,p.getEarliestKeyCreationTime());
      elements+=p.getBloomFilterElementCount();
      requiresUpdateAll=requiresUpdateAll || p.isRequiringUpdateAllBloomFilter();
    }
    if (elements > 0) {
      lastBloomFilterElementCount=elements > lastBloomFilterElementCount ? elements + 100 : lastBloomFilterElementCount;
      BloomFilter.BloomUpdate bloomFlags=requiresUpdateAll ? BloomFilter.BloomUpdate.UPDATE_ALL : BloomFilter.BloomUpdate.UPDATE_P2PUBKEY_ONLY;
      BloomFilter filter=new BloomFilter(lastBloomFilterElementCount,bloomFilterFPRate,bloomFilterTweak,bloomFlags);
      for (      PeerFilterProvider p : peerFilterProviders)       filter.merge(p.getBloomFilter(lastBloomFilterElementCount,bloomFilterFPRate,bloomFilterTweak));
      boolean changed=!filter.equals(bloomFilter);
      boolean send=false;
      bloomFilter=filter;
switch (mode) {
case SEND_IF_CHANGED:
        send=changed;
      break;
case DONT_SEND:
    send=false;
  break;
case FORCE_SEND:
send=true;
break;
}
if (send) {
for (Peer peer : peers) peer.setBloomFilter(filter);
if (chain != null) chain.resetFalsePositiveEstimate();
}
}
earliestKeyTimeSecs-=86400 * 7;
setFastCatchupTimeSecs(earliestKeyTimeSecs);
}
  finally {
lock.unlock();
}
}

public void recalculateFastCatchupAndFilter ( FilterRecalculateMode mode ) { lock . lock ( ) ; try { if ( chain != null && chain . shouldVerifyTransactions ( ) ) return ; log . info ( "Recalculating filter in mode {}" , mode ) ; long earliestKeyTimeSecs = Long . MAX_VALUE ; int elements = 0 ; boolean requiresUpdateAll = false ; for ( PeerFilterProvider p : peerFilterProviders ) { earliestKeyTimeSecs = Math . min ( earliestKeyTimeSecs , p . getEarliestKeyCreationTime ( ) ) ; elements += p . getBloomFilterElementCount ( ) ; requiresUpdateAll = requiresUpdateAll || p . isRequiringUpdateAllBloomFilter ( ) ; } if ( elements > 0 ) { lastBloomFilterElementCount = elements > lastBloomFilterElementCount ? elements + 100 : lastBloomFilterElementCount ; BloomFilter . BloomUpdate bloomFlags = requiresUpdateAll ? BloomFilter . BloomUpdate . UPDATE_ALL : BloomFilter . BloomUpdate . UPDATE_P2PUBKEY_ONLY ; BloomFilter filter = new BloomFilter ( lastBloomFilterElementCount , bloomFilterFPRate , bloomFilterTweak , bloomFlags ) ; for ( PeerFilterProvider p : peerFilterProviders ) filter . merge ( p . getBloomFilter ( lastBloomFilterElementCount , bloomFilterFPRate , bloomFilterTweak ) ) ; boolean changed = ! filter . equals ( bloomFilter ) ; boolean send = false ; bloomFilter = filter ; switch ( mode ) { case SEND_IF_CHANGED : send = changed ; break ; case DONT_SEND : send = false ; break ; case FORCE_SEND : send = true ; break ; } if ( send ) { for ( Peer peer : peers ) peer . setBloomFilter ( filter ) ; if ( chain != null ) chain . resetFalsePositiveEstimate ( ) ; } } earliestKeyTimeSecs -= 86400 * 7 ; setFastCatchupTimeSecs ( earliestKeyTimeSecs ) ; } finally { lock . unlock ( ) ; } }
recalculates the bloom filter given to peers as well as the timestamp after which full blocks are downloaded ( instead of only headers ) .
