anchor.diff:  is_invalidation_ongoing(#transfer{invalidation_status = scheduled}) -> true;
   is_invalidation_ongoing(#transfer{invalidation_status = active}) -> true.
   
  -%%-------------------------------------------------------------------
  -%% @doc
  -%% Predicate saying if given transfer is migrating a replica.
  -%% @end
  -%%-------------------------------------------------------------------
  --spec is_migrating(transfer()) -> boolean().
  -is_migrating(#transfer{invalidate_source_replica = Flag}) -> Flag.
   
   %%%===================================================================
   %%% Internal functions
  
positive.code:             transfer_controller:on_new_transfer_doc(TransferDoc),
              invalidation_controller:on_new_transfer_doc(TransferDoc),
              {ok, TransferId};
          Error ->
              ?error_stacktrace("Restarting transfer ~p failed due to ~p", [TransferId, Error]),
              Error
      end.
  
  %%-------------------------------------------------------------------
  
negative.code: -spec get_posthooks() -> [datastore_hooks:posthook()].
  get_posthooks() ->
      [fun maybe_mark_completed/3].
  
  %%-------------------------------------------------------------------
  %% @private
  %% @doc
  %% Moves given TransferId from past to current transfers links tree if
  %% the transfer is not ongoing.
  %% @end
  %%-------------------------------------------------------------------
  -spec maybe_move_from_past_to_current_links_tree(id(), transfer()) -> ok.
  maybe_move_from_past_to_current_links_tree(TransferId, T = #transfer{space_id = SpaceId}) ->
      case is_ongoing(T) of
          false ->
              ok = add_link(?CURRENT_TRANSFERS_KEY, TransferId, SpaceId),
              ok = delete_links(?PAST_TRANSFERS_KEY, TransferId, SpaceId);
          _ ->
              ok
      end.
  