Skip to content

Commit

Permalink
Merge pull request #76 from s7techlab/peer-interface-fix
Browse files Browse the repository at this point in the history
Peer interface fix
  • Loading branch information
vitiko authored Dec 10, 2021
2 parents 1fe46f5 + 5422d10 commit 8b46b92
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions api/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions client/chaincode/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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) {
Expand Down

0 comments on commit 8b46b92

Please sign in to comment.