anchor.diff:  %% @doc
   %% Initialize chash ring
   %% @end
  -%%--------------------------------------------------------------------
  +%%------------------------------------------`--------------------------
   -spec init([node()]) -> ok.
   init([Node]) ->
       set_chash_ring(#ring{type = single_node, chash = Node});
  
positive.code: %%--------------------------------------------------------------------
  %% @doc
  %% Get nodes that are responsible for the data labeled with given term.
  %% @end
  %%--------------------------------------------------------------------
  -spec get_nodes(term(), non_neg_integer()) -> [node()].
  get_nodes(Label, NodesNum) ->
      case get_chash_ring() of
          undefined ->
              error(chash_ring_not_initialized);
          #ring{type = single_node, chash = Node} ->
              [Node];
          #ring{type = multi_node, chash = CHash} ->
              Index = chash:key_of(Label),
              lists:map(fun({_, Node}) -> Node end, chash:successors(Index, CHash, NodesNum));
          #ring{type = broken, chash = CHash, broken_nodes = BrokenNodes} ->
              Index = chash:key_of(Label),
              lists:map(fun({_, Node}) ->
                  case lists:member(Node, BrokenNodes) of
                      true -> throw(broken_node);
                      false -> Node
                  end
              end, chash:successors(Index, CHash, NodesNum))
      end.
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Get nodes that are responsible for the data labeled with given term.
  %% Returns two lists: alvie and broken nodes.
  %% @end
  %%--------------------------------------------------------------------
  -spec get_alive_and_broken_nodes(term(), non_neg_integer()) -> {AliveNodes :: [node()], BrokenNodes :: [node()]}.
  get_alive_and_broken_nodes(Label, NodesNum) ->
      case get_chash_ring() of
          undefined ->
              error(chash_ring_not_initialized);
          #ring{type = single_node, chash = Node} ->
              {[Node], []};
          #ring{type = multi_node, chash = CHash} ->
              Index = chash:key_of(Label),
              Nodes = lists:map(fun({_, Node}) -> Node end, chash:successors(Index, CHash, NodesNum)),
              {Nodes, []};
          #ring{type = broken, chash = CHash, broken_nodes = BrokenNodes} ->
              Index = chash:key_of(Label),
              Nodes = chash:successors(Index, CHash, NodesNum),
              filter_nodes(Nodes, BrokenNodes)
      end.
  
  %%--------------------------------------------------------------------
  
negative.code: -record(ring, {
      type :: single_node | multi_node | broken,
      chash :: chash:chash() | node(),
      broken_nodes = [] :: [node()],
      key_connected_nodes = 1 :: pos_integer()
  }).
  
  -type ring() :: #ring{}.
  
  %% API
  -export([init/1, cleanup/0, get_chash_ring/0, set_chash_ring/1,
      set_broken_node/1, set_fixed_node/1, set_key_connected_nodes/1,
      get_node/1, get_nodes/2, get_all_nodes/0]).
  
  %%%===================================================================
  %%% API
  