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 {