fix: align offer/answer tiebreak with yaw2/browser (lower ID offers)
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 <noreply@anthropic.com>
This commit is contained in:
@@ -122,9 +122,8 @@ func runOnce(ctx context.Context, anchorURL, netHash string, id *crypto.Identity
|
|||||||
if already {
|
if already {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Use the same lexicographic tiebreak as anchor join to avoid
|
// Lower ID offers (matches yaw2/browser convention).
|
||||||
// both sides trying to offer simultaneously.
|
if strings.Compare(string(id.PeerID()), string(pid)) >= 0 {
|
||||||
if strings.Compare(string(id.PeerID()), string(pid)) <= 0 {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go func(pid proto.PeerID) {
|
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))
|
log.Printf("anchor: joined network, %d peer(s) present", len(msg.Peers))
|
||||||
for _, peerHex := range msg.Peers {
|
for _, peerHex := range msg.Peers {
|
||||||
pid := proto.PeerID(peerHex)
|
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) {
|
go func(pid proto.PeerID) {
|
||||||
sess, err := startOffer(ctx, pid, id, m, s)
|
sess, err := startOffer(ctx, pid, id, m, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -187,7 +186,7 @@ func runOnce(ctx context.Context, anchorURL, netHash string, id *crypto.Identity
|
|||||||
case proto.AnchorPeerJoin:
|
case proto.AnchorPeerJoin:
|
||||||
pid := proto.PeerID(msg.ID)
|
pid := proto.PeerID(msg.ID)
|
||||||
log.Printf("anchor: peer joined: %s", pid.Short())
|
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) {
|
go func(pid proto.PeerID) {
|
||||||
sess, err := startOffer(ctx, pid, id, m, s)
|
sess, err := startOffer(ctx, pid, id, m, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user