-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-8542] Split invoke package from channel client
This change moves transaction handlers from channel to an invoke subpackage. The objective is to make the channel package easier to understand. Change-Id: I2b11152f78e2dd406f0826ffc427930285b4ba49 Signed-off-by: Troy Ronda <[email protected]>
- Loading branch information
Showing
9 changed files
with
154 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// Package invoke provides the handlers for performing chaincode invocations. | ||
package invoke | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/core" | ||
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab" | ||
"github.com/hyperledger/fabric-sdk-go/pkg/errors/retry" | ||
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer" | ||
) | ||
|
||
// Opts allows the user to specify more advanced options | ||
type Opts struct { | ||
ProposalProcessors []fab.ProposalProcessor // targets | ||
Timeout time.Duration | ||
Retry retry.Opts | ||
} | ||
|
||
// Request contains the parameters to execute transaction | ||
type Request struct { | ||
ChaincodeID string | ||
Fcn string | ||
Args [][]byte | ||
TransientMap map[string][]byte | ||
} | ||
|
||
//Response contains response parameters for query and execute transaction | ||
type Response struct { | ||
Payload []byte | ||
TransactionID fab.TransactionID | ||
TxValidationCode pb.TxValidationCode | ||
Proposal *fab.TransactionProposal | ||
Responses []*fab.TransactionProposalResponse | ||
} | ||
|
||
//Handler for chaining transaction executions | ||
type Handler interface { | ||
Handle(context *RequestContext, clientContext *ClientContext) | ||
} | ||
|
||
//ClientContext contains context parameters for handler execution | ||
type ClientContext struct { | ||
CryptoSuite core.CryptoSuite | ||
Discovery fab.DiscoveryService | ||
Selection fab.SelectionService | ||
Channel fab.Channel // TODO: this should be removed when we have MSP split out. | ||
Transactor fab.Transactor | ||
EventHub fab.EventHub | ||
} | ||
|
||
//RequestContext contains request, opts, response parameters for handler execution | ||
type RequestContext struct { | ||
Request Request | ||
Opts Opts | ||
Response Response | ||
Error error | ||
RetryHandler retry.Handler | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.