@@ -45,10 +45,11 @@ var chaincodeLogger = logging.MustGetLogger("shim")
45
45
// ChaincodeStub is an object passed to chaincode for shim side handling of
46
46
// APIs.
47
47
type ChaincodeStub struct {
48
- TxID string
49
- chaincodeEvent * pb.ChaincodeEvent
50
- args [][]byte
51
- handler * Handler
48
+ TxID string
49
+ proposalContext * pb.ChaincodeProposalContext
50
+ chaincodeEvent * pb.ChaincodeEvent
51
+ args [][]byte
52
+ handler * Handler
52
53
}
53
54
54
55
// Peer address derived from command line or env var
@@ -266,17 +267,18 @@ func chatWithPeer(chaincodename string, stream PeerChaincodeStream, cc Chaincode
266
267
// -- init stub ---
267
268
// ChaincodeInvocation functionality
268
269
269
- func (stub * ChaincodeStub ) init (handler * Handler , txid string , input * pb.ChaincodeInput ) {
270
+ func (stub * ChaincodeStub ) init (handler * Handler , txid string , input * pb.ChaincodeInput , proposalContext * pb. ChaincodeProposalContext ) {
270
271
stub .TxID = txid
271
272
stub .args = input .Args
272
273
stub .handler = handler
274
+ stub .proposalContext = proposalContext
273
275
}
274
276
275
277
func InitTestStub (funargs ... string ) * ChaincodeStub {
276
278
stub := ChaincodeStub {}
277
279
allargs := util .ToChaincodeArgs (funargs ... )
278
280
newCI := & pb.ChaincodeInput {Args : allargs }
279
- stub .init (& Handler {}, "TEST-txid" , newCI )
281
+ stub .init (& Handler {}, "TEST-txid" , newCI , nil ) // TODO: add msg.ProposalContext
280
282
return & stub
281
283
}
282
284
@@ -655,12 +657,20 @@ func deleteRowInternal(stub ChaincodeStubInterface, tableName string, key []Colu
655
657
656
658
// GetCallerCertificate returns caller certificate
657
659
func (stub * ChaincodeStub ) GetCallerCertificate () ([]byte , error ) {
658
- return nil , nil
660
+ if stub .proposalContext != nil {
661
+ return stub .proposalContext .Transient , nil
662
+ }
663
+
664
+ return nil , errors .New ("Creator field not set." )
659
665
}
660
666
661
667
// GetCallerMetadata returns caller metadata
662
668
func (stub * ChaincodeStub ) GetCallerMetadata () ([]byte , error ) {
663
- return nil , nil
669
+ if stub .proposalContext != nil {
670
+ return stub .proposalContext .Transient , nil
671
+ }
672
+
673
+ return nil , errors .New ("Transient field not set." )
664
674
}
665
675
666
676
// GetBinding returns the transaction binding
0 commit comments