Skip to content

Commit

Permalink
GetNodeIP: return same values as InfoClient
Browse files Browse the repository at this point in the history
addresses review comment #373 (comment)
  • Loading branch information
feuGeneA committed Jul 19, 2024
1 parent e0794af commit 641e532
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions peers/app_request_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/ava-labs/avalanchego/network"
snowVdrs "github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/ips"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
Expand Down Expand Up @@ -176,20 +175,14 @@ func (n *AppRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id
zap.Error(err),
)
} else if nodeIDs.Contains(apiNodeID) {
if apiNodeIP, err := n.infoAPI.GetNodeIP(context.Background()); err != nil {
if apiNodeIPPort, err := n.infoAPI.GetNodeIP(context.Background()); err != nil {
n.logger.Error(
"Failed to get API Node IP",
zap.Error(err),
)
} else if ipPort, err := ips.ParseAddrPort(apiNodeIP); err != nil {
n.logger.Error(
"Failed to parse API Node IP",
zap.String("nodeIP", apiNodeIP),
zap.Error(err),
)
} else {
trackedNodes.Add(apiNodeID)
n.Network.ManuallyTrack(apiNodeID, ipPort)
n.Network.ManuallyTrack(apiNodeID, apiNodeIPPort)
}
}

Expand Down
6 changes: 3 additions & 3 deletions peers/info_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package peers

import (
"context"
"net/netip"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
Expand Down Expand Up @@ -47,9 +48,8 @@ func (i *InfoAPI) GetNodeID(ctx context.Context) (ids.NodeID, *signer.ProofOfPos
return i.client.GetNodeID(ctx, i.options...)
}

func (i *InfoAPI) GetNodeIP(ctx context.Context) (string, error) {
addrPort, err := i.client.GetNodeIP(ctx, i.options...)
return addrPort.Addr().String(), err
func (i *InfoAPI) GetNodeIP(ctx context.Context) (netip.AddrPort, error) {
return i.client.GetNodeIP(ctx, i.options...)
}

func (i *InfoAPI) GetNodeVersion(ctx context.Context) (*info.GetNodeVersionReply, error) {
Expand Down

0 comments on commit 641e532

Please sign in to comment.