anchor.diff:                  opt_unchoke_chain = [] :: [pid()]}).
   
   -record(rechoke_info, {pid :: pid(),
  -                       peer_state :: 'seeding' | 'leeching', % Is the peer seeding or leeching
  -                       state :: 'seeding' | 'leeching' , % Are we seeding or leeching the torrent of the peer
  +                       %% Peers state:
  +                       peer_state :: 'seeding' | 'leeching',
  +                       %% Our state:
  +                       state :: 'seeding' | 'leeching' ,
                          peer_snubs :: boolean(),
                          r_interest_state :: 'interested' | 'not_interested',
                          r_choke_state :: 'choked' | 'unchoked' ,
  
positive.code: %% Otherwise, We have K excess slots we can move from S to D.
  shuffle_seeder_slots(S, D, SLen) ->
      case lists:max([0, S - SLen]) of
  	0 -> {S, D};
  	K -> {S - K, D + K}
      end.
  
  prune_preferred_peers(SDowns, SLeechs) ->
      MaxUploads = upload_slots(),
      DSlots = lists:max([1, round(MaxUploads * 0.7)]),
      SSlots = lists:max([1, round(MaxUploads * 0.3)]),
      {SSlots2, DSlots2} = shuffle_leecher_slots(SSlots, DSlots, length(SDowns)),
      {SSlots3, DSlots3} = shuffle_seeder_slots(SSlots2, DSlots2, length(SLeechs)),
      {TSDowns, TSLeechs} = {lists:sublist(SDowns, DSlots3),
                             lists:sublist(SLeechs, SSlots3)},
      sets:union(sets:from_list(TSDowns), sets:from_list(TSLeechs)).
  
negative.code: 
  split_preferred(Peers) ->
      {Downs, Leechs} = split_preferred_peers(Peers, [], []),
      %% Notice that the rate on which we sort is negative,
      %% so the fastest peer is actually first in the list
      {lists:keysort(#rechoke_info.rate, Downs),
       lists:keysort(#rechoke_info.rate, Leechs)}.
  
  