Skip to content
This repository was archived by the owner on Jan 3, 2022. It is now read-only.

Commit 839e30b

Browse files
authored
Merge pull request #31 from Jorropo/patch-1
Remove `IsFDCostlyTransport`
2 parents 60fd7d3 + a751143 commit 839e30b

File tree

2 files changed

+0
-73
lines changed

2 files changed

+0
-73
lines changed

filter.go

-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool {
1616
}
1717
}
1818

19-
// IsFDCostlyTransport returns true for transports that require a new file
20-
// descriptor per connection created
21-
func IsFDCostlyTransport(a ma.Multiaddr) bool {
22-
res := false
23-
24-
ma.ForEach(a, func(c ma.Component) bool {
25-
if c.Protocol().Code == ma.P_TCP {
26-
res = true
27-
return false
28-
}
29-
return true
30-
})
31-
return res
32-
}
33-
3419
// FilterNeg returns a negated version of the passed in filter
3520
func FilterNeg(f func(ma.Multiaddr) bool) func(ma.Multiaddr) bool {
3621
return func(a ma.Multiaddr) bool {

filter_test.go

-58
Original file line numberDiff line numberDiff line change
@@ -25,61 +25,3 @@ func TestSubtractAndNegFilter(t *testing.T) {
2525
t.Errorf("Expected only one remaining address: %s", localhost.String())
2626
}
2727
}
28-
29-
func TestIsFDCostlyTransport(t *testing.T) {
30-
tcpMa := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
31-
if ok := IsFDCostlyTransport(tcpMa); !ok {
32-
t.Errorf("Expected address %s to need a new file descriptor per new connection", tcpMa.String())
33-
}
34-
udpMa := newMultiaddr(t, "/ip4/127.0.0.1/udp/1234")
35-
if ok := IsFDCostlyTransport(udpMa); ok {
36-
t.Errorf("Expected address %s to not need a new file descriptor per new connection", udpMa.String())
37-
}
38-
}
39-
40-
func TestIsFDCostly(t *testing.T) {
41-
good := []ma.Multiaddr{
42-
newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234"),
43-
newMultiaddr(t, "/ip4/0.0.0.0/tcp/1234"),
44-
newMultiaddr(t, "/ip6/::1/tcp/1234"),
45-
newMultiaddr(t, "/ip6/::/tcp/1234"),
46-
newMultiaddr(t, "/ip6/fe80::1/tcp/1234"),
47-
newMultiaddr(t, "/ip6/fe80::/tcp/1234"),
48-
newMultiaddr(t, "/ip6/fe80::/tcp/1234/http"),
49-
newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234/http"),
50-
}
51-
52-
bad := []ma.Multiaddr{
53-
newMultiaddr(t, "/ip4/127.0.0.1/udp/1234"),
54-
newMultiaddr(t, "/ip4/0.0.0.0/udp/1234/utp"),
55-
newMultiaddr(t, "/ip6/::1/udp/1234"),
56-
newMultiaddr(t, "/ip6/::/udp/1234"),
57-
}
58-
59-
for _, a := range bad {
60-
if IsFDCostlyTransport(a) {
61-
t.Errorf("addr %s should not be fd costly", a)
62-
}
63-
}
64-
65-
for _, a := range good {
66-
if !IsFDCostlyTransport(a) {
67-
t.Errorf("addr %s should be fd costly", a)
68-
}
69-
}
70-
}
71-
72-
func TestIsFdCostlyMalformed(t *testing.T) {
73-
bad := []ma.Multiaddr{
74-
newMultiaddr(t, "/ip4/127.0.0.1/"),
75-
newMultiaddr(t, "/ip4/0.0.0.0/"),
76-
newMultiaddr(t, "/ip6/::1/"),
77-
newMultiaddr(t, "/ip6/::/"),
78-
}
79-
80-
for _, a := range bad {
81-
if IsFDCostlyTransport(a) {
82-
t.Errorf("addr %s should not be fd costly", a)
83-
}
84-
}
85-
}

0 commit comments

Comments
 (0)