anchor.diff:  
   replicate_change(Source, Target, StartSeq, Metrics) ->
     {LastSeq, Changes} = changes(Source, StartSeq),
  -  Results = maps:get(<<"results">>, Changes),
     Results = maps:get(<<"results">>, Changes) ,
     {ok, Metrics2} = lists:foldl(fun(C, {ok, Acc}) ->
                              sync_change(Source, Target, C, Acc)
  
positive.code:   {ok, LastSeq, Metrics2}.
  
  sync_change(Source, Target, Change, Metrics) ->
    Id = maps:get(id, Change),
    History =  maps:get(changes, Change),
    {Doc, Metrics2} = read_doc(Source, Id, Metrics),
    Metrics3 = write_doc(Target, Id, Doc, History, Metrics2),
  
    {ok, Metrics3}.
  
  
  read_doc(Source, Id, Metrics) ->
    Get = fun() -> get(Source, Id, []) end,
    case timer:tc(Get) of
      {Time, {ok, Doc}} ->
        Metrics2 = barrel_metrics:inc(docs_read, Metrics, 1),
        Metrics3 = barrel_metrics:update_times(doc_read_times, Time, Metrics2),
        {Doc, Metrics3};
      _ ->
        lager:error("replicate read error on dbid=~p for docid=~p", [Source, Id]),
        Metrics2 = barrel_metrics:inc(doc_read_failures, Metrics, 1),
        {undefined, Metrics2}
      end.
  
  write_doc(_, _, undefined, _, Metrics) ->
    Metrics;
  
negative.code:   Mod:get(ModState, Id, Opts);
  get(Conn, Id, Opts) when is_map(Conn) ->
    barrel_db:get(Conn, Id, Opts).
  
  put_rev({Mod, ModState}, Id, Doc, History, Opts) ->
    Mod:put_rev(ModState, Id, Doc, History, Opts);
  