diff --git a/api/chaincode.go b/api/chaincode.go index 90a270d9..1c954cb3 100644 --- a/api/chaincode.go +++ b/api/chaincode.go @@ -25,9 +25,9 @@ type Chaincode interface { } type ChaincodePackage interface { - // Allows to get latest version of chaincode + // Latest allows to get latest version of chaincode Latest(ctx context.Context) (*peer.ChaincodeDeploymentSpec, error) - // Installs chaincode using defined chaincode fetcher + // Install chaincode using defined chaincode fetcher Install(ctx context.Context, path, version string) error // Instantiate chaincode on channel with presented params Instantiate(ctx context.Context, channelName, path, version, policy string, args [][]byte, transArgs TransArgs) error @@ -83,6 +83,8 @@ type ChaincodeQueryBuilder interface { AsJSON(ctx context.Context, out interface{}) error // AsProposalResponse allows to get raw peer response AsProposalResponse(ctx context.Context) (*peer.ProposalResponse, error) + // Do makes query with built arguments + Do(ctx context.Context) (*peer.Response, error) } // QSCC describes Query System Chaincode (QSCC) diff --git a/api/core.go b/api/core.go index 163a480b..45186f69 100644 --- a/api/core.go +++ b/api/core.go @@ -63,7 +63,7 @@ type Core interface { args [][]byte, identity msp.SigningIdentity, transient map[string][]byte, - ) (*peer.ProposalResponse, error) + ) (*peer.Response, error) } // types which identify tx "wait'er" policy diff --git a/client/chaincode/query.go b/client/chaincode/query.go index dbd74bd0..58f3733e 100644 --- a/client/chaincode/query.go +++ b/client/chaincode/query.go @@ -60,6 +60,16 @@ func (q *QueryBuilder) AsProposalResponse(ctx context.Context) (*fabricPeer.Prop return q.peerPool.Process(ctx, q.identity.GetMSPIdentifier(), proposal) } +// Do makes invoke with built arguments +func (q *QueryBuilder) Do(ctx context.Context) (*fabricPeer.Response, error) { + res, err := q.AsProposalResponse(ctx) + if err != nil { + return nil, err + } + + return res.Response, nil +} + func (q *QueryBuilder) Transient(args api.TransArgs) api.ChaincodeQueryBuilder { q.transientArgs = args return q diff --git a/client/core.go b/client/core.go index 05654580..614de075 100644 --- a/client/core.go +++ b/client/core.go @@ -287,7 +287,7 @@ func (c *core) Query( args [][]byte, identity msp.SigningIdentity, transient map[string][]byte, -) (*fabPeer.ProposalResponse, error) { +) (*fabPeer.Response, error) { if identity == nil { identity = c.CurrentIdentity() } @@ -305,7 +305,7 @@ func (c *core) Query( return ccAPI.Query(argsStrings[0], argsStrings[1:]...). WithIdentity(identity). Transient(transient). - AsProposalResponse(ctx) + Do(ctx) } func NewCore(mspId string, identity api.Identity, opts ...CoreOpt) (api.Core, error) {