anchor.diff:      {ok, InitState}.
   
   
  +handle_call({register_peer, PeerPid}, _, State) ->
  +    %% Add a new peer to the set of monitored peers. Set the initial state
  +    %% of the monitored peer to an empty set open requests so that we don't
  +    %% need to check for this during the lifetime of the peer.
  +    #state{peer_monitors=PeerMonitors} = State,
  +    OpenReqs = gb_trees:empty(),
  +    NewMonitors = etorrent_monitorset:insert(PeerPid, OpenReqs, PeerMonitors),
  +    NewState = State#state{peer_monitors=NewMonitors},
  +    {reply, true, NewState};
  +
   handle_call({request_chunks, PeerPid, Peerset, Numchunks}, _, State) ->
       #state{
           pieces_valid=PiecesValid,
           pieces_chunked=PiecesChunked,
  -        piece_chunks=PieceChunks} = State,
  +        piece_chunks=PieceChunks,
  +        peer_monitors=Peers} = State,
       
       %% If this peer has no pieces that we are already downloading, begin
       %% downloading a new piece if this peer has any interesting pieces.
  
positive.code:     {ok, State}.
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  -define(chunk_server, ?MODULE).
  
  initial_chunk_server(ID) ->
      {ok, Pid} = ?chunk_server:start_link(ID, 1, [], [{0, 2}, {1, 2}, {2, 2}]),
      Pid.
  
  chunk_server_test_() ->
  
negative.code:         PieceIndex ->
              Chunkset    = array:get(PieceIndex, PieceChunks),
              {Offs, Len} = etorrent_chunkset:min(Chunkset),
              ?debugVal([Offs, Len, Chunkset]),
              NewChunkset = etorrent_chunkset:delete(Offs, Len, Chunkset),
              NewChunks   = array:set(PieceIndex, NewChunkset, PieceChunks),
              NewChunked  = etorrent_pieceset:insert(PieceIndex, PiecesChunked),
              %% Add the chunk to this peer's set of open requests
              OpenReqs = etorrent_monitorset:fetch(PeerPid, Peers),
              NewReqs  = gb_trees:insert({PieceIndex, Offs}, Len, OpenReqs),
              NewPeers = etorrent_monitorset:update(PeerPid, NewReqs, Peers),
  
              NewState = State#state{
                  pieces_chunked=NewChunked,
                  piece_chunks=NewChunks,
                  peer_monitors=NewPeers},
              {reply, {ok, [{PieceIndex, Offs, Len}]}, NewState}
      end;
  
  