Skip to content

Commit

Permalink
[FABG-803] Sync the latest files of fabric.
Browse files Browse the repository at this point in the history
It will be used to implement parsing blocks.

Change-Id: I48b6b1c5a1a4f12da4dab59681a15273afa97c6c
Signed-off-by: ice <wcwz020140@163.com>
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Dec 18, 2018
1 parent 1bd8071 commit 371a591
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -72,7 +72,7 @@ sed -i'' -e 's/"github.com\/hyperledger\/fabric\/bccsp\/factory"/factory "github
sed -i'' -e 's/&bccsp.SHA256Opts{}/factory.GetSHA256Opts()/g' "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"

FILTER_FILENAME="protos/utils/txutils.go"
FILTER_FN="GetBytesProposalPayloadForTx,GetEnvelopeFromBlock"
FILTER_FN="GetBytesProposalPayloadForTx,GetEnvelopeFromBlock,GetPayloads"
gofilter

FILTER_FILENAME="core/common/ccprovider/ccprovider.go"
Expand Down
28 changes: 28 additions & 0 deletions third_party/github.com/hyperledger/fabric/protos/utils/txutils.go
Expand Up @@ -17,6 +17,34 @@ import (
"github.com/pkg/errors"
)

// GetPayloads gets the underlying payload objects in a TransactionAction
func GetPayloads(txActions *peer.TransactionAction) (*peer.ChaincodeActionPayload, *peer.ChaincodeAction, error) {
// TODO: pass in the tx type (in what follows we're assuming the
// type is ENDORSER_TRANSACTION)
ccPayload, err := GetChaincodeActionPayload(txActions.Payload)
if err != nil {
return nil, nil, err
}

if ccPayload.Action == nil || ccPayload.Action.ProposalResponsePayload == nil {
return nil, nil, errors.New("no payload in ChaincodeActionPayload")
}
pRespPayload, err := GetProposalResponsePayload(ccPayload.Action.ProposalResponsePayload)
if err != nil {
return nil, nil, err
}

if pRespPayload.Extension == nil {
return nil, nil, errors.New("response payload is missing extension")
}

respPayload, err := GetChaincodeAction(pRespPayload.Extension)
if err != nil {
return ccPayload, nil, err
}
return ccPayload, respPayload, nil
}

// GetEnvelopeFromBlock gets an envelope from a block's Data field.
func GetEnvelopeFromBlock(data []byte) (*common.Envelope, error) {
// Block always begins with an envelope
Expand Down

0 comments on commit 371a591

Please sign in to comment.