Revert to normal NewNetwork create NewNetworkWithProtector

parent d9513595
......@@ -65,11 +65,11 @@ func TestFilterAddrs(t *testing.T) {
ps := pstore.NewPeerstore()
ctx := context.Background()
if _, err := NewNetwork(ctx, bad, id, ps, nil, metrics.NewBandwidthCounter()); err == nil {
if _, err := NewNetwork(ctx, bad, id, ps, metrics.NewBandwidthCounter()); err == nil {
t.Fatal("should have failed to create swarm")
}
if _, err := NewNetwork(ctx, goodAndBad, id, ps, nil, metrics.NewBandwidthCounter()); err != nil {
if _, err := NewNetwork(ctx, goodAndBad, id, ps, metrics.NewBandwidthCounter()); err != nil {
t.Fatal("should have succeeded in creating swarm", err)
}
}
......
......@@ -18,8 +18,14 @@ import (
// to implement inet.Network.
type Network Swarm
// NewNetwork constructs a new network and starts listening on given addresses.
func NewNetwork(ctx context.Context, listen []ma.Multiaddr, local peer.ID,
peers pstore.Peerstore, bwc metrics.Reporter) (*Network, error) {
return NewNetworkWithProtector(ctx, listen, local, peers, nil, bwc)
}
// NewNetwork constructs a new network and starts listening on given addresses.
func NewNetworkWithProtector(ctx context.Context, listen []ma.Multiaddr, local peer.ID,
peers pstore.Peerstore, protec ipnet.Protector, bwc metrics.Reporter) (*Network, error) {
s, err := NewSwarmWithProtector(ctx, listen, local, peers, protec, bwc)
......
......@@ -17,7 +17,7 @@ func GenSwarmNetwork(t *testing.T, ctx context.Context) *Network {
ps := pstore.NewPeerstore()
ps.AddPubKey(p.ID, p.PubKey)
ps.AddPrivKey(p.ID, p.PrivKey)
n, err := NewNetwork(ctx, []ma.Multiaddr{p.Addr}, p.ID, ps, nil, nil)
n, err := NewNetwork(ctx, []ma.Multiaddr{p.Addr}, p.ID, ps, nil)
if err != nil {
t.Fatal(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment