anchor.diff:  %% @doc Generate the folding function
   %% for a riak fold_req
   -spec fold_fun(pid(), boolean()) -> fun().
  -fold_fun(Tree, _HasIndexTree = false) ->
  -    ObjectFoldFun = object_fold_fun(Tree),
  +fold_fun(HashtreePid, _HasIndexTree = false) ->
  +    ObjectFoldFun = object_fold_fun(HashtreePid),
       {Limit, Wait} = get_build_throttle(),
       fun(BKey, RObj, Acc) ->
               BinBKey = term_to_binary(BKey),
  
positive.code: %% before the fold reaches the now out-of-date version of the object, the old
  %% key/hash pair will be ignored.
  %% If `HasIndexTree` is true, also update the index spec tree.
  -spec fold_keys(index(), pid(), boolean()) -> ok.
  fold_keys(Partition, Tree, HasIndexTree) ->
      FoldFun = fold_fun(Tree, HasIndexTree),
      Req = riak_core_util:make_fold_req(FoldFun,
                                         0, false,
                                         [aae_reconstruction,
                                          {iterator_refresh, true}]),
      riak_core_vnode_master:sync_command({Partition, node()},
                                          Req,
                                          riak_kv_vnode_master, infinity),
      ok.
  
  get_build_throttle() ->
      app_helper:get_env(riak_kv,
  
negative.code: %% a fold/build. Otherwise, trigger a rehash to ensure the hashtrees match the
  %% current on-disk segments.
  -spec build_or_rehash(pid(), state()) -> ok.
  build_or_rehash(HashtreePid, State = #state{index =Index}) ->
      BuildOrRehash = determine_build_or_rehash(State),
      Locked = get_all_locks(BuildOrRehash, Index, self()),
      build_or_rehash(HashtreePid, Locked, BuildOrRehash, State).
  
  determine_build_or_rehash(State) ->
      case load_built(State) of
          false -> build;
          true -> rehash
      end.
  
  build_or_rehash(HashtreePid, true, build, #state{index =Index, trees =Trees}) ->
      lager:info("Starting AAE tree build: ~p", [Index]),
      fold_keys(Index, HashtreePid, Index, has_index_tree(Trees));
  build_or_rehash(HashtreePid, true, rehash, #state{index=Index, trees=Trees}) ->
      lager:debug("Starting AAE tree rehash: ~p", [Index]),
      _ = [hashtree:rehash_tree(T) || {_,T} <- Trees],
      lager:debug("Finished AAE tree rehash: ~p", [Index]),
      gen_server:cast(HashtreePid, build_finished);
  build_or_rehash(HashtreePid, false, _Type, _State) ->
      gen_server:cast(HashtreePid, build_failed).
  
  -spec maybe_rebuild(state()) -> state().
  maybe_rebuild(State=#state{lock=undefined, built=true, expired=true, index=Index}) ->
  