Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch to /p2p multiaddrs by default #115

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions multiaddr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ func TestRoundTrip(t *testing.T) {
"/ip4/127.0.0.1/tcp/123",
"/ip4/127.0.0.1/udp/123",
"/ip4/127.0.0.1/udp/123/ip6/::",
"/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP",
"/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP/unix/a/b/c",
"/p2p/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP",
"/p2p/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP/unix/a/b/c",
} {
ma, err := NewMultiaddr(s)
if err != nil {
Expand All @@ -523,7 +523,6 @@ func TestRoundTrip(t *testing.T) {
}
}

// XXX: Change this test when we switch to /p2p by default.
func TestIPFSvP2P(t *testing.T) {
var (
p2pAddr = "/p2p/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP"
Expand All @@ -535,8 +534,8 @@ func TestIPFSvP2P(t *testing.T) {
if err != nil {
t.Errorf("error when parsing %q: %s", s, err)
}
if ma.String() != ipfsAddr {
t.Errorf("expected %q, got %q", ipfsAddr, ma.String())
if ma.String() != p2pAddr {
t.Errorf("expected %q, got %q", p2pAddr, ma.String())
}
}
}
Expand Down
14 changes: 2 additions & 12 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,9 @@ var Protocols = []Protocol{}
// This will cause any P_P2P multiaddr to print out as /p2p/ instead of /ipfs/.
// Note that the binary serialization of this multiaddr does not change at any
// point. This means that this code is not a breaking network change at any point
//
// DEPRECATED: this is now the default
func SwapToP2pMultiaddrs() {
for i := range Protocols {
if Protocols[i].Code == P_P2P {
Protocols[i].Name = "p2p"
break
}
}

protoP2P.Name = "p2p"

protocolsByName["ipfs"] = protoP2P
protocolsByName["p2p"] = protoP2P
protocolsByCode[protoP2P.Code] = protoP2P
}

func AddProtocol(p Protocol) error {
Expand Down
2 changes: 1 addition & 1 deletion protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var (
VCode: CodeToVarint(P_HTTPS),
}
protoP2P = Protocol{
Name: "ipfs",
Name: "p2p",
Code: P_P2P,
VCode: CodeToVarint(P_P2P),
Size: LengthPrefixedVarSize,
Expand Down