Skip to content

Commit 254d757

Browse files
committed
[FAB-14324] move GetPolicyManager to instance
Change-Id: Ieb271941e1efa67c7cf59de797746461e9683c7e Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent b02cb03 commit 254d757

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

core/peer/peer.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -454,17 +454,6 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block,
454454
return nil
455455
}
456456

457-
// GetPolicyManager returns the policy manager of the chain with chain ID. Note that this
458-
// call returns nil if chain cid has not been created.
459-
func GetPolicyManager(cid string) policies.Manager {
460-
chains.RLock()
461-
defer chains.RUnlock()
462-
if c, ok := chains.list[cid]; ok {
463-
return c.cs.PolicyManager()
464-
}
465-
return nil
466-
}
467-
468457
// updates the trusted roots for the peer based on updates to channels
469458
func updateTrustedRoots(cm channelconfig.Resources) {
470459
// this is triggered on per channel basis so first update the roots for the channel

core/peer/peer_impl.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ type Operations interface {
5252
}
5353

5454
type Peer struct {
55-
getPolicyManager func(cid string) policies.Manager
56-
initChain func(cid string)
57-
initialize func(
55+
initChain func(cid string)
56+
initialize func(
5857
init func(string),
5958
sccp sysccprovider.SystemChaincodeProvider,
6059
mapper plugin.Mapper,
@@ -72,9 +71,8 @@ type Peer struct {
7271
// Default provides in implementation of the Peer interface that provides
7372
// access to the package level state.
7473
var Default Operations = &Peer{
75-
getPolicyManager: GetPolicyManager,
76-
initChain: InitChain,
77-
initialize: Initialize,
74+
initChain: InitChain,
75+
initialize: Initialize,
7876
}
7977

8078
func CreateChainFromBlock(
@@ -205,8 +203,19 @@ func (p *Peer) GetMSPIDs(cid string) []string {
205203
return nil
206204
}
207205

208-
func (p *Peer) GetPolicyManager(cid string) policies.Manager { return p.getPolicyManager(cid) }
209-
func (p *Peer) InitChain(cid string) { p.initChain(cid) }
206+
// GetPolicyManager returns the policy manager of the chain with chain ID. Note that this
207+
// call returns nil if chain cid has not been created.
208+
func GetPolicyManager(cid string) policies.Manager { return Default.GetPolicyManager(cid) }
209+
func (p *Peer) GetPolicyManager(cid string) policies.Manager {
210+
chains.RLock()
211+
defer chains.RUnlock()
212+
if c, ok := chains.list[cid]; ok {
213+
return c.cs.PolicyManager()
214+
}
215+
return nil
216+
}
217+
218+
func (p *Peer) InitChain(cid string) { p.initChain(cid) }
210219

211220
func (p *Peer) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
212221
cc := p.GetChannelConfig(cid)

0 commit comments

Comments
 (0)