anchor.diff:      Status /= Current orelse erlang:error(badarg),
       Peerstate#peerstate{interested=Status}.
   
  -
  +%% @doc Check if a piece is interesting
  +%% This function is intended to be called when a have-message is
  +%% received from a peer. If we are already interested or we are
  +%% a seeding the torrent this check is not necessary.
  +%% @end
   -spec interesting(pieceindex(), peerstate()) -> unchanged | true.
   interesting(Piece, Peerstate) ->
       #peerstate{interested=Status} = Peerstate,
  
positive.code:          interesting/3,
           seeder/1,
           seeder/2,
           pieces/1,
           requests/1,
           requests/2,
  
negative.code:     end.
  
  
  %% @doc Check if a set of pieces is still interesting
  %% This function is intended to be called when a have-message is sent
  %% to a peer. If we are not interested or if the peer did not provide
  %% the piece our interest remains unchanged. If there is no longer a
  %% difference between the peer's piece set and our piece set, return
  %% false.
  %% @end
  -spec interesting(pieceindex(), peerstate(), peerstate()) -> unchanged | false.
  interesting(Piece, RemoteState, LocalState) ->
      Status = etorrent_peerstate:interested(LocalState),
      case Status of
          false -> unchanged;
          true  ->
              Remote = etorrent_peerstate:pieces(RemoteState),
              case etorrent_pieceset:is_member(Piece, Remote) of
                  false -> unchanged;
                  true  ->
                      Local = etorrent_peerstate:pieces(LocalState),
                      Difference = etorrent_pieceset:difference(Remote, Local),
                      case etorrent_pieceset:is_empty(Difference) of
                          false -> unchanged;
                          true  -> false
                      end
              end
      end.
      
  
  
  -spec seeder(peerstate()) -> boolean().
  seeder(Peerstate) ->
      #peerstate{seeder=Seeder} = Peerstate,
      Seeder.
  
  -spec seeder(boolean(), peerstate()) -> peerstate().
  seeder(Status, Peerstate) ->
      #peerstate{seeder=Current} = Peerstate,
      Status orelse erlang:error(badarg),
      Peerstate#peerstate{seeder=Status}.
  
  -spec seeding(peerstate()) -> boolean().
  seeding(Peerstate) ->
      Pieces = pieces(Peerstate),
      etorrent_pieceset:is_full(Pieces).
  
  
  -spec requests(peerstate()) -> rqueue().
  requests(Peerstate) ->
  