anchor.diff:  -author('schintke@zib.de').
   -vsn('$Id:$ ').
   
  -%-define(TRACE(X,Y), io:format(X,Y)).
  +                                                %-define(TRACE(X,Y), io:format(X,Y)).
   -define(TRACE(X,Y), ok).
   -include("scalaris.hrl").
   -include("record_helpers.hrl").
  
positive.code:                        case Value of
                             no_value_yet -> {fail, not_found};
                             _ -> {ok, Value}
                             end
                        )
      end.
  
  -spec write(lease_id(), lease_entry()) -> api_tx:write_result().
  write(Key, Value) ->
      %% decide which lease db is responsible, ie. if the key is from
      %% the first quarter of the ring, use lease_db1, if from 2nd
      %% quarter -> use lease_db2, ...
  
negative.code:              io_lib:format("lease_db~p", ?RT:get_key_segment(Key, 4)))),
  
      rbrcseq:qwrite(DB, self(), Key,
                     ContentCheck,
                     Value),
      receive
          ?SCALARIS_RECV({qwrite_done, _ReqId, _Round, _Value}, {ok} ) %%;
          %%        ?SCALARIS_RECV({qwrite_deny, _ReqId, _Round, _Value}, {fail, timeout} )
          end.
  
  -spec write(lease_id(), lease_entry()) -> api_tx:write_result().
  write(Key, Value) ->
      write(Key, Value, fun l_on_cseq:is_valid_state_change/3).
  
  %% content checks
  -spec is_valid_state_change(any(), prbr:write_filter(), any()) ->
                                     {boolean(), null}.
  is_valid_state_change(rbr_bottom, _WriteFilter, NewLease) ->
      is_valid_creation(NewLease);
  is_valid_state_change(OldQRLease, WriteFilter, NewLease) ->
      Result =
          case OldQRLease#lease.aux of
              {aux, empty} ->
                  is_valid_renewal(OldQRLease, WriteFilter, NewLease)
                      orelse true; %% list further checks...
              %% {aux, {create, Parent}} ->
              %%     is_valid_create_step2(
              %%        andalso true,
  