Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 913ef17

Browse files
committed
[FAB-7998] Move client APIs to apifabclient
Change-Id: I58b23bb2f9f662acbc6d0fe7921f101651f37284 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent cb5e581 commit 913ef17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+239
-267
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ dockerenv-latest-up: clean
320320

321321
.PHONY: mock-gen
322322
mock-gen:
323-
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apitxn ProposalProcessor | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apitxn/mocks/mockapitxn.gen.go
323+
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apifabclient ProposalProcessor | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apifabclient/mocks/mockfabclient.gen.go
324324
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apiconfig Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apiconfig/mocks/mockconfig.gen.go
325325
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apifabca FabricCAClient | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apifabca/mocks/mockfabriccaclient.gen.go
326326
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api CoreProviders,SvcProviders,Providers,CoreProviderFactory,ServiceProviderFactory,OrgClientFactory,SessionClientFactory | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/fabsdk/api/mocks/mocksdkapi.gen.go

api/apifabclient/channel.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package apifabclient
88

99
import (
10-
txn "github.com/hyperledger/fabric-sdk-go/api/apitxn"
1110
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/msp"
1211
"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
1312
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
@@ -24,14 +23,14 @@ import (
2423
* primary orderer to retrieve the configuration settings for this channel.
2524
*/
2625
type Channel interface {
27-
txn.Sender
28-
txn.ProposalSender
26+
Sender
27+
ProposalSender
2928

3029
Name() string
3130
ChannelConfig() (*common.ConfigEnvelope, error)
3231
SendInstantiateProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope,
33-
collConfig []*common.CollectionConfig, targets []txn.ProposalProcessor) ([]*txn.TransactionProposalResponse, txn.TransactionID, error)
34-
SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []txn.ProposalProcessor) ([]*txn.TransactionProposalResponse, txn.TransactionID, error)
32+
collConfig []*common.CollectionConfig, targets []ProposalProcessor) ([]*TransactionProposalResponse, TransactionID, error)
33+
SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []ProposalProcessor) ([]*TransactionProposalResponse, TransactionID, error)
3534

3635
// Network
3736
// TODO: Use PeerEndorser
@@ -60,8 +59,8 @@ type Channel interface {
6059
QueryBlockByHash(blockHash []byte) (*common.Block, error)
6160
QueryTransaction(transactionID string) (*pb.ProcessedTransaction, error)
6261
QueryInstantiatedChaincodes() (*pb.ChaincodeQueryResponse, error)
63-
QueryByChaincode(txn.ChaincodeInvokeRequest) ([][]byte, error)
64-
QueryBySystemChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, error)
62+
QueryByChaincode(ChaincodeInvokeRequest) ([][]byte, error)
63+
QueryBySystemChaincode(request ChaincodeInvokeRequest) ([][]byte, error)
6564
QueryConfigBlock(peers []Peer, minResponses int) (*common.ConfigEnvelope, error)
6665
}
6766

