Skip to content

Commit

Permalink
rhp4: add UpgradeConn helper
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Oct 21, 2024
1 parent da3e94e commit 5a9fa81
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rhp/v4/siamux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func DialSiaMux(ctx context.Context, addr string, peerKey types.PublicKey) (Tran
return nil, fmt.Errorf("failed to connect to %q: %w", addr, err)
}

return UpgradeConn(ctx, conn, peerKey)
}

// UpgradeConn upgrades an existing connection to use the SiaMux multiplexer.
func UpgradeConn(ctx context.Context, conn net.Conn, peerKey types.PublicKey) (TransportClient, error) {
m, err := mux.Dial(conn, peerKey[:])
if err != nil {
return nil, fmt.Errorf("failed to establish siamux connection: %w", err)
Expand Down

0 comments on commit 5a9fa81

Please sign in to comment.