anchor.diff:          state_num = NewStateNum}.
   
   %%--------------------------------------------------------------------
  +%% @doc
  +%% Get node that can be used by new nodes to synchronize with
  +%% (i. e. attach to mnesia cluster). This node should be one of active
  +%% nodes of existing cluster, or if there isn't any, the first of nodes
  +%% that are initializing.
  +%%
  +%% In some cases synchronization requires waiting for this node to finish
  +%% initialization process. It is up to caller to wait and ensure that he can
  +%% safely synchronize.
  +%% @end
  +%%--------------------------------------------------------------------
  +-spec get_node_to_sync(#cm_state{}) -> {ok, node()} | {error, term()}.
  +get_node_to_sync(#cm_state{nodes = [], uninitialized_nodes = []}) ->
  +    {error, no_nodes_connected};
  +get_node_to_sync(#cm_state{nodes = [], uninitialized_nodes = [FirstInitNode | _]}) ->
  +    {ok, FirstInitNode};
  +get_node_to_sync(#cm_state{nodes = [FirstNode | _]}) ->
  +    {ok, FirstNode}.
  +
  +%%--------------------------------------------------------------------
   %% @private
   %% @doc
   %% Handles healthcheck request
  
positive.code:             ?info("New node: ~p", [SenderNode]),
              try
                  erlang:monitor_node(SenderNode, true),
                  NewInitNodes = [SenderNode | lists:delete(SenderNode, InitNodes)],
                  gen_server:cast({?NODE_MANAGER_NAME, SenderNode},
                      {heartbeat_ok, State#cm_state.state_num}),
                  State#cm_state{uninitialized_nodes = NewInitNodes}
  
negative.code: handle_call(get_nodes_and_state_num, _From, State) ->
      {reply, {State#cm_state.nodes, State#cm_state.state_num}, State};
  
  handle_call(get_node_to_sync, _From, State) ->
      Ans = get_node_to_sync(State),
      {reply, Ans, State};
  
  handle_call(healthcheck, _From, State) ->
      Ans = healthcheck(State),
      {reply, Ans, State};
  