anchor.diff:  -behaviour(gen_server).
   
   %% API
  +%% Startup/init
   -export([start_link/0]).
  +
  +%% File Path map
   -export([get_path/2, insert_path/2, delete_paths/1]).
  +
  +%% Peer information
   -export([get_peer_info/1, new_peer/5, connected_peer/3,
   	 foreach_peer/2, statechange_peer/2]).
  +
  +%% Torrent information
   -export([all_torrents/0, statechange_torrent/2, get_torrent/1, acquire_check_token/1,
   	 new_torrent/3]).
   
  
positive.code:     true = ets:insert(tracking_map, TM),
      ok.
  
  % @doc Returns true if we are already connected to this peer.
  % @end
  -spec connected_peer(ip(), integer(), integer()) -> boolean().
  connected_peer(IP, Port, Id) when is_integer(Id) ->
      case ets:match(peers, #peer { ip = IP, port = Port, torrent_id = Id, _ = '_'}) of
  
negative.code: 	[PR] -> {peer_info, PR#peer.state, PR#peer.torrent_id}
      end.
  
  %% @doc Return all peer pids with a given torrentId
  %% @end
  %% @todo We can probably fetch this from the supervisor tree. There is
  %% less reason to have this then.
  -spec all_peer_pids(integer()) -> {value, [pid()]}.
  all_peer_pids(Id) ->
      R = ets:match(peers, #peer { torrent_id = Id, pid = '$1', _ = '_' }),
      {value, [Pid || [Pid] <- R]}.
  
  %% @doc Change the peer to a seeder
  %% @end
  -spec statechange_peer(pid(), seeder) -> ok.
  statechange_peer(Pid, seeder) ->
      [Peer] = ets:lookup(peers, Pid),
      true = ets:insert(peers, Peer#peer { state = seeding }),
      ok.
  
  %% @doc Insert a row for the peer
  %% @end
  -spec new_peer(ip(), integer(), integer(), pid(), seeding | leeching) -> ok.
  new_peer(IP, Port, TorrentId, Pid, State) ->
      true = ets:insert(peers, #peer { pid = Pid, ip = IP, port = Port,
  				     torrent_id = TorrentId, state = State}),
      add_monitor(peer, Pid).
  
  %% @doc Add a new torrent
  %% <p>The torrent is given by File with the Supervisor pid as given to the
  %% database structure.</p>
  %% @end
  -spec new_torrent(string(), pid(), integer()) -> ok.
  new_torrent(File, Supervisor, Id) when is_integer(Id), is_pid(Supervisor), is_list(File) ->
      add_monitor({torrent, Id}, Supervisor),
  