anchor.diff:      {noreply, State}.
   
   
  -%%--------------------------------------------------------------------
  -%% Function: terminate(Reason, State) -> void()
  -%% Description: This function is called by a gen_server when it is about to
  -%% terminate. It should be the opposite of Module:init/1 and do any necessary
  -%% cleaning up. When it returns, the gen_server terminates with Reason.
  -%% The return value is ignored.
  -%%--------------------------------------------------------------------
   terminate(normal, _State) ->
       persist_to_disk(),
       ok;
   terminate(_Reason, _State) ->
       ok.
   
  -
  -%%--------------------------------------------------------------------
  -%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
  -%% Description: Convert process state when code is changed
  -%%--------------------------------------------------------------------
   code_change(_OldVsn, State, _Extra) ->
       {ok, State}.
  -
  -%%--------------------------------------------------------------------
  -%%% Internal functions
  -%%--------------------------------------------------------------------
  -
  -%%--------------------------------------------------------------------
  -%% Func: prune_disk_state(Tracking) -> ok
  -%% Description: Prune the persistent disk state for anything we are
  -%%   not tracking.
  -%%--------------------------------------------------------------------
  -
  -%%--------------------------------------------------------------------
  -%% Func: persist_disk_state(Tracking) -> ok
  -%% Description: Persist state on disk
  -%%--------------------------------------------------------------------
  -track_in_ets_table([]) -> ok;
  -track_in_ets_table([#tracking_map { id = Id,
  -                                    filename = FName} | Next]) ->
  -    {F, St} = case etorrent_torrent:state(Id) of
  -        not_found -> track_in_ets_table(Next); %% Not hot, skip it.
  -        {value, seeding}  -> {FName, seeding};
  -        {value, leeching} -> {FName, {bitfield, etorrent_piece_mgr:bitfield(Id)}};
  -        {value, endgame}  -> {FName, {bitfield, etorrent_piece_mgr:bitfield(Id)}};
  -        {value, unknown}  -> track_in_ets_table(Next) %% Skip, we know nothing yet
  -    end,
  -    true = ets:insert(etorrent_fast_resume, #piece_diskstate{filename = F,
  -                                                             state    = St}),
  -    track_in_ets_table(Next).
  -
  -persist_to_disk() ->
  -    {atomic, Torrents} = etorrent_tracking_map:all(),
  -    track_in_ets_table(Torrents),
  -    {ok, F} = application:get_env(etorrent, fast_resume_file),
  -    ok = ets:tab2file(etorrent_fast_resume, F, [{extended_info, [object_count, md5sum]}]),
  -    etorrent_event_mgr:persisted_state_to_disk(),
  -    ok.
  -
  -
  
positive.code: query_state(Id) ->
          gen_server:call(?SERVER, {query_state, Id}).
  
  %%====================================================================
  %% gen_server callbacks
  %%====================================================================
  
  %%--------------------------------------------------------------------
  %% Function: init(Args) -> {ok, State} |
  %%                         {ok, State, Timeout} |
  %%                         ignore               |
  %%                         {stop, Reason}
  %% Description: Initiates the server
  %%--------------------------------------------------------------------
  init([]) ->
      process_flag(trap_exit, true),
      {ok, F} = application:get_env(etorrent, fast_resume_file),
  
negative.code:     {ok, TRef} = timer:send_interval(?PERSIST_TIME, self(), persist),
      {ok, #state{ timer = TRef}}.
  
  handle_call({query_state, Id}, _From, S) ->
      {atomic, [TM]} = etorrent_tracking_map:select(Id),
      case ets:lookup(etorrent_fast_resume, TM#tracking_map.filename) of
          [] -> {reply, unknown, S};
          [{_, R}] -> {reply, R, S}
      end;
  handle_call(_Request, _From, State) ->
      Reply = ok,
      {reply, Reply, State}.
  
  handle_cast(_Msg, State) ->
      {noreply, State}.
  
  handle_info(persist, S) ->
      error_logger:info_report([persist_to_disk]),
      persist_to_disk(),
  