Skip to content

Commit

Permalink
feat(api) : Peers function to return the PrimaryAlias of the chainID (#…
Browse files Browse the repository at this point in the history
…2251)

Signed-off-by: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
  • Loading branch information
DoTheBestToGetTheBest and StephenButtolph authored Nov 2, 2023
1 parent c174c62 commit 11f1b55
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 11f1b55

Please sign in to comment.