-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up client dial API. Add vat.NewClientHost.
- Loading branch information
Showing
4 changed files
with
35 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Package vatutil provides utilities for creating and configuring network vats. | ||
package vat | ||
|
||
import ( | ||
"github.com/libp2p/go-libp2p" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
libp2pquic "github.com/libp2p/go-libp2p-quic-transport" | ||
) | ||
|
||
// NewClientHost returns a libp2p.Host suitable for use in a Wetware | ||
// client vat. By default, the returned host uses the QUIC transport, | ||
// and does not accept incoming network connections. | ||
// | ||
// Callers can override these defaults by passing libp2p.Options. | ||
func NewClientHost(opt ...libp2p.Option) (host.Host, error) { | ||
return libp2p.New(withClientDefault(opt)...) | ||
} | ||
|
||
func withClientDefault(opt []libp2p.Option) []libp2p.Option { | ||
return append([]libp2p.Option{ | ||
libp2p.NoTransports, | ||
libp2p.NoListenAddrs, | ||
libp2p.Transport(libp2pquic.NewTransport), | ||
}, opt...) | ||
} |