@@ -26,7 +26,10 @@ import (
26
26
27
27
// SupportImpl provides an implementation of the endorser.Support interface
28
28
// issuing calls to various static methods of the peer
29
- type SupportImpl struct {}
29
+ type SupportImpl struct {
30
+ Peer peer.Operations
31
+ PeerSupport peer.Support
32
+ }
30
33
31
34
// IsSysCCAndNotInvokableExternal returns true if the supplied chaincode is
32
35
// ia system chaincode and it NOT invokable
@@ -38,7 +41,7 @@ func (s *SupportImpl) IsSysCCAndNotInvokableExternal(name string) bool {
38
41
// a client may obtain more than one such simulator; they are made unique
39
42
// by way of the supplied txid
40
43
func (s * SupportImpl ) GetTxSimulator (ledgername string , txid string ) (ledger.TxSimulator , error ) {
41
- lgr := peer .GetLedger (ledgername )
44
+ lgr := s . Peer .GetLedger (ledgername )
42
45
if lgr == nil {
43
46
return nil , errors .Errorf ("channel does not exist: %s" , ledgername )
44
47
}
@@ -48,7 +51,7 @@ func (s *SupportImpl) GetTxSimulator(ledgername string, txid string) (ledger.TxS
48
51
// GetHistoryQueryExecutor gives handle to a history query executor for the
49
52
// specified ledger
50
53
func (s * SupportImpl ) GetHistoryQueryExecutor (ledgername string ) (ledger.HistoryQueryExecutor , error ) {
51
- lgr := peer .GetLedger (ledgername )
54
+ lgr := s . Peer .GetLedger (ledgername )
52
55
if lgr == nil {
53
56
return nil , errors .Errorf ("channel does not exist: %s" , ledgername )
54
57
}
@@ -57,7 +60,7 @@ func (s *SupportImpl) GetHistoryQueryExecutor(ledgername string) (ledger.History
57
60
58
61
// GetTransactionByID retrieves a transaction by id
59
62
func (s * SupportImpl ) GetTransactionByID (chid , txID string ) (* pb.ProcessedTransaction , error ) {
60
- lgr := peer .GetLedger (chid )
63
+ lgr := s . Peer .GetLedger (chid )
61
64
if lgr == nil {
62
65
return nil , errors .Errorf ("failed to look up the ledger for channel %s" , chid )
63
66
}
@@ -68,13 +71,13 @@ func (s *SupportImpl) GetTransactionByID(chid, txID string) (*pb.ProcessedTransa
68
71
return tx , nil
69
72
}
70
73
71
- //IsSysCC returns true if the name matches a system chaincode's
72
- //system chaincode names are system, chain wide
74
+ // IsSysCC returns true if the name matches a system chaincode's
75
+ // system chaincode names are system, chain wide
73
76
func (s * SupportImpl ) IsSysCC (name string ) bool {
74
77
return scc .IsSysCC (name )
75
78
}
76
79
77
- //Execute - execute proposal, return original response of chaincode
80
+ // Execute a proposal and return the chaincode response
78
81
func (s * SupportImpl ) Execute (ctxt context.Context , cid , name , version , txid string , syscc bool , signedProp * pb.SignedProposal , prop * pb.Proposal , spec interface {}) (* pb.Response , * pb.ChaincodeEvent , error ) {
79
82
cccid := ccprovider .NewCCContext (cid , name , version , txid , syscc , signedProp , prop )
80
83
@@ -105,8 +108,8 @@ func (s *SupportImpl) GetChaincodeDefinition(ctx context.Context, chainID string
105
108
return chaincode .GetChaincodeDefinition (ctxt , txid , signedProp , prop , chainID , chaincodeID )
106
109
}
107
110
108
- //CheckACL checks the ACL for the resource for the channel using the
109
- //SignedProposal from which an id can be extracted for testing against a policy
111
+ // CheckACL checks the ACL for the resource for the channel using the
112
+ // SignedProposal from which an id can be extracted for testing against a policy
110
113
func (s * SupportImpl ) CheckACL (signedProp * pb.SignedProposal , chdr * common.ChannelHeader , shdr * common.SignatureHeader , hdrext * pb.ChaincodeHeaderExtension ) error {
111
114
return aclmgmt .GetACLProvider ().CheckACL (resources .PROPOSE , chdr .ChannelId , signedProp )
112
115
}
@@ -132,14 +135,5 @@ func (s *SupportImpl) CheckInstantiationPolicy(name, version string, cd resource
132
135
// GetApplicationConfig returns the configtxapplication.SharedConfig for the channel
133
136
// and whether the Application config exists
134
137
func (s * SupportImpl ) GetApplicationConfig (cid string ) (channelconfig.Application , bool ) {
135
- return peer .GetSupport ().GetApplicationConfig (cid )
136
- }
137
-
138
- // shorttxid replicates the chaincode package function to shorten txids.
139
- // TODO utilize a common shorttxid utility across packages.
140
- func shorttxid (txid string ) string {
141
- if len (txid ) < 8 {
142
- return txid
143
- }
144
- return txid [0 :8 ]
138
+ return s .PeerSupport .GetApplicationConfig (cid )
145
139
}
0 commit comments