Skip to content

Commit

Permalink
[FAB-10079] Use successful response from discovery
Browse files Browse the repository at this point in the history
Loop through all responses and choose the first
response without error.

Change-Id: I5886fbaba3151710be0f058bc9fdbd7c76b459c2
Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
  • Loading branch information
bstasyszyn committed May 15, 2018
1 parent 89d1ed6 commit 2933804
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/client/common/discovery/dynamicdiscovery/chservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ func (s *channelService) evaluate(ctx contextAPI.Channel, responses []fabdiscove
// TODO: In a future patch:
// - validate the signatures in the responses
// - ensure N responses match according to the policy
// For now just pick the first response
response := responses[0]
endpoints, err := response.ForChannel(ctx.ChannelID()).Peers()
if err != nil {
return nil, errors.Wrapf(err, "error getting peers from discovery response")
// For now just pick the first successful response

var lastErr error
for _, response := range responses {
endpoints, err := response.ForChannel(ctx.ChannelID()).Peers()
if err != nil {
lastErr = errors.Wrapf(err, "error getting peers from discovery response")
logger.Warn(lastErr.Error())
continue
}
return asPeers(ctx, endpoints), nil
}

return asPeers(ctx, endpoints), nil
return nil, lastErr
}

0 comments on commit 2933804

Please sign in to comment.