Skip to content

Commit

Permalink
Add debug for gateway endorsement requests (#2538)
Browse files Browse the repository at this point in the history
Add debug messages for the results of gateway endorsement requests.
This makes it easy for developers to see which endorsers were called
and how they each responded.

Signed-off-by: David Enyeart <[email protected]>
  • Loading branch information
denyeart authored Apr 13, 2021
1 parent 4cfc722 commit d001dbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/pkg/gateway/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (gs *Server) Evaluate(ctx context.Context, request *gp.EvaluateRequest) (*g

response, err := endorser.client.ProcessProposal(ctx, signedProposal)
if err != nil {
logger.Debugw("Evaluate call to endorser failed", "channel", request.ChannelId, "txid", request.TransactionId, "endorserAddress", endorser.endpointConfig.address, "endorserMspid", endorser.endpointConfig.mspid, "error", err)
return nil, rpcError(
codes.Aborted,
"failed to evaluate transaction",
Expand All @@ -60,6 +61,7 @@ func (gs *Server) Evaluate(ctx context.Context, request *gp.EvaluateRequest) (*g

retVal, err := getTransactionResponse(response)
if err != nil {
logger.Debugw("Evaluate call to endorser returned failure", "channel", request.ChannelId, "txid", request.TransactionId, "endorserAddress", endorser.endpointConfig.address, "endorserMspid", endorser.endpointConfig.mspid, "error", err)
return nil, rpcError(
codes.Aborted,
"transaction evaluation error",
Expand All @@ -69,6 +71,8 @@ func (gs *Server) Evaluate(ctx context.Context, request *gp.EvaluateRequest) (*g
evaluateResponse := &gp.EvaluateResponse{
Result: retVal,
}

logger.Debugw("Evaluate call to endorser returned success", "channel", request.ChannelId, "txid", request.TransactionId, "endorserAddress", endorser.endpointConfig.address, "endorserMspid", endorser.endpointConfig.mspid, "status", retVal.Status, "message", retVal.Message)
return evaluateResponse, nil
}

Expand Down Expand Up @@ -108,11 +112,14 @@ func (gs *Server) Endorse(ctx context.Context, request *gp.EndorseRequest) (*gp.
response, err := e.client.ProcessProposal(ctx, signedProposal)
switch {
case err != nil:
logger.Debugw("Endorse call to endorser failed", "channel", request.ChannelId, "txid", request.TransactionId, "numEndorsers", len(endorsers), "endorserAddress", e.endpointConfig.address, "endorserMspid", e.endpointConfig.mspid, "error", err)
responseCh <- &endorserResponse{err: endpointError(e, err)}
case response.Response.Status < 200 || response.Response.Status >= 400:
// this is an error case and will be returned in the error details to the client
logger.Debugw("Endorse call to endorser returned failure", "channel", request.ChannelId, "txid", request.TransactionId, "numEndorsers", len(endorsers), "endorserAddress", e.endpointConfig.address, "endorserMspid", e.endpointConfig.mspid, "status", response.Response.Status, "message", response.Response.Message)
responseCh <- &endorserResponse{err: endpointError(e, fmt.Errorf("error %d, %s", response.Response.Status, response.Response.Message))}
default:
logger.Debugw("Endorse call to endorser returned success", "channel", request.ChannelId, "txid", request.TransactionId, "numEndorsers", len(endorsers), "endorserAddress", e.endpointConfig.address, "endorserMspid", e.endpointConfig.mspid, "status", response.Response.Status, "message", response.Response.Message)
responseCh <- &endorserResponse{pr: response}
}
}(e)
Expand Down

0 comments on commit d001dbc

Please sign in to comment.