anchor.diff:  -include_lib("leo_object_storage/include/leo_object_storage.hrl").
   -include_lib("eunit/include/eunit.hrl").
   
  --export([replicate/4, loop/5]).
  +-export([replicate/4]).
   
   -type(error_msg_type() :: ?ERR_TYPE_REPLICATE_DATA  |
                             ?ERR_TYPE_DELETE_DATA).
  
positive.code:               true = rpc:cast(Node, leo_storage_handler_object, put, [From, Object, ReqId]);
           ({Node, false}) ->
                ok = enqueue(?ERR_TYPE_REPLICATE_DATA, AddrId, Key),
                erlang:send(Pid, {error, {Node, nodedown}})
        end, Nodes),
  
      loop(Callback).
  
  
  %% @doc Waiting for messages (replication)
  %%
  -spec(loop(integer(), function(), integer(), binary(),
             {integer(), string(), integer(), list()}) ->
               ok).
  loop(0, From,_AddrId,_Key, {_NumOfNodes,_ResL,_Errors}) ->
      erlang:send(From, {ok, hd(_ResL)});
  
  loop(W, From,_AddrId,_Key, { NumOfNodes,_ResL, Errors}) when (NumOfNodes - W) < length(Errors) ->
      erlang:send(From, {error, Errors});
  
  loop(W, From, AddrId, Key, { NumOfNodes, ResL, Errors}) ->
      receive
          {ok, Checksum} ->
              loop(W-1, From, AddrId, Key, {NumOfNodes, [Checksum|ResL], Errors});
          {error, {Node, Cause}} ->
              ok = enqueue(?ERR_TYPE_REPLICATE_DATA, AddrId, Key),
              loop(W,   From, AddrId, Key, {NumOfNodes, ResL, [{Node, Cause}|Errors]})
      after
          ?DEF_REQ_TIMEOUT ->
              case (W >= 0) of
                  true ->
                      erlang:send(From, {error, timeout});
                  false ->
                      void
              end
      end.
  
  %% @doc Waiting for messages (result)
  %% @private
  -spec(loop(function()) ->
               any()).
  loop(Callback) ->
      receive
          Res ->
              Callback(Res)
      after ?DEF_REQ_TIMEOUT ->
              Callback({error, timeout})
      end.
  
  
  
negative.code:     AddrId = Object#object.addr_id,
      Key    = Object#object.key,
      ReqId  = Object#object.req_id,
      From = self(),
  
      lists:foreach(
        fun({Node, true}) when Node == erlang:node() ->
                spawn(fun() ->
                              replicate_fun(local, #req_params{pid     = From,
                                                               addr_id = AddrId,
                                                               key     = Key,
                                                               object  = Object,
  