api/apifabclient/event.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package apifabclient
99
import (
1010
"crypto/x509"
1111

12-
"github.com/hyperledger/fabric-sdk-go/api/apitxn"
1312
common "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
1413
ehpb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
1514
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
@@ -23,8 +22,8 @@ type EventHub interface {
2322
Disconnect() error
2423
RegisterChaincodeEvent(ccid string, eventname string, callback func(*ChaincodeEvent)) *ChainCodeCBE
2524
UnregisterChaincodeEvent(cbe *ChainCodeCBE)
26-
RegisterTxEvent(txnID apitxn.TransactionID, callback func(string, pb.TxValidationCode, error))
27-
UnregisterTxEvent(txnID apitxn.TransactionID)
25+
RegisterTxEvent(txnID TransactionID, callback func(string, pb.TxValidationCode, error))
26+
UnregisterTxEvent(txnID TransactionID)
2827
RegisterBlockEvent(callback func(*common.Block))
2928
UnregisterBlockEvent(callback func(*common.Block))
3029
}

api/apitxn/mocks/mockapitxn.gen.go renamed to api/apifabclient/mocks/mockfabclient.gen.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apifabclient/peer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ package apifabclient
88

99
import (
1010
"encoding/pem"
11-
12-
txn "github.com/hyperledger/fabric-sdk-go/api/apitxn"
1311
)
1412

1513
// The Peer class represents a peer in the target blockchain network to which
@@ -26,7 +24,7 @@ import (
2624
// It should be noted that Peer event streams function at the Peer level and not at the
2725
// channel and chaincode levels.
2826
type Peer interface {
29-
txn.ProposalProcessor
27+
ProposalProcessor
3028

3129
// ECert Client (need verb)
3230
EnrollmentCertificate() *pem.Block
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Copyright SecureKey Technologies Inc. All Rights Reserved.
44
SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
// Package apitxn allows SDK users to plugin their own implementations of transaction processing.
8-
package apitxn
7+
package apifabclient
98

109
import (
1110
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"

api/apifabclient/resource.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ SPDX-License-Identifier: Apache-2.0
77
package apifabclient
88

99
import (
10-
txn "github.com/hyperledger/fabric-sdk-go/api/apitxn"
1110
"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
1211
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
1312
)
1413

1514
// Resource is a client that provides access to fabric resources such as chaincode.
1615
type Resource interface {
17-
CreateChannel(request CreateChannelRequest) (txn.TransactionID, error)
18-
InstallChaincode(request InstallChaincodeRequest) ([]*txn.TransactionProposalResponse, string, error)
16+
CreateChannel(request CreateChannelRequest) (TransactionID, error)
17+
InstallChaincode(request InstallChaincodeRequest) ([]*TransactionProposalResponse, string, error)
1918
QueryInstalledChaincodes(peer Peer) (*pb.ChaincodeQueryResponse, error)
2019
QueryChannels(peer Peer) (*pb.ChannelQueryResponse, error)
2120

@@ -45,7 +44,7 @@ type CreateChannelRequest struct {
4544

4645
// TODO: InvokeChannelRequest allows the TransactionID to be passed in.
4746
// This request struct also has the field for consistency but perhaps it should be removed.
48-
TxnID txn.TransactionID
47+
TxnID TransactionID
4948
}
5049

5150
// InstallChaincodeRequest requests chaincode installation on the network
@@ -59,7 +58,7 @@ type InstallChaincodeRequest struct {
5958
// required - package (chaincode package type and bytes)
6059
Package *CCPackage
6160
// required - proposal processor list
62-
Targets []txn.ProposalProcessor
61+
Targets []ProposalProcessor
6362
}
6463

6564
// CCPackage contains package type and bytes required to create CDS
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Copyright SecureKey Technologies Inc. All Rights Reserved.
44
SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
// Package apitxn allows SDK users to plugin their own implementations of transaction processing.
8-
package apitxn
7+
package apifabclient
98

109
import (
1110
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"

api/apitxn/chclient/chclient.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package chclient
99
import (
1010
"time"
1111

12-
"github.com/hyperledger/fabric-sdk-go/api/apitxn"
12+
"github.com/hyperledger/fabric-sdk-go/api/apifabclient"
1313
"github.com/hyperledger/fabric-sdk-go/pkg/errors/retry"
1414
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
1515
)
@@ -25,14 +25,14 @@ type Request struct {
2525
//Response contains response parameters for query and execute transaction
2626
type Response struct {
2727
Payload []byte
28-
TransactionID apitxn.TransactionID
28+
TransactionID apifabclient.TransactionID
2929
TxValidationCode pb.TxValidationCode
30-
Responses []*apitxn.TransactionProposalResponse
30+
Responses []*apifabclient.TransactionProposalResponse
3131
}
3232

3333
// Opts allows the user to specify more advanced options
3434
type Opts struct {
35-
ProposalProcessors []apitxn.ProposalProcessor // targets
35+
ProposalProcessors []apifabclient.ProposalProcessor // targets
3636
Timeout time.Duration
3737
Retry retry.Opts
3838
}
@@ -43,7 +43,7 @@ type Option func(opts *Opts) error
4343
// TxProposalResponseFilter allows the user to inspect/modify response before commit
4444
type TxProposalResponseFilter interface {
4545
// process transaction proposal response (there will be no commit if an error is returned)
46-
ProcessTxProposalResponse(txProposalResponse []*apitxn.TransactionProposalResponse) ([]*apitxn.TransactionProposalResponse, error)
46+
ProcessTxProposalResponse(txProposalResponse []*apifabclient.TransactionProposalResponse) ([]*apifabclient.TransactionProposalResponse, error)
4747
}
4848

4949
// Registration is a handle that is returned from a successful Register Chaincode Event.

api/apitxn/chclient/opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package chclient
99
import (
1010
"time"
1111

12-
"github.com/hyperledger/fabric-sdk-go/api/apitxn"
12+
"github.com/hyperledger/fabric-sdk-go/api/apifabclient"
1313
"github.com/hyperledger/fabric-sdk-go/pkg/errors/retry"
1414
)
1515

@@ -22,7 +22,7 @@ func WithTimeout(timeout time.Duration) Option {
2222
}
2323

2424
//WithProposalProcessor encapsulates ProposalProcessors to Option
25-
func WithProposalProcessor(proposalProcessors ...apitxn.ProposalProcessor) Option {
25+
func WithProposalProcessor(proposalProcessors ...apifabclient.ProposalProcessor) Option {
2626
return func(opts *Opts) error {
2727
opts.ProposalProcessors = proposalProcessors
2828
return nil

0 commit comments

Comments
 (0)