Skip to content

Commit

Permalink
change the simultaneous open protocol to /libp2p/simultaneous-connect
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 1, 2021
1 parent 497f0e2 commit e0ad858
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func SelectOneOf(protos []string, rwc io.ReadWriteCloser) (string, error) {
return selectProtosOrFail(protos[1:], rwc)
}

const simOpenProtocol = "/libp2p/simultaneous-connect"

// Performs protocol negotiation with the simultaneous open extension; the returned boolean
// indicator will be true if we should act as a server.
func SelectWithSimopenOrFail(protos []string, rwc io.ReadWriteCloser) (string, bool, error) {
Expand All @@ -86,7 +88,7 @@ func SelectWithSimopenOrFail(protos []string, rwc io.ReadWriteCloser) (string, b
werrCh := make(chan error, 1)
go func() {
var buf bytes.Buffer
if err := delitmWriteAll(&buf, []byte(ProtocolID), []byte("iamclient"), []byte(protos[0])); err != nil {
if err := delitmWriteAll(&buf, []byte(ProtocolID), []byte(simOpenProtocol), []byte(protos[0])); err != nil {
werrCh <- err
return
}
Expand All @@ -110,19 +112,16 @@ func SelectWithSimopenOrFail(protos []string, rwc io.ReadWriteCloser) (string, b
}

switch tok {
case "iamclient":
case simOpenProtocol:
// simultaneous open
return simOpen(protos, rwc)

case "na":
// client open
proto, err := clientOpen(protos, rwc)
if err != nil {
return "", false, err
}

return proto, false, nil

default:
return "", false, errors.New("unexpected response: " + tok)
}
Expand Down

1 comment on commit e0ad858

@lovishpuri
Copy link

@lovishpuri lovishpuri commented on e0ad858 Apr 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marten-seemann Where is the handler for simOpenProtocol ? It seems like it has not been implemented.

Please sign in to comment.