Skip to content

Commit

Permalink
[FAB-14324] remove peer.Support
Browse files Browse the repository at this point in the history
The "Support" interface and "supportImpl" are unnecessary.

Change-Id: I79d566f7604aec52cbc9bc85463bcbca37f42803
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed Jun 4, 2019
1 parent 5033e2f commit 42b6cd8
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 122 deletions.
27 changes: 11 additions & 16 deletions core/chaincode/chaincode_support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/hyperledger/fabric/core/container/inproccontroller"
"github.com/hyperledger/fabric/core/ledger"
ledgermock "github.com/hyperledger/fabric/core/ledger/mock"
cmp "github.com/hyperledger/fabric/core/mocks/peer"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/core/policy"
"github.com/hyperledger/fabric/core/scc"
Expand Down Expand Up @@ -152,21 +151,11 @@ func (p *PackageProviderWrapper) GetChaincodeCodePackage(ccci *ccprovider.Chainc

//initialize peer and start up. If security==enabled, login as vp
func initMockPeer(chainIDs ...string) (*ChaincodeSupport, func(), error) {
fakeApplicationConfig := &mock.ApplicationConfig{}
capabilities := &mock.ApplicationCapabilities{}
capabilities.LifecycleV20Returns(false)
fakeApplicationConfig.CapabilitiesReturns(capabilities)
msi := &cmp.MockSupportImpl{
GetApplicationConfigRv: fakeApplicationConfig,
GetApplicationConfigBoolRv: true,
}

ipRegistry := inproccontroller.NewRegistry()
sccp := &scc.Provider{
Peer: peer.Default,
PeerSupport: msi,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
Peer: peer.Default,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
}

ledgerCleanup, err := peer.MockInitialize()
Expand Down Expand Up @@ -257,7 +246,7 @@ func initMockPeer(chainIDs ...string) (*ChaincodeSupport, func(), error) {
}
chaincodeSupport := &ChaincodeSupport{
ACLProvider: mockAclProvider,
AppConfig: peer.DefaultSupport,
AppConfig: peer.Default,
DeployedCCInfoProvider: &ledgermock.DeployedChaincodeInfoProvider{},
ExecuteTimeout: globalConfig.ExecuteTimeout,
HandlerMetrics: NewHandlerMetrics(metricsProviders),
Expand Down Expand Up @@ -1113,7 +1102,13 @@ func TestStartAndWaitLaunchError(t *testing.T) {
}

func TestGetTxContextFromHandler(t *testing.T) {
h := Handler{TXContexts: NewTransactionContexts(), SystemCCProvider: &scc.Provider{Peer: peer.Default, PeerSupport: peer.DefaultSupport, Registrar: inproccontroller.NewRegistry()}}
h := Handler{
TXContexts: NewTransactionContexts(),
SystemCCProvider: &scc.Provider{
Peer: peer.Default,
Registrar: inproccontroller.NewRegistry(),
},
}

chnl := "test"
txid := "1"
Expand Down
19 changes: 4 additions & 15 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
"github.com/hyperledger/fabric/core/ledger"
ledgermock "github.com/hyperledger/fabric/core/ledger/mock"
cut "github.com/hyperledger/fabric/core/ledger/util"
cmp "github.com/hyperledger/fabric/core/mocks/peer"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/core/policy"
"github.com/hyperledger/fabric/core/policy/mocks"
Expand All @@ -71,21 +70,11 @@ func initPeer(chainIDs ...string) (*cm.Lifecycle, net.Listener, *ChaincodeSuppor
//start clean
finitPeer(nil, chainIDs...)

fakeApplicationConfig := &cm.ApplicationConfig{}
fakeCapabilites := &cm.ApplicationCapabilities{}
fakeApplicationConfig.CapabilitiesReturns(fakeCapabilites)

msi := &cmp.MockSupportImpl{
GetApplicationConfigRv: fakeApplicationConfig,
GetApplicationConfigBoolRv: true,
}

ipRegistry := inproccontroller.NewRegistry()
sccp := &scc.Provider{
Peer: peer.Default,
PeerSupport: msi,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
Peer: peer.Default,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
}

ledgerCleanup, err := peer.MockInitialize()
Expand Down Expand Up @@ -191,7 +180,7 @@ func initPeer(chainIDs ...string) (*cm.Lifecycle, net.Listener, *ChaincodeSuppor
}
chaincodeSupport := &ChaincodeSupport{
ACLProvider: aclmgmt.NewACLProvider(func(string) channelconfig.Resources { return nil }),
AppConfig: peer.DefaultSupport,
AppConfig: peer.Default,
DeployedCCInfoProvider: &ledgermock.DeployedChaincodeInfoProvider{},
ExecuteTimeout: globalConfig.ExecuteTimeout,
HandlerMetrics: NewHandlerMetrics(metricsProviders),
Expand Down
3 changes: 1 addition & 2 deletions core/endorser/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type SupportImpl struct {
*PluginEndorser
identity.SignerSerializer
Peer peer.Operations
PeerSupport peer.Support
ChaincodeSupport *chaincode.ChaincodeSupport
SysCCProvider *scc.Provider
ACLProvider aclmgmt.ACLProvider
Expand Down Expand Up @@ -184,7 +183,7 @@ func (s *SupportImpl) CheckInstantiationPolicy(name, version string, cd ccprovid
// GetApplicationConfig returns the configtxapplication.SharedConfig for the Channel
// and whether the Application config exists
func (s *SupportImpl) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
return s.PeerSupport.GetApplicationConfig(cid)
return s.Peer.GetApplicationConfig(cid)
}

// GetDeployedCCInfoProvider returns ledger.DeployedChaincodeInfoProvider
Expand Down
36 changes: 0 additions & 36 deletions core/mocks/peer/support.go

This file was deleted.

29 changes: 25 additions & 4 deletions core/peer/peer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type Operations interface {
CreateChainFromBlock(cb *common.Block, sccp sysccprovider.SystemChaincodeProvider, deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider, lr plugindispatcher.LifecycleResources, nr plugindispatcher.CollectionAndLifecycleResources) error
GetChannelConfig(cid string) channelconfig.Resources
GetApplicationConfig(cid string) (channelconfig.Application, bool)
GetChannelsInfo() []*pb.ChannelInfo
GetStableChannelConfig(cid string) channelconfig.Resources
GetCurrConfigBlock(cid string) *common.Block
Expand Down Expand Up @@ -87,23 +88,43 @@ var Default Operations = &peerImpl{
initialize: Initialize,
}

var DefaultSupport Support = &supportImpl{operations: Default}

func (p *peerImpl) CreateChainFromBlock(cb *common.Block, sccp sysccprovider.SystemChaincodeProvider, deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider, lr plugindispatcher.LifecycleResources, nr plugindispatcher.CollectionAndLifecycleResources) error {
func (p *peerImpl) CreateChainFromBlock(
cb *common.Block,
sccp sysccprovider.SystemChaincodeProvider,
deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider,
lr plugindispatcher.LifecycleResources,
nr plugindispatcher.CollectionAndLifecycleResources,
) error {
return p.createChainFromBlock(cb, sccp, deployedCCInfoProvider, lr, nr)
}

func (p *peerImpl) GetChannelConfig(cid string) channelconfig.Resources {
return p.getChannelConfig(cid)
}
func (p *peerImpl) GetChannelsInfo() []*pb.ChannelInfo { return p.getChannelsInfo() }

func (p *peerImpl) GetChannelsInfo() []*pb.ChannelInfo {
return p.getChannelsInfo()
}

func (p *peerImpl) GetStableChannelConfig(cid string) channelconfig.Resources {
return p.getStableChannelConfig(cid)
}

func (p *peerImpl) GetCurrConfigBlock(cid string) *common.Block { return p.getCurrConfigBlock(cid) }
func (p *peerImpl) GetLedger(cid string) ledger.PeerLedger { return p.getLedger(cid) }
func (p *peerImpl) GetMSPIDs(cid string) []string { return p.getMSPIDs(cid) }
func (p *peerImpl) GetPolicyManager(cid string) policies.Manager { return p.getPolicyManager(cid) }
func (p *peerImpl) InitChain(cid string) { p.initChain(cid) }

func (p *peerImpl) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
cc := p.GetChannelConfig(cid)
if cc == nil {
return nil, false
}

return cc.ApplicationConfig()
}

func (p *peerImpl) Initialize(
init func(string),
sccp sysccprovider.SystemChaincodeProvider,
Expand Down
31 changes: 0 additions & 31 deletions core/peer/support.go

This file was deleted.

10 changes: 4 additions & 6 deletions core/scc/scc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ func init() {

func newTestProvider() *Provider {
p := &Provider{
Peer: peer.Default,
PeerSupport: peer.DefaultSupport,
Registrar: inproccontroller.NewRegistry(),
Peer: peer.Default,
Registrar: inproccontroller.NewRegistry(),
Whitelist: map[string]bool{
"invokableExternalButNotCC2CC": true,
"invokableCC2CCButNotExternal": true,
Expand Down Expand Up @@ -112,9 +111,8 @@ func TestIsSysCCAndNotInvokableExternal(t *testing.T) {

func TestSccProviderImpl_GetQueryExecutorForLedger(t *testing.T) {
p := &Provider{
Peer: peer.Default,
PeerSupport: peer.DefaultSupport,
Registrar: inproccontroller.NewRegistry(),
Peer: peer.Default,
Registrar: inproccontroller.NewRegistry(),
}
qe, err := p.GetQueryExecutorForLedger("")
assert.Nil(t, qe)
Expand Down
11 changes: 5 additions & 6 deletions core/scc/sccproviderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import (

// Provider implements sysccprovider.SystemChaincodeProvider
type Provider struct {
Peer peer.Operations
PeerSupport peer.Support
Registrar Registrar
SysCCs []SelfDescribingSysCC
Whitelist Whitelist
Peer peer.Operations
Registrar Registrar
SysCCs []SelfDescribingSysCC
Whitelist Whitelist
}

// RegisterSysCC registers a system chaincode with the syscc provider.
Expand Down Expand Up @@ -93,7 +92,7 @@ func (p *Provider) IsSysCCAndNotInvokableExternal(name string) bool {
// GetApplicationConfig returns the configtxapplication.SharedConfig for the channel
// and whether the Application config exists
func (p *Provider) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
return p.PeerSupport.GetApplicationConfig(cid)
return p.Peer.GetApplicationConfig(cid)
}

// Returns the policy manager associated to the passed channel
Expand Down
10 changes: 4 additions & 6 deletions internal/peer/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,9 @@ func serve(args []string) error {
ipRegistry := inproccontroller.NewRegistry()

sccp := &scc.Provider{
Peer: peer.Default,
PeerSupport: peer.DefaultSupport,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
Peer: peer.Default,
Registrar: ipRegistry,
Whitelist: scc.GlobalWhitelist(),
}
lsccInst := lscc.New(sccp, aclProvider, platformRegistry)

Expand Down Expand Up @@ -450,7 +449,7 @@ func serve(args []string) error {

chaincodeSupport := &chaincode.ChaincodeSupport{
ACLProvider: aclProvider,
AppConfig: peer.DefaultSupport,
AppConfig: peer.Default,
DeployedCCInfoProvider: lifecycleValidatorCommitter,
ExecuteTimeout: globalConfig.ExecuteTimeout,
HandlerRegistry: chaincodeHandlerRegistry,
Expand Down Expand Up @@ -505,7 +504,6 @@ func serve(args []string) error {
endorserSupport := &endorser.SupportImpl{
SignerSerializer: signingIdentity,
Peer: peer.Default,
PeerSupport: peer.DefaultSupport,
ChaincodeSupport: chaincodeSupport,
SysCCProvider: sccp,
ACLProvider: aclProvider,
Expand Down
Loading

0 comments on commit 42b6cd8

Please sign in to comment.