anchor.diff:      end.
   
   % @doc Return the node that owns the given index.
  -% @spec index_owner(State :: hstate(), Idx :: integer()) -> Node :: term()
  +% @spec index_owner(State :: chstate(), Idx :: integer()) -> Node :: term()
   index_owner(State, Idx) ->
       hd([Owner || {I, Owner} <- ?MODULE:all_owners(State), I =:= Idx]).
   
  -% @doc Return the node that is responsible for a given hstate.
  -% owner_node(State :: hstate()) -> Node :: term()
  +% @doc Return the node that is responsible for a given chstate.
  +% owner_node(State :: chstate()) -> Node :: term()
   owner_node(State) ->
  -    State#hstate.nodename.
  +    State#chstate.nodename.
   
   % @doc Produce a list of all nodes that own any partitions.
  -% @spec all_members(State :: hstate()) -> [Node :: term()]
  +% @spec all_members(State :: chstate()) -> [Node :: term()]
   all_members(State) ->
  -    chash:members(State#hstate.ring).
  +    chash:members(State#chstate.chring).
   
   % @doc Return a randomly-chosen node from amongst the owners.
  -% @spec random_node(State :: hstate()) -> Node :: term()
  +% @spec random_node(State :: chstate()) -> Node :: term()
   random_node(State) ->
       L = lists:usort(all_members(State)),
       lists:nth(crypto:rand_uniform(1, length(L)+1), L).
   
   % @doc Provide all ownership information in the form of {Index,Node} pairs.
  -% @spec all_owners(State :: hstate()) -> [{Index :: integer(), Node :: term()}]
  +% @spec all_owners(State :: chstate()) -> [{Index :: integer(), Node :: term()}]
   all_owners(State) ->
  -    chash:nodes(State#hstate.ring).
  +    chash:nodes(State#chstate.chring).
   
   % @doc For two rings, return the list of owners that have differing ownership.
   % @spec diff_nodes(State1,State2) -> [node()]
  
positive.code: 
  % @doc riak_ring manages a riak node's local view of partition
  %      ownership.  The functions in this module revolve around use
  %      of the hstate record, which should be treated as opaque by
  %      other modules.  Riak nodes exchange instances of
  %      these records via gossip in order to converge on a common
  %      view of node/partition ownership.
  
negative.code:     ?assertEqual({no_change,Ring1},reconcile(fresh(2,someone_else),Ring1)),
      RingB0 = fresh(2,node()),
      RingB1 = transfer_node(0,x,RingB0),
      RingB2 = RingB1#chstate{nodename=b},
      ?assertEqual({no_change,RingB2},reconcile(Ring1,RingB2)).
  
  metadata_inequality_test() ->
      Ring0 = fresh(2,node()),
      Ring1 = update_meta(key,val,Ring0),
      ?assertNot(equal_rings(Ring0,Ring1)),
      ?assertEqual(Ring1#chstate.meta,
                   merge_meta(Ring0#chstate.meta,Ring1#chstate.meta)),
      timer:sleep(1001), % ensure that lastmod is at least a second later
      Ring2 = update_meta(key,val2,Ring1),
      ?assertEqual(get_meta(key,Ring2),
                   get_meta(key,#chstate{meta=
                              merge_meta(Ring1#chstate.meta,
                                         Ring2#chstate.meta)})),
      ?assertEqual(get_meta(key,Ring2),
                   get_meta(key,#chstate{meta=
                              merge_meta(Ring2#chstate.meta,
                                         Ring1#chstate.meta)})).
  
  full_preflist_test() ->
      Ring0 = fresh(4,a),
  