github.com/yimialmonte/fabric@v2.1.1+incompatible/common/tools/protolator/protoext/peerext/proposal.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package peerext
     8  
     9  import (
    10  	"fmt"
    11  
    12  	"github.com/golang/protobuf/proto"
    13  	"github.com/hyperledger/fabric-protos-go/ledger/rwset"
    14  	"github.com/hyperledger/fabric-protos-go/peer"
    15  )
    16  
    17  type ChaincodeProposalPayload struct {
    18  	*peer.ChaincodeProposalPayload
    19  }
    20  
    21  func (cpp *ChaincodeProposalPayload) Underlying() proto.Message {
    22  	return cpp.ChaincodeProposalPayload
    23  }
    24  
    25  func (cpp *ChaincodeProposalPayload) StaticallyOpaqueFields() []string {
    26  	return []string{"input"}
    27  }
    28  
    29  func (cpp *ChaincodeProposalPayload) StaticallyOpaqueFieldProto(name string) (proto.Message, error) {
    30  	if name != cpp.StaticallyOpaqueFields()[0] {
    31  		return nil, fmt.Errorf("not a marshaled field: %s", name)
    32  	}
    33  	return &peer.ChaincodeInvocationSpec{}, nil
    34  }
    35  
    36  type ChaincodeAction struct {
    37  	*peer.ChaincodeAction
    38  }
    39  
    40  func (ca *ChaincodeAction) Underlying() proto.Message {
    41  	return ca.ChaincodeAction
    42  }
    43  
    44  func (ca *ChaincodeAction) StaticallyOpaqueFields() []string {
    45  	return []string{"results", "events"}
    46  }
    47  
    48  func (ca *ChaincodeAction) StaticallyOpaqueFieldProto(name string) (proto.Message, error) {
    49  	switch name {
    50  	case "results":
    51  		return &rwset.TxReadWriteSet{}, nil
    52  	case "events":
    53  		return &peer.ChaincodeEvent{}, nil
    54  	default:
    55  		return nil, fmt.Errorf("not a marshaled field: %s", name)
    56  	}
    57  }