protected void receive( DHTUDPPacketRequest request ) { if ( destroyed ){ return; } // incoming request if ( test_network_alive ){ request.setAddress( AddressUtils.adjustDHTAddress( request.getAddress(), false )); // an alien request is one that originates from a peer that we haven't recently // talked to byte[] bloom_key = request.getAddress().getAddress().getAddress(); boolean alien = !bloom1.contains( bloom_key ); if ( alien ){ // avoid counting consecutive requests from same contact more than once bloom1.add( bloom_key ); bloom2.add( bloom_key ); } stats.packetReceived( request.getSerialisedSize()); request_handler.process( request, alien ); } }
destination_address = AddressUtils.adjustDHTAddress( destination_address, true );
@Override public void send( DHTUDPPacketReply reply, InetSocketAddress destination_address ) throws DHTUDPPacketHandlerException { if ( destroyed ){ throw( new DHTUDPPacketHandlerException( "packet handler is destroyed" )); } destination_address = AddressUtils.adjustDHTAddress( destination_address, true ); // send reply to a request try{ reply.setNetwork( network ); // outgoing request if ( test_network_alive ){ packet_handler.send( reply, destination_address ); } }catch( PRUDPPacketHandlerException e ){ throw( new DHTUDPPacketHandlerException( e )); }finally{ stats.packetSent( reply.getSerialisedSize()); } }
public void send( DHTUDPPacketRequest request, InetSocketAddress destination_address ) throws DHTUDPPacketHandlerException { if ( destroyed ){ throw( new DHTUDPPacketHandlerException( "packet handler is destroyed" )); } destination_address = AddressUtils.adjustDHTAddress( destination_address, true ); updateBloom( destination_address ); // one way send (no matching reply expected ) try{ request.setNetwork( network ); if ( test_network_alive ){ packet_handler.send( request, destination_address ); } }catch( PRUDPPacketHandlerException e ){ throw( new DHTUDPPacketHandlerException( e )); }finally{ stats.packetSent( request.getSerialisedSize() ); } }