Skip to content

Commit 26e2584

Browse files
authored
Merge pull request #105 from ipfs/fix/ipfs-addr-migration
fix: handle /ipfs/ addrs when migrating bootstrappers
2 parents 9622b6f + d67352c commit 26e2584

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ipfs-9-to-10/migration/config_conv.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ func ver9to10Bootstrap(bootstrap []string) []string {
130130
hasNew := false
131131
res := make([]string, 0, len(bootstrap)+1)
132132
for _, addr := range bootstrap {
133+
// Upgrade /ipfs & /p2p. This should have happened in migration
134+
// 7-to-8, but that migration wouldn't run at all if we already
135+
// had the new bootstrappers.
136+
addr = strings.Replace(addr, "/ipfs/Qm", "/p2p/Qm", -1)
137+
addr = strings.Replace(addr, "/ipfs/1", "/p2p/1", -1)
138+
133139
res = append(res, addr)
134140
if addr == ip4BootstrapAddr {
135141
hasOld = true

sharness/t0130-migration-9-to-10.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ test_expect_success "re-run migration 9 to 10" '
8585
# Shouldn't do anything this time, now that we have an address.
8686
check_results
8787

88+
# Should also work with /ipfs/ addresses
89+
test_expect_success "add bootstrap addresses" '
90+
test_config_set --json Bootstrap "[
91+
\"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb\",
92+
\"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt\",
93+
\"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ\",
94+
\"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN\",
95+
\"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa\"
96+
]"
97+
'
98+
99+
test_expect_success "re-run migration 9 to 10" '
100+
echo 9 > "$IPFS_PATH/version" &&
101+
echo $IPFS_PATH &&
102+
ipfs-9-to-10 -verbose -path="$IPFS_PATH"
103+
'
104+
105+
# Shouldn't do anything this time, now that we have an address.
106+
check_results
107+
88108
test_expect_success "revert migration 10 to 9 succeeds" '
89109
ipfs-9-to-10 -revert -verbose -path="$IPFS_PATH"
90110
'

0 commit comments

Comments
 (0)