anchor.diff:              0
       end.
   
  -owner(Node, Seq, Epochs) ->
  -    owner(Node, Seq, Epochs, infinity).
  -
  -owner(_Node, _Seq, [], _HighSeq) ->
  -    false;
  -owner(Node, Seq, [{EpochNode, EpochSeq} | _Rest], HighSeq)
  -  when Node =:= EpochNode andalso Seq < HighSeq andalso Seq > EpochSeq ->
  -    true;
  -owner(Node, Seq, [{_EpochNode, EpochSeq} | Rest], _HighSeq) ->
  -    owner(Node, Seq, Rest, EpochSeq).
  +is_owner(Node, Seq, Epochs) ->
  +    Node =:= owner_of(Seq, Epochs).
  +
  +owner_of(_Seq, []) ->
  +    undefined;
  +owner_of(Seq, [{EpochNode, EpochSeq} | _Rest]) when Seq > EpochSeq ->
  +    EpochNode;
  +owner_of(Seq, [_ | Rest]) ->
  +    owner_of(Seq, Rest).
   
   -ifdef(TEST).
   -include_lib("eunit/include/eunit.hrl").
  
positive.code:     %% return integer if we didn't get a vector.
      ?assertEqual(4, calculate_start_seq(#db{}, 4)).
  
  owner_test() ->
      ?assertNot(owner(foo, 1, [])),
      ?assert(owner(foo, 1, [{foo, 1}])),
      ?assert(owner(foo, 50, [{bar, 100}, {foo, 1}])),
      ?assert(owner(foo, 50, [{baz, 200}, {bar, 100}, {foo, 1}])),
      ?assert(owner(bar, 150, [{baz, 200}, {bar, 100}, {foo, 1}])).
  
  -endif.
  
negative.code: calculate_start_seq(Db, {Seq, Uuid, Node}) ->
      case couch_db:get_uuid(Db) == Uuid of
          true ->
              case is_owner(Node, Seq, couch_db:get_epochs(Db)) of
                  true -> Seq;
                  false -> 0
              end;
  