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

Commit b368032

Browse files
author
Firas Qutishat
committed
[FABG-755] Round-robin balancer using block height
Change-Id: I4ceef5888e7b965547e791ca03ab62febe213188 Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
1 parent 915a932 commit b368032

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/client/common/selection/fabricselection/selectionfilter.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func resolveBalancer(channelID string, channelConfig *fab.ChannelEndpointConfig)
8080
}
8181

8282
func (s *selectionFilter) Filter(endorsers discclient.Endorsers) discclient.Endorsers {
83+
8384
// Convert the endorsers to peers
8485
peers := s.asPeerValues(endorsers)
8586

@@ -96,7 +97,7 @@ func (s *selectionFilter) Filter(endorsers discclient.Endorsers) discclient.Endo
9697
sortedPeers := s.sortPeers(filteredPeers)
9798

9899
// Convert the filtered peers to endorsers
99-
return asEndorsers(endorsers, sortedPeers)
100+
return s.asEndorsers(endorsers, sortedPeers)
100101
}
101102

102103
func (s *selectionFilter) sortPeers(peers []fab.Peer) []fab.Peer {
@@ -179,10 +180,10 @@ func (s *selectionFilter) sortByURL(peers []fab.Peer) []fab.Peer {
179180
return peers
180181
}
181182

182-
func asEndorsers(allEndorsers discclient.Endorsers, filteredPeers []fab.Peer) discclient.Endorsers {
183+
func (s *selectionFilter) asEndorsers(allEndorsers discclient.Endorsers, filteredPeers []fab.Peer) discclient.Endorsers {
183184
var filteredEndorsers discclient.Endorsers
184185
for _, peer := range filteredPeers {
185-
endorser, found := asEndorser(allEndorsers, peer)
186+
endorser, found := s.asEndorser(allEndorsers, peer)
186187
if !found {
187188
// This should never happen since the peer was composed from the initial list of endorsers
188189
logger.Warnf("Endorser [%s] not found. Endorser will be excluded.", peer.URL())
@@ -194,9 +195,9 @@ func asEndorsers(allEndorsers discclient.Endorsers, filteredPeers []fab.Peer) di
194195
return filteredEndorsers
195196
}
196197

197-
func asEndorser(endorsers discclient.Endorsers, peer fab.Peer) (*discclient.Peer, bool) {
198+
func (s *selectionFilter) asEndorser(endorsers discclient.Endorsers, peer fab.Peer) (*discclient.Peer, bool) {
198199
for _, endorser := range endorsers {
199-
url := endorser.AliveMessage.GetAliveMsg().GetMembership().Endpoint
200+
url := s.asPeerValue(endorser).URL()
200201
if peer.URL() == url {
201202
return endorser, true
202203
}

0 commit comments

Comments
 (0)