anchor.diff:  %% Internal functions
   %%====================================================================
   
  -
  +%%--------------------------------------------------------------------
  +%% Function: invariant_check(PList) -> ok | error
  +%% Description: Check that a list of chunks for a full piece obeys some
  +%%   invariants. This piece of code is there mostly as a debugging tool,
  +%%   but I (jlouis) keep it in to catch some bugs.
  +%%  TODO: This function needs some work to be correct. The data changed.
  +%%--------------------------------------------------------------------
   invariant_check(PList) ->
       V = lists:foldl(fun (_T, error) -> error;
   			({Offset, _Size, fetched, _D}, N) when Offset /= N ->
  
positive.code: 		    {ok, Return};
  		N when is_integer(N) ->
  		    Remaining = Num - N,
  		    {partial, Return, Remaining, PieceNum}
  	    end;
  	[_|_] ->
  	    %% More left, we got everything we wanted to get
  
negative.code:     end.
  
  %%--------------------------------------------------------------------
  %% Function: putback_chunks(Pid) -> transaction
  %% Description: Find all chunks assigned to Pid and mark them as not_fetched
  %%--------------------------------------------------------------------
  putback_chunks(Pid) ->
      MatchHead = #chunk { idt = {'_', '_', {assigned, Pid}}, _='_'},
  