Skip to content

Commit 11f1b55

Browse files
feat(api) : Peers function to return the PrimaryAlias of the chainID (#2251)
Signed-off-by: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
1 parent c174c62 commit 11f1b55

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

api/info/service.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ type PeersArgs struct {
208208
type Peer struct {
209209
peer.Info
210210

211-
Benched []ids.ID `json:"benched"`
211+
Benched []string `json:"benched"`
212212
}
213213

214214
// PeersReply are the results from calling Peers
@@ -229,9 +229,18 @@ func (i *Info) Peers(_ *http.Request, args *PeersArgs, reply *PeersReply) error
229229
peers := i.networking.PeerInfo(args.NodeIDs)
230230
peerInfo := make([]Peer, len(peers))
231231
for index, peer := range peers {
232+
benchedIDs := i.benchlist.GetBenched(peer.ID)
233+
benchedAliases := make([]string, len(benchedIDs))
234+
for idx, id := range benchedIDs {
235+
alias, err := i.chainManager.PrimaryAlias(id)
236+
if err != nil {
237+
return fmt.Errorf("failed to get primary alias for chain ID %s: %w", id, err)
238+
}
239+
benchedAliases[idx] = alias
240+
}
232241
peerInfo[index] = Peer{
233242
Info: peer,
234-
Benched: i.benchlist.GetBenched(peer.ID),
243+
Benched: benchedAliases,
235244
}
236245
}
237246

0 commit comments

Comments
 (0)