Skip to content

Commit

Permalink
[FAB-8300] Remove unused Channel from ChannelService
Browse files Browse the repository at this point in the history
Change-Id: I5200e1b71c272fe3626d180485aebca6bdba4f7f
Signed-off-by: Divyank Katira <Divyank.Katira@securekey.com>
  • Loading branch information
d1vyank committed Feb 27, 2018
1 parent 0f74d53 commit 54c4ba0
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 47 deletions.
1 change: 0 additions & 1 deletion pkg/context/api/fab/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import "github.com/hyperledger/fabric-sdk-go/pkg/context"
type ChannelService interface {
Config() (ChannelConfig, error)
Ledger() (ChannelLedger, error)
Channel() (Channel, error) // TODO remove
Transactor() (Transactor, error)
EventHub() (EventHub, error) // TODO support new event delivery
Membership() (ChannelMembership, error)
Expand Down
1 change: 0 additions & 1 deletion pkg/fabsdk/api/pvdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

// FabricProvider enables access to fabric objects such as peer and user based on config or
type FabricProvider interface {
CreateChannelClient(user context.IdentityContext, cfg fab.ChannelCfg) (fab.Channel, error)
CreateChannelLedger(ic context.IdentityContext, name string) (fab.ChannelLedger, error)
CreateChannelConfig(user context.IdentityContext, name string) (fab.ChannelConfig, error)
CreateResourceClient(user context.IdentityContext) (api.Resource, error)
Expand Down
5 changes: 0 additions & 5 deletions pkg/fabsdk/provider/chpvdr/chprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ type ChannelService struct {
cfg fab.ChannelCfg
}

// Channel returns the named Channel client.
func (cs *ChannelService) Channel() (fab.Channel, error) {
return cs.fabricProvider.CreateChannelClient(cs.identityContext, cs.cfg)
}

// EventHub returns the EventHub for the named channel.
func (cs *ChannelService) EventHub() (fab.EventHub, error) {
return cs.fabricProvider.CreateEventHub(cs.identityContext, cs.cfg.Name())
Expand Down
10 changes: 0 additions & 10 deletions pkg/fabsdk/provider/chpvdr/chprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,12 @@ func TestBasicValidChannel(t *testing.T) {
t.Fatalf("Unexpected error creating Channel Service: %v", err)
}

_, err = channelService.Channel()
if err != nil {
t.Fatalf("Unexpected error creating Channel Service: %v", err)
}

// System channel
channelService, err = cp.ChannelService(user, "")
if err != nil {
t.Fatalf("Unexpected error creating Channel Service: %v", err)
}

_, err = channelService.Channel()
if err != nil {
t.Fatalf("Unexpected error creating Channel Service: %v", err)
}

m, err := channelService.Membership()
assert.Nil(t, err)
assert.NotNil(t, m)
Expand Down
14 changes: 0 additions & 14 deletions pkg/fabsdk/provider/fabpvdr/fabpvdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,6 @@ func (f *FabricProvider) CreateResourceClient(ic context.IdentityContext) (api.R
return client, nil
}

// CreateChannelClient returns a new client initialized for the current instance of the SDK.
func (f *FabricProvider) CreateChannelClient(ic context.IdentityContext, cfg fab.ChannelCfg) (fab.Channel, error) {
ctx := &fabContext{
ProviderContext: f.providerContext,
IdentityContext: ic,
}
channel, err := channelImpl.New(ctx, cfg)
if err != nil {
return nil, errors.WithMessage(err, "NewChannel failed")
}

return channel, nil
}

// CreateChannelLedger returns a new client initialized for the current instance of the SDK.
func (f *FabricProvider) CreateChannelLedger(ic context.IdentityContext, channelName string) (fab.ChannelLedger, error) {
ctx := &fabContext{
Expand Down
16 changes: 0 additions & 16 deletions pkg/fabsdk/provider/fabpvdr/fabpvdr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
"github.com/hyperledger/fabric-sdk-go/pkg/core/cryptosuite/bccsp/sw"
channelImpl "github.com/hyperledger/fabric-sdk-go/pkg/fab/channel"
identityImpl "github.com/hyperledger/fabric-sdk-go/pkg/fab/identity"
"github.com/hyperledger/fabric-sdk-go/pkg/fab/identitymgr"
"github.com/hyperledger/fabric-sdk-go/pkg/fab/mocks"
Expand All @@ -27,21 +26,6 @@ func TestCreateFabricProvider(t *testing.T) {
newMockFabricProvider(t)
}

func TestCreateChannelClient(t *testing.T) {
p := newMockFabricProvider(t)

user := mocks.NewMockUser("user")
client, err := p.CreateChannelClient(user, mocks.NewMockChannelCfg("mychannel"))
if err != nil {
t.Fatalf("Unexpected error creating client %v", err)
}

_, ok := client.(*channelImpl.Channel)
if !ok {
t.Fatalf("Unexpected client impl created: %v", client)
}
}

func TestCreateResourceClient(t *testing.T) {
p := newMockFabricProvider(t)

Expand Down

0 comments on commit 54c4ba0

Please sign in to comment.