anchor.diff:  %% =============================================================================
   
   
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
   new() ->
  -    state_orset:new().
  -
  -
  -add(#{name := _} = NodeSpec, Actor, T) ->
  -    state_orset:mutate({add, NodeSpec}, Actor, T).
  -
  -
  -remove(#{name := _} = NodeSpec, Actor, T) ->
  -    state_orset:mutate({rmv, NodeSpec}, Actor, T).
  -
  -
  +    state_awmap:new([state_mvregister]).
  +
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
  +add(#{name := Node} = NodeSpec, Actor, T) ->
  +    Ts = 0,
  +    state_awmap:mutate({apply, Node, {set, Ts, NodeSpec}}, Actor, T).
  +
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
  +remove(#{name := Node}, Actor, T) ->
  +    state_awmap:mutate({rmv, Node}, Actor, T).
  +
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
  +merge(T1, T2) ->
  +    state_awmap:merge(T1, T2).
  +
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
  +equal(T1, T2) ->
  +    state_awmap:equal(T1, T2).
  +
  +
  +%% -----------------------------------------------------------------------------
  +%% @doc
  +%% @end
  +%% -----------------------------------------------------------------------------
   to_list(T) ->
  -    sets:to_list(state_orset:query(T)).
  +    lists:append([sets:to_list(Values) || {_, Values} <- state_awmap:query(T)]).
   
   
   %% -----------------------------------------------------------------------------
  
positive.code:                          [B3, C]),
      ?assertEqual([], to_list(Merged)).
  
  %% A reset-remove bug eqc found where dropping a superseded dot lost
  %% field remove merge information the dropped dot contained, adding
  %% the tombstone fixed this.
  tombstone_remove_test() ->
      Name = 'node1@127.0.0.1',
      Node1 = node_spec(Name),
      Node2 = node_spec(Name, {192, 168, 0, 1}),
      Node3 = node_spec(Name, {192, 168, 0, 2}),
  
      A=B=new(),
      {ok, A1} = add(Node1, a, A),
  
      %% Replicate!
      B1 = merge(A1, B),
      ?assertEqual([Node1], to_list(B1)),
  
      {ok, A2} = remove(Node1, a, A1),
  
      {ok, B2} = add(Node2, b, B1),
  
      %% Replicate
      A3 = merge(A2, B2),
      %% that remove of nodenamme from A means remove
      %% the Node1 A added to nodename
      ?assertEqual([Node2], to_list(A3)),
  
      {ok, B3} = add(Node3, b, B2),
      %% replicate to A
      A4 = merge(A3, B3),
  
      ?assertEqual([Node3, Node2], to_list(A4)),
  
      %% final values
      Final = merge(A4, B3),
      %% before adding the tombstone, the dropped dots were simply
      %% merged with the surviving field. When the second update to B
      %% was merged with A, that information contained in the superseded
      %% field in A at {b,1} was lost (since it was merged into the
      %% _VALUE_). This casued the [0] from A's first dot to
      %% resurface. By adding the tombstone, the superseded field merges
      %% it's tombstone with the surviving {b, 2} field so the remove
      %% information is preserved, even though the {b, 1} value is
      %% dropped. Pro-tip, don't alter the CRDTs' values in the merge!
      ?assertEqual(
          [Node3, Node2],
          to_list(Final)
      ).
  
  %% This test is a regression test for a counter example found by eqc.
  %% The previous version of riak_dt_map used the `dot' from the field
  %% update/creation event as key in `merge_left/3'. Of course multiple
  %% fields can be added/updated at the same time. This means they get
  %% the same `dot'. When merging two replicas, it is possible that one
  %% has removed one or more of the fields added at a particular `dot',
  %% which meant a function clause error in `merge_left/3'. The
  %% structure was wrong, it didn't take into account the possibility
  %% that multiple fields could have the same `dot', when clearly, they
  %% can. This test fails with `dot' as the key for a field in
  %% `merge_left/3', but passes with the current structure, of
  %% `{nodename(), dot()}' as key.
  dot_key_test() ->
      Name1 = 'node1@127.0.0.1',
      Node1 = node_spec(Name1),
      Name2 = 'node2@127.0.0.1',
      Node2 = node_spec(Name2),
  
      {ok, A0} = add(Node1, a, new()),
      {ok, A1} = add(Node2, a, A0),
      B0 = A1,
      {ok, A2} = remove(Node1, a, A1),
      ?assertEqual([Node2], to_list(merge(B0, A2))).
  
  
  equals_test() ->
      Name1 = 'node1@127.0.0.1',
  
negative.code: -include_lib("eunit/include/eunit.hrl").
  -endif.
  
  -type t()   ::  state_awmap:state_awmap().
  
  %% API
  -export([add/3]).
  