Skip to content

Commit

Permalink
Code changes for go-multiaddr-v015
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Jan 21, 2025
1 parent 5f8dd91 commit bef40e0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/rpc/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (api *SwarmAPI) Connect(ctx context.Context, pi peer.AddrInfo) error {

saddrs := make([]string, len(pi.Addrs))
for i, addr := range pi.Addrs {
saddrs[i] = addr.Encapsulate(pidma).String()
saddrs[i] = addr.EncapsulateC(pidma).String()

Check failure on line 24 in client/rpc/swarm.go

View workflow job for this annotation

GitHub Actions / go-check

addr.EncapsulateC undefined (type multiaddr.Multiaddr has no field or method EncapsulateC)

Check failure on line 24 in client/rpc/swarm.go

View workflow job for this annotation

GitHub Actions / go-lint

addr.EncapsulateC undefined (type multiaddr.Multiaddr has no field or method EncapsulateC) (typecheck)
}

return api.core().Request("swarm/connect", saddrs...).Exec(ctx, nil)
Expand Down
4 changes: 2 additions & 2 deletions cmd/ipfs/kubo/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ func rewriteMaddrToUseLocalhostIfItsAny(maddr ma.Multiaddr) ma.Multiaddr {
first, rest := ma.SplitFirst(maddr)

switch {
case first.Equal(manet.IP4Unspecified):
case first.Equal(manet.IP4Unspecified[0]):

Check failure on line 819 in cmd/ipfs/kubo/daemon.go

View workflow job for this annotation

GitHub Actions / go-lint

invalid operation: cannot index manet.IP4Unspecified (variable of type multiaddr.Multiaddr) (typecheck)
return manet.IP4Loopback.Encapsulate(rest)
case first.Equal(manet.IP6Unspecified):
case first.Equal(manet.IP6Unspecified[0]):
return manet.IP6Loopback.Encapsulate(rest)
default:
return maddr // not ip
Expand Down
2 changes: 1 addition & 1 deletion core/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func bootstrapAdd(r repo.Repo, cfg *config.Config, peers []string) ([]string, er
return nil, err
}
tpt, p2ppart := ma.SplitLast(m)
if p2ppart == nil || p2ppart.Protocol().Code != ma.P_P2P {
if p2ppart.Empty() || p2ppart.Protocol().Code != ma.P_P2P {

Check failure on line 304 in core/commands/bootstrap.go

View workflow job for this annotation

GitHub Actions / go-check

p2ppart.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 304 in core/commands/bootstrap.go

View workflow job for this annotation

GitHub Actions / interop-prep

p2ppart.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 304 in core/commands/bootstrap.go

View workflow job for this annotation

GitHub Actions / go-build

p2ppart.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 304 in core/commands/bootstrap.go

View workflow job for this annotation

GitHub Actions / go-lint

p2ppart.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 304 in core/commands/bootstrap.go

View workflow job for this annotation

GitHub Actions / go-test

p2ppart.Empty undefined (type *multiaddr.Component has no field or method Empty)
return nil, fmt.Errorf("invalid bootstrap address: %s", p)
}
if tpt == nil {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func resolveAddresses(ctx context.Context, addrs []string, rslv *madns.Resolver)
// filter out addresses that still doesn't end in `ipfs/Qm...`
found := 0
for _, raddr := range raddrs {
if _, last := ma.SplitLast(raddr); last != nil && last.Protocol().Code == ma.P_IPFS {
if _, last := ma.SplitLast(raddr); !last.Empty() && last.Protocol().Code == ma.P_IPFS {

Check failure on line 810 in core/commands/swarm.go

View workflow job for this annotation

GitHub Actions / go-check

last.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 810 in core/commands/swarm.go

View workflow job for this annotation

GitHub Actions / interop-prep

last.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 810 in core/commands/swarm.go

View workflow job for this annotation

GitHub Actions / go-build

last.Empty undefined (type *multiaddr.Component has no field or method Empty)

Check failure on line 810 in core/commands/swarm.go

View workflow job for this annotation

GitHub Actions / go-lint

last.Empty undefined (type *multiaddr.Component has no field or method Empty)) (typecheck)

Check failure on line 810 in core/commands/swarm.go

View workflow job for this annotation

GitHub Actions / go-test

last.Empty undefined (type *multiaddr.Component has no field or method Empty)
maddrC <- raddr
found++
}
Expand Down
8 changes: 4 additions & 4 deletions test/cli/harness/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (n *Node) SwarmAddrsWithPeerIDs() []multiaddr.Multiaddr {
if err != nil {
panic(err)
}
ma = ma.Encapsulate(comp)
ma = ma.EncapsulateC(comp)

Check failure on line 489 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-check

ma.EncapsulateC undefined (type multiaddr.Multiaddr has no field or method EncapsulateC)

Check failure on line 489 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-lint

ma.EncapsulateC undefined (type multiaddr.Multiaddr has no field or method EncapsulateC)

Check failure on line 489 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-lint

ma.EncapsulateC undefined (type multiaddr.Multiaddr has no field or method EncapsulateC)
}
addrs = append(addrs, ma)
}
Expand All @@ -496,15 +496,15 @@ func (n *Node) SwarmAddrsWithPeerIDs() []multiaddr.Multiaddr {
func (n *Node) SwarmAddrsWithoutPeerIDs() []multiaddr.Multiaddr {
var addrs []multiaddr.Multiaddr
for _, ma := range n.SwarmAddrs() {
var components []multiaddr.Multiaddr
var components []multiaddr.Component
multiaddr.ForEach(ma, func(c multiaddr.Component) bool {
if c.Protocol().Code == multiaddr.P_IPFS {
return true
}
components = append(components, &c)
components = append(components, c)
return true
})
ma = multiaddr.Join(components...)
ma = multiaddr.JoinComponents(components...)

Check failure on line 507 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-check

undefined: multiaddr.JoinComponents

Check failure on line 507 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-lint

undefined: multiaddr.JoinComponents (typecheck)

Check failure on line 507 in test/cli/harness/node.go

View workflow job for this annotation

GitHub Actions / go-lint

undefined: multiaddr.JoinComponents) (typecheck)
addrs = append(addrs, ma)
}
return addrs
Expand Down

0 comments on commit bef40e0

Please sign in to comment.