protected DHTUDPPacketHandler( DHTUDPPacketHandlerFactory _factory, int _network, PRUDPPacketHandler _packet_handler, DHTUDPRequestHandler _request_handler ) { factory = _factory; network = _network; packet_handler = _packet_handler; request_handler = _request_handler; bloom1 = BloomFilterFactory.createAddOnly( BLOOM_FILTER_SIZE ); bloom2 = BloomFilterFactory.createAddOnly( BLOOM_FILTER_SIZE ); stats = new DHTUDPPacketHandlerStats( packet_handler ); }
protected void resetPersistentlyDeleted() { FileUtil.deleteResilientConfigFile( PERSIST_DEL_FILE ); persist_del_bloom = BloomFilterFactory.createAddOnly( PD_BLOOM_INITIAL_SIZE ); }
protected void setKnownSeed( InetSocketAddress address ) { synchronized( registered_legacy_managers ){ if ( known_seeds == null ){ known_seeds = BloomFilterFactory.createAddOnly( 1024 ); } // can't include port as it will be a randomly allocated one in general. two people behind the // same NAT will have to connect to each other using LAN peer finder known_seeds.add( AddressUtils.getAddressBytes( address )); } }
protected boolean isPersistentlyDeleted( RelatedContent content ) { if ( persist_del_bloom == null ){ List<byte[]> entries = loadPersistentlyDeleted(); persist_del_bloom = BloomFilterFactory.createAddOnly( Math.max( PD_BLOOM_INITIAL_SIZE, entries.size()*10 + PD_BLOOM_INCREMENT_SIZE )); for ( byte[] k: entries ){ persist_del_bloom.add( k ); } } byte[] key = getPermDelKey( content ); return( persist_del_bloom.contains( key )); }
protected void updateBloom( InetSocketAddress destination_address ) { // allow unresolved through (e.g. ipv6 dht seed) as handled later if ( !destination_address.isUnresolved()){ long diff = SystemTime.getCurrentTime() - last_bloom_rotation_time; if( diff < 0 || diff > BLOOM_ROTATION_PERIOD ) { // System.out.println( "bloom rotate: entries = " + bloom1.getEntryCount() + "/" + bloom2.getEntryCount()); bloom1 = bloom2; bloom2 = BloomFilterFactory.createAddOnly( BLOOM_FILTER_SIZE ); last_bloom_rotation_time = SystemTime.getCurrentTime(); } byte[] address_bytes = destination_address.getAddress().getAddress(); bloom1.add( address_bytes ); bloom2.add( address_bytes ); } }
@Override public void sentTo( DHTTransportContact contact ) { BloomFilter filter = sent_to_bloom; if ( filter == null || filter.getEntryCount() > 100 ){ filter = BloomFilterFactory.createAddOnly(500); sent_to_bloom = filter; } filter.add( contact.getID()); } }
all_desired_bits = Math.min( all_desired_bits, KEY_BLOOM_MAX_BITS ); BloomFilter all_bloom = BloomFilterFactory.createAddOnly( all_desired_bits ); non_dht_desired_bits = Math.min( non_dht_desired_bits, KEY_BLOOM_MAX_BITS ); BloomFilter non_dht_bloom = BloomFilterFactory.createAddOnly( non_dht_desired_bits );
protected void addPersistentlyDeleted( RelatedContent[] content ) { if ( content.length == 0 ){ return; } List<byte[]> entries = loadPersistentlyDeleted(); List<byte[]> new_keys = new ArrayList<>(content.length); for ( RelatedContent rc: content ){ byte[] key = getPermDelKey( rc ); new_keys.add( key ); entries.add( key ); } Map<String,Object> map = new HashMap<>(); map.put( "entries", entries ); FileUtil.writeResilientConfigFile( PERSIST_DEL_FILE, map ); if ( persist_del_bloom != null ){ if ( persist_del_bloom.getSize() / ( persist_del_bloom.getEntryCount() + content.length ) < 10 ){ persist_del_bloom = BloomFilterFactory.createAddOnly( Math.max( PD_BLOOM_INITIAL_SIZE, persist_del_bloom.getSize() *10 + PD_BLOOM_INCREMENT_SIZE + content.length )); for ( byte[] k: entries ){ persist_del_bloom.add( k ); } }else{ for ( byte[] k: new_keys ){ persist_del_bloom.add( k ); } } } }
protected void findContacts() { DHTTransportContact[] reachables = dht.getTransport().getReachableContacts(); for (int i=0;i<reachables.length;i++){ DHTTransportContact contact = reachables[i]; byte[] address = contact.getAddress().getAddress().getAddress(); if ( tried_bloom == null || tried_bloom.getEntryCount() > 500 ){ tried_bloom = BloomFilterFactory.createAddOnly( 4096 ); } if ( !tried_bloom.contains( address )){ tried_bloom.add( address ); synchronized( pending_contacts ){ potentialPing ping = new potentialPing( contact, DHTNetworkPositionManager.estimateRTT( contact.getNetworkPositions(), dht.getTransport().getLocalContact().getNetworkPositions())); pending_contacts.add( 0, ping ); if ( pending_contacts.size() > 60 ){ pending_contacts.removeLast(); } } } } }
negative_result_bloom = BloomFilterFactory.createAddOnly( BLOOM_SIZE );
BloomFilterFactory.createAddOnly(BLOOMFILTER_SIZE), 2); BloomFilterFactory.createAddOnly(BLOOMFILTER_PEERID_SIZE), 2);
filter_two = BloomFilterFactory.createAddOnly( BLOOM_FILTER_SIZE ); last_rotation_time = now;
bad_ip_bloom_filter = BloomFilterFactory.createAddOnly( BAD_IP_BLOOM_FILTER_SIZE ); bad_ip_bloom_filter = BloomFilterFactory.createAddOnly( BAD_IP_BLOOM_FILTER_SIZE );
ygm_unauth_bloom = BloomFilterFactory.createAddOnly(512);
lastAdd = 0; bloomFilter = BloomFilterFactory.createRotating( BloomFilterFactory.createAddOnly(BLOOMFILTER_SIZE), 2); bloomFilterPeerId = BloomFilterFactory.createRotating( BloomFilterFactory.createAddOnly(BLOOMFILTER_PEERID_SIZE), 2); overall = new ClientStatsOverall(); mapData.clear();
filter = BloomFilterFactory.createAddOnly(4000);
filter = prefer_udp_bloom = BloomFilterFactory.createAddOnly( PREFER_UDP_BLOOM_SIZE );
ip_bloom_filter = BloomFilterFactory.createAddOnly( ( LOCAL_DIVERSIFICATION_READS_PER_MIN * LOCAL_DIVERSIFICATION_READS_PER_MIN_SAMPLES *10 ) / 3 );
BloomFilterFactory.createAddOnly(10*1024), 2 );