anchor.diff:  
   
   -record(state, {
  -    endgame  :: etorrent_endgame:originhandle(),
       receiver :: pid(),
       table :: ets:tid()}).
   
  
positive.code: code_change(_, State, _) ->
      {ok, State}.
  
  
  notify(Receiver, Piece, Offset, Length) ->
      Receiver ! {dropped, Piece, Offset, Length},
      ok.
  
  notify(Receiver, Chunks) ->
      [notify(Receiver, I, O, L) || {I, O, L} <- Chunks],
      ok.
  
  delete_request(Table, Pid, Piece, Offset, Length) ->
      case ets:member(Table, Pid) of
          false -> ok;
          true  -> ets:delete(Table, {Pid, Piece, Offset, Length})
      end.
  
  insert_request(Table, Pid, Piece, Offset, Length) ->
      case ets:member(Table, Pid) of
          false -> false;
          true -> ets:insert(Table, {{Pid, Piece, Offset, Length}})
      end.
  
  flush_requests(Table, Pid) ->
      Match = {{Pid, '_', '_', '_'}},
      Rows  = ets:match_object(Table, Match),
      true  = ets:match_delete(Table, Match),
      [{I, O, L} || {_, I, O, L} <- Rows].
      
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  
negative.code: -module(etorrent_pending).
  -behaviour(gen_server).
  %% This module implements a server process tracking which open
  %% requests have been assigned to each peer process. The process
  %% assigning the requests to peers are responsible for keeping
  %% the request tracking process updated.
  %%
  %% #Peers
  %% Peer processes are responsible for notifying both the request
  %% tracking process and the process that assigned the request
  %% when a request is dropped, fetched or stored.
  %%
  %% When a peer exits the request tracking process must notify the
  %% process that is responsible for assigning requests that the
  %% request has been dropped.
  %%
  %% #Changing assigning process
  %% When endgame mode is activated the assigning process is replaced
  %% with the endgame process. The currently open requests are then sent
  %% to the endgame process. Any requests that have been sent to but
  %% not received by the assigning process is expected to be forwarded
  %% to the endgame process by the previous assigning process.
  
  %% exported functions
  -export([start_link/1,
           receiver/2]).
  
  %% gproc registry entries
  -export([register_server/1,
  