anchor.diff:      %% Establish connections.
       Connections = maybe_connect(Peer, Connections0),
   
  -    State = case neighbor_acceptable(Priority, PeerTag, State0) of
  -                true ->
  -                    case is_addable(DisconnectId, Peer, SentMessageMap0) of
  -                        true ->
  -                            LastDisconnectId = get_current_id(Peer, RecvMessageMap0),
  -                            %% Reply to acknowledge the neighbor was accepted.
  -                            do_send_message(
  -                                Peer,
  -                                {neighbor_accepted, Myself0, Tag0, LastDisconnectId},
  +    Exchange_Ack0 = %% Myself.
  +                    [Myself0] ++
  +
  +                    % Random members of the active list.
  +                    select_random_sublist(Active0, k_active()) ++
  +
  +                    %% Random members of the passive list.
  +                    select_random_sublist(Passive0, k_passive()),
  +
  +    Exchange_Ack = lists:usort(Exchange_Ack0),
  +
  +    State2 =
  +        case neighbor_acceptable(Priority, PeerTag, State0) of
  +            true ->
  +                case is_addable(DisconnectId, Peer, SentMessageMap0) of
  +                    true ->
  +                        LastDisconnectId = get_current_id(Peer, RecvMessageMap0),
  +                        %% Reply to acknowledge the neighbor was accepted.
  +                        do_send_message(
  +                            Peer,
  +                            {neighbor_accepted, Myself0, Tag0, LastDisconnectId, Exchange_Ack},
  +                            Connections),
  +
  +                        State1 = add_to_active_view(Peer, PeerTag, State0),
  +                        State1#state{connections=Connections};
  +                    false ->
  +                        %% Reply to acknowledge the neighbor was rejected.
  +                        do_send_message(Peer,
  +                                        {neighbor_rejected, Myself0, Exchange_Ack},
  +                                        Connections),
  +
  +                        State0#state{connections=Connections}
  +                end;
  +            false ->
  +                %% Reply to acknowledge the neighbor was rejected.
  +                do_send_message(Peer,
  +                                {neighbor_rejected, Myself0},
                                   Connections),
   
  -                            State1 = add_to_active_view(Peer, PeerTag, State0),
  -                            State1#state{connections=Connections};
  -                        false ->
  -                            %% Reply to acknowledge the neighbor was rejected.
  -                            do_send_message(Peer,
  -                                            {neighbor_rejected, Myself0},
  -                                            Connections),
  -
  -                            State0#state{connections=Connections}
  -                    end;
  -                false ->
  -                    %% Reply to acknowledge the neighbor was rejected.
  -                    do_send_message(Peer,
  -                                    {neighbor_rejected, Myself0},
  -                                    Connections),
  -
  -                    State0#state{connections=Connections}
  -            end,
  +                State0#state{connections=Connections}
  +        end,
  +
  +    State = merge_exchange(Exchange, State2),
   
       %% Notify with event.
       notify(State),
  
positive.code:     Exchange = lists:usort(Exchange0),
  
      %% Select random member of the active list.
      case select_random(Active, [Myself]) of
          undefined ->
              ok;
          Random ->
              %% Forward shuffle request.
              do_send_message(Random,
                              {shuffle, Exchange, arwl(), Myself},
                              Connections)
      end,
  
      %% Schedule periodic maintenance of the passive view.
      schedule_passive_view_maintenance(),
  
negative.code:         Random ->
              lager:info("Node ~p sends the NEIGHBOR_REQUEST to ~p", [Myself0, Random]),
  
              Exchange0 = %% Myself.
                          [Myself0] ++
  
                          % Random members of the active list.
                          select_random_sublist(Active0, k_active()) ++
  
                          %% Random members of the passive list.
                          select_random_sublist(Passive0, k_passive()),
  
              Exchange = lists:usort(Exchange0),
  
              %% Trigger connection.
              Connections = maybe_connect(Random, Connections0),
  
              LastDisconnectId = get_current_id(Random, RecvMessageMap0),
              do_send_message(
                  Random,
                  {neighbor_request, Myself0, high, Tag0, LastDisconnectId, Exchange},
                  Connections),
  
              State0#state{connections=Connections}
  