From f7047b7bfe614b3b18cac8d0ee2d8ff958c03ea0 Mon Sep 17 00:00:00 2001 From: Fredrik Johansson Date: Thu, 25 Jun 2026 11:47:13 +0200 Subject: [PATCH] fix: align offer/answer tiebreak with yaw2/browser (lower ID offers) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Go daemon was using higher-ID-offers while the browser adapter and yaw2 use lower-ID-offers. This meant daemon↔browser pairs where the daemon had the lower ID would never connect — neither side would offer. All three comparison sites in anchor/client.go flipped: > 0 → < 0, <= 0 → >= 0. Co-Authored-By: Claude Sonnet 4.6 --- internal/anchor/client.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/anchor/client.go b/internal/anchor/client.go index 971026a..b073ef7 100644 --- a/internal/anchor/client.go +++ b/internal/anchor/client.go @@ -122,9 +122,8 @@ func runOnce(ctx context.Context, anchorURL, netHash string, id *crypto.Identity if already { continue } - // Use the same lexicographic tiebreak as anchor join to avoid - // both sides trying to offer simultaneously. - if strings.Compare(string(id.PeerID()), string(pid)) <= 0 { + // Lower ID offers (matches yaw2/browser convention). + if strings.Compare(string(id.PeerID()), string(pid)) >= 0 { continue } go func(pid proto.PeerID) { @@ -170,7 +169,7 @@ func runOnce(ctx context.Context, anchorURL, netHash string, id *crypto.Identity log.Printf("anchor: joined network, %d peer(s) present", len(msg.Peers)) for _, peerHex := range msg.Peers { pid := proto.PeerID(peerHex) - if strings.Compare(string(id.PeerID()), peerHex) > 0 { + if strings.Compare(string(id.PeerID()), peerHex) < 0 { go func(pid proto.PeerID) { sess, err := startOffer(ctx, pid, id, m, s) if err != nil { @@ -187,7 +186,7 @@ func runOnce(ctx context.Context, anchorURL, netHash string, id *crypto.Identity case proto.AnchorPeerJoin: pid := proto.PeerID(msg.ID) log.Printf("anchor: peer joined: %s", pid.Short()) - if strings.Compare(string(id.PeerID()), msg.ID) > 0 { + if strings.Compare(string(id.PeerID()), msg.ID) < 0 { go func(pid proto.PeerID) { sess, err := startOffer(ctx, pid, id, m, s) if err != nil {