anchor.diff:                  pending=Pending,
                   active=Active,
                   passive=Passive,
  +                reserved=Reserved,
  +                tag=Tag,
                   suspected=Suspected,
                   connections=Connections,
                   max_active_size=MaxActiveSize,
  
positive.code: -type passive() :: sets:set(node_spec()).
  -type pending() :: sets:set(node_spec()).
  -type suspected() :: sets:set(node_spec()).
  
  -record(state, {myself :: node_spec(),
                  active :: active(),
                  passive :: passive(),
                  pending :: pending(),
                  suspected :: suspected(),
                  connections :: connections(),
                  max_active_size :: non_neg_integer(),
  
negative.code: %% @private
  notify(#state{active=Active}) ->
      partisan_peer_service_events:update(Active).
  
  %% @private
  reserved_slot_available(Tag, Reserved) ->
      case dict:find(Tag, Reserved) of
          {ok, undefined} ->
              true;
          _ ->
              false
      end.
  
  %% @private
  handle_connect(Peer, Tag, #state{pending=Pending0,
                                   passive=Passive0,
                                   suspected=Suspected0}=State0) ->
      lager:info("Peer ~p connected.", [Peer]),
  
      %% When a node actually connects, perform the join steps.
      case is_pending(Peer, Pending0) of
          true ->
              %% Move out of pending.
              Pending = remove_from_pending(Peer, Pending0),
  
              %% If node is in the passive view, and we have a suspected
              %% node, that means it was contacted to be a potential node
              %% for replacement in the active view.
              %%
              case is_replacement_candidate(Peer, Passive0, Suspected0) of
                  true ->
                      %% Send neighbor request to peer asking it to
                      %% replace a suspected node.
                      %%
                      State = send_neighbor_request(Peer, State0#state{pending=Pending}),
  
                      %% Notify with event.
                      notify(State),
  
                      {noreply, State};
                  false ->
                      %% Normal join.
                      %%
                      State = perform_join(Peer,
                                           Tag,
                                           State0#state{pending=Pending}),
  
                      %% Notify with event.
                      notify(State),
  
                      {noreply, State}
              end;
          false ->
              {noreply, State0}
      end.
  