Skip to content

Commit

Permalink
Endorser gets ESCC from ChaincodeData
Browse files Browse the repository at this point in the history
This change request extracts the ESCC that is to be used to endorse a given
chaincode from the ChaincodeData struct returned by LCCC instead of using
the hardcoded "escc" string as it was done previously.

Change-Id: I94648a0556b7729d69af476c6ed25b23728cd85b
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Feb 1, 2017
1 parent 7104614 commit 579101d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,17 @@ func (e *Endorser) getCDSFromLCCC(ctx context.Context, chainID string, txid stri
func (e *Endorser) endorseProposal(ctx context.Context, chainID string, txid string, proposal *pb.Proposal, response *pb.Response, simRes []byte, event *pb.ChaincodeEvent, visibility []byte, ccid *pb.ChaincodeID, txsim ledger.TxSimulator, cd *ccprovider.ChaincodeData) (*pb.ProposalResponse, error) {
endorserLogger.Infof("endorseProposal starts for chainID %s, ccid %s", chainID, ccid)

// 1) extract the chaincodeDeploymentSpec for the chaincode we are invoking; we need it to get the escc
// 1) extract the name of the escc that is requested to endorse this chaincode
var escc string

//ie, not "lccc" or system chaincodes
if cd != nil {
_, err := putils.GetChaincodeDeploymentSpec(cd.DepSpec)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal cds for %s - %s", ccid, err)
escc = cd.Escc
if escc == "" { // this should never happen, LCCC always fills this field
panic("No ESCC specified in ChaincodeData")
}

// FIXME: pick the right escc from cds - currently cds doesn't have this info
escc = "escc"
} else {
// FIXME: getCDSFromLCCC seems to fail for lccc - not sure this is expected?
// TODO: who should endorse a call to LCCC?
escc = "escc"
}

Expand Down

0 comments on commit 579101d

Please sign in to comment.