anchor.diff:  %% # Priority of pieces
   %% The chunk server uses the scarcity server to keep an updated
   %% list of pieces, ordered by priority, for two subsets of the
  -%% pieces in a torrent.
  +%% pieces in a torrent. Every time these piece sets are update
  +%% these piece lists need to be updated.
   %%
   %% ## Begun
   %% The chunk server is biased towards choosing pieces that we are
  
positive.code:             %% Unassigned -> Assigned
              %% Begun -> Begun
              %% Begun -> Assigned
              %% The piece may have gone directly from Unassigned to Assigned.
              %% Check if it has been assigned before making any transitions.
              %% TODO - we want an is_empty function in etorrent_chunkset
              Wasassigned = etorrent_chunkset:size(NewChunkset) == 0,
              NewUnassigned = case Targetstate of
                  %% Begun -> Begun
                  begun ->
                      Unassigned;
                  %% Unassigned -> Begun|Assigned
                  unassigned ->
                      etorrent_pieceset:delete(Index, Unassigned)
              end,
  
              NewBegun = case Targetstate of
                  %% Begun -> Assigned
                  begun when Wasassigned ->
                      etorrent_pieceset:delete(Index, Begun);
                  %% Begun -> Begun
                  begun ->
                      Begun;
                  %% Unassigned -> Assigned
                  unassigned when Wasassigned ->
                      Begun;
                  %% Unassigned -> Begun
                  unassigned ->
                      etorrent_pieceset:insert(Index, Begun)
              end,
  
              NewAssigned = case Targetstate of
                  %% Unassigned|Begun -> Assigned
                  _ when Wasassigned ->
                      etorrent_pieceset:insert(Index, Assigned);
                  %% Begun -> Begun
                  begun ->
                      Assigned;
                  %% Unassigned -> Begun
                  unassigned ->
                      Assigned
              end,
              %% TODO - update order watches if Unassigned or Begun changed
              NewState = State#state{
                  pieces_unassigned=NewUnassigned,
                  pieces_begun=NewBegun,
  
negative.code: 
  handle_call({request_chunks, PeerPid, Peerset, Numchunks}, _, State) ->
      #state{
          torrent_id=TorrentID,
          pieces_valid=Valid,
          pieces_unassigned=Unassigned,
          pieces_begun=Begun,
          pieces_assigned=Assigned,
          chunks_assigned=AssignedChunks,
          peer_monitors=Peers,
          prio_unassigned=PrioUnassigned,
          prio_begun=PrioBegun} = State,
  
      %% If this peer has any pieces that we have begun downloading, pick
      %% one of those pieces over any unassigned pieces.
  