anchor.diff:                      NodeID
               end
       end.
  -    
  +
  +%
  +% Refresh the contents of a bucket by issuing find_node queries to each node
  +% in the bucket until enough nodes that falls within the range of the bucket
  +% has been returned to replace the inactive nodes in the bucket.
  +%
  +refresh(Range, Inactive, Active) ->
  +    % Try to refresh the routing table using the inactive nodes first, 
  +    % If they turn out to be reachable the problem's solved.
  +    do_refresh(Range, Inactive ++ Active, []).
  +
  +do_refresh(_, [], _) ->
  +    ok; % TODO - perform a find_node_search here?
  +do_refresh(Range, [{ID, IP, Port}|T], IDs) ->
  +    Continue = case etorrent_dht_net:find_node(IP, Port, ID) of
  +        {error, timeout} ->
  +            true;
  +        {_, CloseNodes} ->
  +            do_refresh_inserts(Range, CloseNodes)
  +    end,
  +    case Continue of 
  +        false -> ok;
  +        true  -> do_refresh(Range, T, [ID|IDs])
  +    end.
  +
  +do_refresh_inserts({_, _}, []) ->
  +    true;
  +do_refresh_inserts({Min, Max}=Range, [{ID, IP, Port}|T])
  +when ?in_range(ID, Min, Max) ->
  +    case safe_insert_node(ID, IP, Port) of
  +        {error, timeout} ->
  +            do_refresh_inserts(Range, T);
  +        true ->
  +            do_refresh_inserts(Range, T);
  +        false ->
  +            safe_insert_nodes(T),
  +            false
  +    end;
  +
  +do_refresh_inserts(Range, [{ID, IP, Port}|T]) ->
  +    _ = safe_insert_node(ID, IP, Port),
  +    do_refresh_inserts(Range, T).
  +
  +spawn_refresh(Range, InputInactive, InputActive) ->
  +    Inactive = [{ensure_bin_id(ID), IP, Port}
  +               || {ID, IP, Port} <- InputInactive],
  +    Active   = [{ensure_bin_id(ID), IP, Port}
  +               || {ID, IP, Port} <- InputActive],
  +    spawn(?MODULE, refresh, [Range, Inactive, Active]).
   
   
   max_unreachable() ->
  
positive.code:     TmpNTimers = case Replace of
          none ->
              PrevNTimers;
          [{_, _, _}=DNode|_] ->
              del_timer(DNode, PrevNTimers)
      end,
  
  
negative.code:                              Now, BTimeout, LRecent, NTimeout, Range),
                  add_timer(Range, Now, BTimer, Acc)
              end, DelBTimers, NewRanges)
      end,
      NewState = State#state{
          buckets=NewBuckets,
          node_timers=NewNTimers,
          buck_timers=NewBTimers},
      {reply, ((not IsPrevMember) and IsNewMember), NewState};
              
  
  
  