-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-4370] Basic EndorserTx support in protolator
There have been numerous requests on rocketchat with people attempting to inspect the endorser transaction contents. Thanks to the complicated structure of the endorser tx protos, it is very difficult for a casual user to turn the binary blob into a human readable form. This CR adds basic support for decoding typical endorser transactions. Note: It makes no effort to handle transactions which have the proposal visibility set to anything other than full, and no effort to support endorser transactions which are not chaincode related (to my knowledge, these are unimplemented). Change-Id: I246b5a4ec60ae5748a4eedc064da54f1d3e92672 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Aug 2, 2017
1 parent
b0632c0
commit 15a9028
Showing
5 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package peer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
func (cpp *ChaincodeProposalPayload) StaticallyOpaqueFields() []string { | ||
return []string{"input"} | ||
} | ||
|
||
func (cpp *ChaincodeProposalPayload) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { | ||
if name != cpp.StaticallyOpaqueFields()[0] { | ||
return nil, fmt.Errorf("not a marshaled field: %s", name) | ||
} | ||
return &ChaincodeInvocationSpec{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package peer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
func (ppr *ProposalResponsePayload) StaticallyOpaqueFields() []string { | ||
return []string{"extension"} | ||
} | ||
|
||
func (ppr *ProposalResponsePayload) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { | ||
if name != ppr.StaticallyOpaqueFields()[0] { | ||
return nil, fmt.Errorf("not a marshaled field: %s", name) | ||
} | ||
return &ChaincodeAction{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package peer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric/protos/common" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
func init() { | ||
common.PayloadDataMap[int32(common.HeaderType_ENDORSER_TRANSACTION)] = &Transaction{} | ||
} | ||
|
||
func (ta *TransactionAction) StaticallyOpaqueFields() []string { | ||
return []string{"header", "payload"} | ||
} | ||
|
||
func (ta *TransactionAction) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { | ||
switch name { | ||
case ta.StaticallyOpaqueFields()[0]: | ||
return &common.SignatureHeader{}, nil | ||
case ta.StaticallyOpaqueFields()[1]: | ||
return &ChaincodeActionPayload{}, nil | ||
default: | ||
return nil, fmt.Errorf("not a marshaled field: %s", name) | ||
} | ||
} | ||
|
||
func (cap *ChaincodeActionPayload) StaticallyOpaqueFields() []string { | ||
return []string{"chaincode_proposal_payload"} | ||
} | ||
|
||
func (cap *ChaincodeActionPayload) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { | ||
if name != cap.StaticallyOpaqueFields()[0] { | ||
return nil, fmt.Errorf("not a marshaled field: %s", name) | ||
} | ||
return &ChaincodeProposalPayload{}, nil | ||
} | ||
|
||
func (cae *ChaincodeEndorsedAction) StaticallyOpaqueFields() []string { | ||
return []string{"proposal_response_payload"} | ||
} | ||
|
||
func (cae *ChaincodeEndorsedAction) StaticallyOpaqueFieldProto(name string) (proto.Message, error) { | ||
if name != cae.StaticallyOpaqueFields()[0] { | ||
return nil, fmt.Errorf("not a marshaled field: %s", name) | ||
} | ||
return &ProposalResponsePayload{}, nil | ||
} |