anchor.diff:              dict:store(Type, [Resource], Dict)
       end.
   
  -resources_for_types(Types, Resources) ->
  +filter_remote_resources_by_target_types(Types, Resources) ->
       Fun =
           fun(Type, Acc) ->
               case dict:find(Type, Resources) of
                   {ok, List} ->
  -                    [{Type, Instance} || Instance <- List] ++ Acc;
  +                    [{Type, Resource} || Resource <- List] ++ Acc;
                   error ->
                       Acc
               end
  
positive.code: 
  init([]) ->
      {ok, #state{target_resource_types = [],
                  local_resources       = dict:new(),
                  resources             = dict:new()}}.
  
  handle_call({fetch_resources, Type}, _From, State) ->
      {reply, dict:find(Type, State#state.resources), State};
  handle_call(_Request, _From, State) ->
      Reply = ok,
      {reply, Reply, State}.
  
  handle_cast({add_target_resource_type, Type}, State) ->
      TargetTypes = State#state.target_resource_types,
      NewTargetTypes = [Type | lists:delete(Type, TargetTypes)],
      {noreply, State#state{target_resource_types = NewTargetTypes}};
  handle_cast({add_local_resource, {Type, Instance}}, State) ->
      LocalResources = State#state.local_resources,
      NewLocalResources = add_resource(Type, Instance, LocalResources),
      {noreply, State#state{local_resources = NewLocalResources}};
  handle_cast(trade_resources, State) ->
      LocalResources = State#state.local_resources,
      AllNodes = [node() | nodes()],
      lists:foreach(
          fun(Node) ->
              gen_server:cast({?SERVER, Node},
                              {trade_resources, {node(), LocalResources}})
          end,
          AllNodes),
      {noreply, State};
  handle_cast({trade_resources, {ReplyTo, RemoteResources}},
              #state{local_resources       = LocalResources,
                     target_resource_types = TargetTypes,
                     resources             = Resources} = State) ->
      ResourceList = resources_for_types(TargetTypes, RemoteResources),
      NewResources = add_resources(ResourceList, Resources),
      case ReplyTo of
          noreply ->
              ok;
          _ ->
              gen_server:cast({?SERVER, ReplyTo},
                              {trade_resources, {noreply, LocalResources}})
      end,
      {noreply, State#state{resources = NewResources}};
  handle_cast(_Msg, State) ->
      {noreply, State}.
  
  handle_info(_Info, State) ->
      {noreply, State}.
  
  terminate(_Reason, _State) ->
  
negative.code:          add_local_resource/2,
           fetch_resources/1,
           trade_resources/0
          ]).
  
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
           terminate/2, code_change/3]).
  