anchor.diff:  	       ip, port,
   	       downloaded, uploaded,
   	       left,
  -	       speed, last}).
  +	       upspeed, downspeed, last}).
   
   -define(RESPONSE_PEER_COUNT, 10).
   
  
positive.code: 		    not_found -> not_found;
  		    {ok, _} ->
  			mnesia:write_lock_table(peer),
  			Speed = case mnesia:read({peer, {HashId, PeerId}}) of
  				    [#peer{downloaded = DownloadedOld,
  					   last = LastOld}] ->
  					(DownloadedOld - Downloaded) / (LastOld - Now);
  				    [] ->
  					0
  				end,
  			%%io:format("New speed: ~p/s~n",[Speed]),
  			mnesia:write(#peer{hash_peer = {HashId, PeerId},
  					   ip = IP, port = Port,
  					   downloaded = Downloaded, uploaded = Uploaded,
  					   left = Left,
  					   speed = Speed, last = Now}),
  			ok
  		end
  	end,
  
      case mnesia:transaction(F) of
  	{atomic, ok} ->
  	    %% Assemble result
  	    AllPeers = dirty_hash_peers(HashId),
  		%%io:format("AllPeers: ~p~n", [AllPeers]),
  
negative.code:     Peers = dirty_hash_peers(HashId),
      {Seeders, Leechers, Speed} =
  	lists:foldl(fun(#peer{left = 0,
  			      upspeed = PeerUpspeed,
  			      downspeed = PeerDownspeed}, {S, L, Speed}) ->
  			    PeerSpeed = lists:max([PeerUpspeed, PeerDownspeed]),
  			    {S + 1, L, Speed + PeerSpeed};
  		       (#peer{left = PeerLeft,
  			      upspeed = PeerUpspeed,
  			      downspeed = PeerDownspeed}, {S, L, Speed}) when PeerLeft > 0 ->
  			    PeerSpeed = lists:max([PeerUpspeed, PeerDownspeed]),
  			    {S, L + 1, Speed + PeerSpeed}
  		    end, {0, 0, 0}, Peers),
      {Seeders, Leechers, Speed}.
  