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(api) : Peers function to return the PrimaryAlias of the chainID #2251

Merged
merged 2 commits into from
Nov 2, 2023
Merged
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
13 changes: 11 additions & 2 deletions api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ type PeersArgs struct {
type Peer struct {
peer.Info

Benched []ids.ID `json:"benched"`
Benched []string `json:"benched"`
}

// PeersReply are the results from calling Peers
Expand All @@ -229,9 +229,18 @@ func (i *Info) Peers(_ *http.Request, args *PeersArgs, reply *PeersReply) error
peers := i.networking.PeerInfo(args.NodeIDs)
peerInfo := make([]Peer, len(peers))
for index, peer := range peers {
benchedIDs := i.benchlist.GetBenched(peer.ID)
benchedAliases := make([]string, len(benchedIDs))
for idx, id := range benchedIDs {
alias, err := i.chainManager.PrimaryAlias(id)
if err != nil {
return fmt.Errorf("failed to get primary alias for chain ID %s: %w", id, err)
}
benchedAliases[idx] = alias
}
peerInfo[index] = Peer{
Info: peer,
Benched: i.benchlist.GetBenched(peer.ID),
Benched: benchedAliases,
}
}

Expand Down
Loading