Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 2933804

Browse files
committed
[FAB-10079] Use successful response from discovery
Loop through all responses and choose the first response without error. Change-Id: I5886fbaba3151710be0f058bc9fdbd7c76b459c2 Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
1 parent 89d1ed6 commit 2933804

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/client/common/discovery/dynamicdiscovery/chservice.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ func (s *channelService) evaluate(ctx contextAPI.Channel, responses []fabdiscove
9393
// TODO: In a future patch:
9494
// - validate the signatures in the responses
9595
// - ensure N responses match according to the policy
96-
// For now just pick the first response
97-
response := responses[0]
98-
endpoints, err := response.ForChannel(ctx.ChannelID()).Peers()
99-
if err != nil {
100-
return nil, errors.Wrapf(err, "error getting peers from discovery response")
96+
// For now just pick the first successful response
97+
98+
var lastErr error
99+
for _, response := range responses {
100+
endpoints, err := response.ForChannel(ctx.ChannelID()).Peers()
101+
if err != nil {
102+
lastErr = errors.Wrapf(err, "error getting peers from discovery response")
103+
logger.Warn(lastErr.Error())
104+
continue
105+
}
106+
return asPeers(ctx, endpoints), nil
101107
}
102-
103-
return asPeers(ctx, endpoints), nil
108+
return nil, lastErr
104109
}

0 commit comments

Comments
 (0)