Skip to content

Commit

Permalink
Merge pull request #99 from s7techlab/return-peer-uri-when-endrorse-w…
Browse files Browse the repository at this point in the history
…ith-error

Return peer uri when endrorse with error
  • Loading branch information
criro1 committed Mar 2, 2022
2 parents 9f76434 + 59a4a07 commit d1d0343
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions peer/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pool

import (
"context"
"fmt"
"sync"

"github.com/hyperledger/fabric-protos-go/peer"
Expand Down Expand Up @@ -103,11 +104,12 @@ func (p *peerPool) poolChecker(ctx context.Context, aliveChan chan bool, peer *p
func (p *peerPool) Process(ctx context.Context, mspId string, proposal *peer.SignedProposal) (*peer.ProposalResponse, error) {
log := p.log.Named(`Process`)
p.storeMx.RLock()

//check MspId exists
peers, ok := p.store[mspId]
peers, exists := p.store[mspId]
p.storeMx.RUnlock()

if !ok {
if !exists {
log.Error(api.ErrMSPNotFound.Error(), zap.String(`mspId`, mspId))
return nil, api.ErrMSPNotFound
}
Expand Down Expand Up @@ -142,8 +144,9 @@ func (p *peerPool) Process(ctx context.Context, mspId string, proposal *peer.Sig
zap.String(`code_str`, s.Code().String()), zap.Error(s.Err()))
// not mark as not ready
}

// next mspId peer
lastError = err
lastError = fmt.Errorf("peer %s: %w", poolPeer.peer.Uri(), err)
continue
}

Expand All @@ -157,7 +160,7 @@ func (p *peerPool) Process(ctx context.Context, mspId string, proposal *peer.Sig
}

if lastError == nil {
// all peers was not ready
// not all peers were ready
return nil, api.ErrNoReadyPeers{MspId: mspId}
}

Expand Down

0 comments on commit d1d0343

Please sign in to comment.