anchor.diff:           await_scarcity_server/1]).
   
   %% api functions
  --export([start_link/2,
  +-export([start_link/1,
            add_peer/2,
            add_piece/3,
            get_order/2]).
  
positive.code: 
  %% @private
  handle_call({add_peer, PeerPid, Pieceset}, _, State) ->
      #state{num_pieces=NumPieces, peer_monitors=Monitors} = State,
      NewMonitors = etorrent_monitorset:insert(PeerPid, Pieceset, Monitors),
      NewState = State#state{peer_monitors=NewMonitors},
      {reply, ok, NewState};
  
  handle_call({add_piece, Pid, PieceIndex, Pieceset}, _, State) ->
  
negative.code: 
  -record(state, {
      torrent_id :: torrent_id(),
      num_peers  :: array(),
      peer_monitors :: monitorset()}).
  
  
  %% @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 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 Wait for the scarcity server of a torrent to register
  %% @end
  -spec await_scarcity_server(torrent_id()) -> pid().
  await_scarcity_server(TorrentID) ->
  