anchor.diff:  
   -define(RPCS(Tree), {rpcs, Tree}).
   -define(REPLAY(Tree), {replay, Tree}).
  +-define(DEDUP(Tree), {dedup, Tree}).
   
   -type(rpcs() :: ?RPCS(gb_tree())).
   -type(replay() :: ?REPLAY(gb_tree())).
  +
  +-define(SETS, sets).
  +-type(dedup() :: ?DEDUP(set())).
   
   -record(state, {
             connect_args = undefined :: {
  
positive.code:           parse_fun :: erlmqtt_framing:parse(),
            rpcs = empty_rpcs() :: rpcs(),
            replay = empty_replay() :: replay(),
            id_counter = 1 :: pos_integer(),
            receiver :: pid(),
            receiver_monitor :: reference(),
  
negative.code: 
  opened({frame, pingresp}, S0) -> ?OPENED(S0);
  
  %% Receiving publish: messages sent exactly_once must be
  %% deduplicated. I do this by keeping a set of message IDs that have
  %% already been seen, and removing when the #pubrel{} is sent.  Note
  %% that we only have to check for a duplicate if the message is marked
  %% as a duplicate and it's exactly_once -- there's no duty to check
  %% for duplicates of other messages (although it's possible to do so
  %% with a rolling window, say).
  
  opened({frame, Frame = #publish{}}, S0) ->
      #state{ dedup = Dedup, receiver = Receiver } = S0,
      case Frame of
          #publish{ dup = Dup,
                    qos = #qos{
                      message_id = Id,
                      level = exactly_once }} ->
              case Dup andalso is_duplicate(Id, Dedup) of
                  true ->
                      ?OPENED(S0);
                  false ->
                      S1 = do_ack(S0, Frame),
                      Dedup1 = record_for_dedup(Id, Dedup),
                      Receiver ! {frame, Frame},
                      ?OPENED(S1#state{ dedup = Dedup1 })
              end;
          _ ->
              S1 = do_ack(S0, Frame),
              Receiver ! {frame, Frame},
              ?OPENED(S1)
      end;
  
  %% This is step two of "exactly once" delivery (step one is publish),
  %% the first of two acknowledgments.
  