anchor.diff:  
   %% @todo: What pid is the chunk recording pid? Control or SendPid?
   %% API
  --export([start_link/4,
  +-export([start_link/5,
            mark_valid/2,
            mark_fetched/4,
            mark_stored/4,
  
positive.code: %% Start a new chunk server for a set of pieces, a subset of the
  %% pieces may already have been fetched.
  %% @end
  start_link(TorrentID, ChunkSize, Fetched, Sizes) ->
      gen_server:start_link(?MODULE, [TorrentID, ChunkSize, Fetched, Sizes], []).
  
  %% @doc
  %% Mark a piece as completly stored to disk and validated.
  
negative.code:     %% can send a cancel-message to all of them.
      {reply, ok, State};
  
  handle_call({mark_stored, Pid, Index, Offset, Length}, _, State) ->
      %% The calling process has written this chunk to disk.
      %% Remove it from the list of open requests of the peer.
      #state{
          torrent_pid=TorrentPid,
          pieces_stored=Stored,
          peer_monitors=Peers,
          chunks_stored=ChunksStored} = State,
      OpenReqs = etorrent_monitorset:fetch(Pid, Peers),
      NewReqs  = gb_trees:delete({Index, Offset}, OpenReqs),
      NewPeers = etorrent_monitorset:update(Pid, NewReqs, Peers),
      %% Update the set of chunks in the piece that has been written to disk.
      Chunks = array:get(Index, ChunksStored),
      NewChunks = etorrent_chunkset:delete(Offset, Length, Chunks),
      NewChunksStored = array:set(Index, NewChunks, ChunksStored),
      %% Check if all chunks in this piece has been written to disk now.
      NewStored = case etorrent_chunkset:size(NewChunks) of
          0 ->
              ok = etorrent_t_control:piece_stored(TorrentPid, Index),
              etorrent_pieceset:insert(Index, Stored);
          _ ->
              Stored
      end,
      NewState = State#state{
          pieces_stored=NewStored,
          chunks_stored=NewChunksStored,
          peer_monitors=NewPeers},
      {reply, ok, NewState};
  
  
  