Skip to content

Commit

Permalink
[FAB-6391] Remove deprecated fabrictxn functions
Browse files Browse the repository at this point in the history
Change-Id: I554d5039784b4b4b837d837aea74657ee9e8ba2d
Signed-off-by: Sandra Vrtikapa <[email protected]>
  • Loading branch information
sandrask committed Oct 2, 2017
1 parent 20ff232 commit 7c71a98
Show file tree
Hide file tree
Showing 22 changed files with 831 additions and 308 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ populate-clean:

clean:
$(GO_CMD) clean
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore /tmp/hfc-kvs
rm -f integration-report.xml report.xml
rm -f test/fixtures/tls/fabricca/certs/server/ca.org*.example.com-cert.pem
cd test/fixtures && $(DOCKER_COMPOSE_CMD) -f docker-compose.yaml -f docker-compose-nopkcs11-test.yaml -f docker-compose-pkcs11-test.yaml down
4 changes: 2 additions & 2 deletions api/apiconfig/configprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const (
Query
// ExecuteTx timeout
ExecuteTx
// OrdererConnection Orderer connection timeout
// OrdererConnection orderer connection timeout
OrdererConnection
// OrdererSendDeliver Orderer SendDeliver timeout
// OrdererResponse orderer response timeout
OrdererResponse
)
1 change: 1 addition & 0 deletions api/apiconfig/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type PeerChannelConfig struct {
type ChannelPeer struct {
PeerChannelConfig
PeerConfig
MspID string
}

// OrganizationConfig provides the definition of an organization in the network
Expand Down
7 changes: 4 additions & 3 deletions api/apitxn/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ type ExecuteTxRequest struct {

// ExecuteTxOpts allows the user to specify more advanced options
type ExecuteTxOpts struct {
Notifier chan ExecuteTxResponse // async
TxFilter ExecuteTxFilter
Timeout time.Duration
Notifier chan ExecuteTxResponse // async
TxFilter ExecuteTxFilter
ProposalProcessors []ProposalProcessor // targets
Timeout time.Duration
}

// ExecuteTxFilter allows the user to inspect/modify response before commit
Expand Down
12 changes: 11 additions & 1 deletion def/fabapi/context/defprovider/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ func (f *DefaultProviderFactory) NewConfigProvider(o opt.ConfigOpts, a opt.SDKOp

// NewStateStoreProvider creates a KeyValueStore using the SDK's default implementation
func (f *DefaultProviderFactory) NewStateStoreProvider(o opt.StateStoreOpts, config apiconfig.Config) (fab.KeyValueStore, error) {
stateStore, err := kvs.CreateNewFileKeyValueStore(o.Path)

var stateStorePath = o.Path
if stateStorePath == "" {
clientCofig, err := config.Client()
if err != nil {
return nil, err
}
stateStorePath = clientCofig.CredentialStore.Path
}

stateStore, err := kvs.CreateNewFileKeyValueStore(stateStorePath)
if err != nil {
return nil, fmt.Errorf("CreateNewFileKeyValueStore returned error[%s]", err)
}
Expand Down
6 changes: 3 additions & 3 deletions def/fabapi/context/defprovider/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (f *SessionClientFactory) NewChannelClient(sdk context.SDK, session context
return nil, fmt.Errorf("Unable to create discovery service:%v", err)
}

eventHub, err := getEventHub(client, channelName)
eventHub, err := getEventHub(client, channelName, session)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -103,7 +103,7 @@ func getChannel(client fab.FabricClient, channelID string) (fab.Channel, error)
return channel, nil
}

func getEventHub(client fab.FabricClient, channelID string) (*events.EventHub, error) {
func getEventHub(client fab.FabricClient, channelID string, session context.Session) (*events.EventHub, error) {

peerConfig, err := client.Config().ChannelPeers(channelID)
if err != nil {
Expand All @@ -115,7 +115,7 @@ func getEventHub(client fab.FabricClient, channelID string) (*events.EventHub, e

for _, p := range peerConfig {

if p.EventSource {
if p.EventSource && p.MspID == session.Identity().MspID() {
serverHostOverride = ""
if str, ok := p.GRPCOptions["ssl-target-name-override"].(string); ok {
serverHostOverride = str
Expand Down
15 changes: 14 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,20 @@ func (c *Config) ChannelPeers(name string) ([]apiconfig.ChannelPeer, error) {
p.TLSCACerts.Path = strings.Replace(p.TLSCACerts.Path, "$GOPATH", os.Getenv("GOPATH"), -1)
}

peer := apiconfig.ChannelPeer{PeerChannelConfig: chPeerConfig, PeerConfig: p}
var mspID string

// Find organisation/msp that peer belongs to
for _, org := range netConfig.Organizations {
for i := 0; i < len(org.Peers); i++ {
if strings.EqualFold(org.Peers[i], peerName) {
// peer belongs to this org add org msp
mspID = org.MspID
break
}
}
}

peer := apiconfig.ChannelPeer{PeerChannelConfig: chPeerConfig, PeerConfig: p, MspID: mspID}

peers = append(peers, peer)
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/fabric-client/mocks/mockconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ func (c *MockConfig) CAClientCertFile(org string) (string, error) {

//TimeoutOrDefault not implemented
func (c *MockConfig) TimeoutOrDefault(arg config.TimeoutType) time.Duration {

if arg == config.Query || arg == config.ExecuteTx {
return time.Second * 10
}
return 0
return time.Second * 10
}

// FabricClientViper returns the internal viper instance used by the
Expand Down
26 changes: 17 additions & 9 deletions pkg/fabric-txn/chclient/chclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ func (cc *ChannelClient) QueryWithOpts(request apitxn.QueryRequest, opts apitxn.
notifier = make(chan apitxn.QueryResponse)
}

peers, err := cc.discovery.GetPeers(request.ChaincodeID)
if err != nil {
return nil, fmt.Errorf("Unable to get peers: %v", err)
txProcessors := opts.ProposalProcessors
if len(txProcessors) == 0 {
// Use discovery service to figure out proposal processors
peers, err := cc.discovery.GetPeers(request.ChaincodeID)
if err != nil {
return nil, fmt.Errorf("Unable to get peers: %v", err)
}
txProcessors = peer.PeersToTxnProcessors(peers)
}

txProcessors := peer.PeersToTxnProcessors(peers)

go sendTransactionProposal(request, cc.channel, txProcessors, notifier)

if opts.Notifier != nil {
Expand Down Expand Up @@ -113,15 +116,20 @@ func (cc *ChannelClient) ExecuteTxWithOpts(request apitxn.ExecuteTxRequest, opts
return apitxn.TransactionID{}, fmt.Errorf("Chaincode name and function name must be provided")
}

peers, err := cc.discovery.GetPeers(request.ChaincodeID)
if err != nil {
return apitxn.TransactionID{}, fmt.Errorf("Unable to get peers: %v", err)
txProcessors := opts.ProposalProcessors
if len(txProcessors) == 0 {
// Use discovery service to figure out proposal processors
peers, err := cc.discovery.GetPeers(request.ChaincodeID)
if err != nil {
return apitxn.TransactionID{}, fmt.Errorf("Unable to get peers: %v", err)
}
txProcessors = peer.PeersToTxnProcessors(peers)
}

// TODO: Temporary conversion until proposal sender is changed to handle [][]byte arguments
ccArgs := toStringArray(request.Args)
txProposalResponses, txID, err := internal.CreateAndSendTransactionProposal(cc.channel,
request.ChaincodeID, request.Fcn, ccArgs, peer.PeersToTxnProcessors(peers), request.TransientMap)
request.ChaincodeID, request.Fcn, ccArgs, txProcessors, request.TransientMap)
if err != nil {
return apitxn.TransactionID{}, fmt.Errorf("CreateAndSendTransactionProposal returned error: %v", err)
}
Expand Down
120 changes: 0 additions & 120 deletions pkg/fabric-txn/transaction.go

This file was deleted.

Loading

0 comments on commit 7c71a98

Please sign in to comment.