You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2025/04/30 14:57:16 UTC

(couchdb) 01/02: don't double hex-encode sigs

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch auto-delete-3
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d7f373c460789635e33871b54e74ab7f3ddbdaa8
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Apr 30 15:56:45 2025 +0100

    don't double hex-encode sigs
---
 src/couch_mrview/src/couch_mrview_index.erl | 4 ++--
 src/fabric/src/fabric_drop_seq.erl          | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index b7d08bddb..5ec895434 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -222,7 +222,7 @@ commit(State) ->
         State#mrst.db_name,
         <<"mrview">>,
         State#mrst.idx_name,
-        fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, State#mrst.sig),
+        fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, couch_util:to_hex_bin(State#mrst.sig)),
         State#mrst.update_seq
     ),
     ok.
@@ -315,7 +315,7 @@ ensure_peer_checkpoint_doc(#mrst{} = State) ->
         State#mrst.db_name,
         <<"mrview">>,
         State#mrst.idx_name,
-        fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, State#mrst.sig),
+        fabric_drop_seq:peer_id_from_sig(State#mrst.db_name, couch_util:to_hex_bin(State#mrst.sig)),
         State#mrst.update_seq
     ).
 
diff --git a/src/fabric/src/fabric_drop_seq.erl b/src/fabric/src/fabric_drop_seq.erl
index 773a98157..41a915d12 100644
--- a/src/fabric/src/fabric_drop_seq.erl
+++ b/src/fabric/src/fabric_drop_seq.erl
@@ -402,12 +402,11 @@ peer_checkpoint_doc(PeerId, Subtype, Source, UpdateSeq) when
 peer_checkpoint_id(Subtype, PeerId) ->
     <<?LOCAL_DOC_PREFIX, "peer-checkpoint-", Subtype/binary, "-", PeerId/binary>>.
 
-peer_id_from_sig(DbName, Sig0) ->
-    Sig1 = ?l2b(couch_util:to_hex(Sig0)),
+peer_id_from_sig(DbName, Sig) when is_binary(DbName), is_binary(Sig) ->
     Hash = couch_util:encodeBase64Url(
         crypto:hash(sha256, [atom_to_binary(node()), $0, DbName])
     ),
-    <<Sig1/binary, "$", Hash/binary>>.
+    <<Sig/binary, "$", Hash/binary>>.
 
 pack_seq(DbName, UpdateSeq) ->
     PrefixLen = fabric_util:get_uuid_prefix_len(),