anchor.diff:  
   -record(state, {
       torrent_id :: torrent_id(),
  -    num_pieces :: pos_integer(),
       num_peers  :: array(),
       peer_monitors :: monitorset()}).
   
   
  -%% @doc
  +%% @doc Register as the scarcity server for a torrent
   %% @end
   -spec register_scarcity_server(torrent_id()) -> true.
   register_scarcity_server(TorrentID) ->
       gproc:add_local_name({etorrent, TorrentID, scarcity}).
   
   
  -%% @doc
  +%% @doc Lookup the scarcity server for a torrent
   %% @end
   -spec lookup_scarcity_server(torrent_id()) -> pid().
   lookup_scarcity_server(TorrentID) ->
       gproc:lookup_local_name({etorrent, TorrentID, scarcity}).
   
   
  -%% @doc
  +%% @doc Wait for the scarcity server of a torrent to register
   %% @end
   -spec await_scarcity_server(torrent_id()) -> pid().
   await_scarcity_server(TorrentID) ->
  
positive.code:     ?assertEqual([1,2,3,4,5,6,7,0], Order).
  
  decrement_on_exit_case() ->
      {ok, _} = ?scarcity:start_link(6, 8),
      Main = self(),
      Pid = spawn_link(fun() ->
          ok = ?scarcity:add_peer(6, pieces([])),
          ok = ?scarcity:add_piece(6, 0, pieces([0])),
          ok = ?scarcity:add_piece(6, 2, pieces([0,2])),
          Main ! done,
          receive die -> ok end
  
negative.code: -module(etorrent_scarcity).
  -behaviour(gen_server).
  %% @author Magnus Klaar <magnus.klaar@sgsstudentbostader.se>
  %% @doc A server to track how many peers provide each piece
  %%
  %% The scarcity server associates a counter with each piece. When
  %% a peer comes online it registers it's prescence to the scarcity
  %% server. After the peer has registered it's precence it is responsible
  %% for keeping the scarcity server updated with additions to the
  %% set of pieces that it's providing, the peer is also expected to
  %% provide a copy of the updated piece set to the server.
  %%
  %% The server is expected to increment the counter and reprioritize
  %% the set of pieces of a torrent when the scarcity changes. When a
  %% peer exits the server is responsible for decrementing the counter
  %% for each piece that was provided by the peerl.
  %%
  %% The purpose of the server is not to provide a mapping between
  %% peers and pieces to other processes.
  %%
  %% ## notes on implementation
  %% A complete piece set is provided on each update in order to reduce
  %% the amount of effort spent on keeping the two sets synced. This also
  %% reduces memory usage for torrents with more than 512 pieces due to
  %% the way piece sets are implemented (2011-03-09).
  %% @end
  
  
  