Skip to content

Commit 2bcc04a

Browse files
author
Jason Yellick
committed
[FAB-5946] Restore policies sanity check logging
As part of the channel config refactor, the policies sanity check logging was disabled. This CR adds it back as a utility method and invokes it whenever channel config is set. Change-Id: Ie01fac36d583ff0201a0aa10ce184511b1190554 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 10d340c commit 2bcc04a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

common/channelconfig/initializer.go renamed to common/channelconfig/logsanitychecks.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ SPDX-License-Identifier: Apache-2.0
66

77
package channelconfig
88

9-
// TODO, move this code elsewhere
10-
/*
11-
if ppr.initializationLogSuppression {
12-
ppr.initializationLogSuppression = false
13-
}
9+
import (
10+
"github.com/hyperledger/fabric/common/policies"
11+
)
1412

15-
pm := ppr.policyManager
13+
func LogSanityChecks(res Resources) {
14+
pm := res.PolicyManager()
1615
for _, policyName := range []string{policies.ChannelReaders, policies.ChannelWriters} {
1716
_, ok := pm.GetPolicy(policyName)
1817
if !ok {
@@ -45,4 +44,4 @@ package channelconfig
4544
}
4645
}
4746
}
48-
*/
47+
}

core/peer/peer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func (cs *chainSupport) Apply(configtx *common.ConfigEnvelope) error {
8484
if err != nil {
8585
return err
8686
}
87+
88+
channelconfig.LogSanityChecks(bundle)
89+
8790
err = cs.bundleSource.ValidateNew(bundle)
8891
if err != nil {
8992
return err
@@ -217,6 +220,8 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
217220
return err
218221
}
219222

223+
channelconfig.LogSanityChecks(bundle)
224+
220225
gossipEventer := service.GetGossipService().NewConfigEventer()
221226

222227
gossipCallbackWrapper := func(bundle *channelconfig.Bundle) {

orderer/common/multichannel/registrar.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func (cr *configResources) CreateBundle(channelID string, config *cb.Config) (*c
4646
return channelconfig.NewBundle(channelID, config)
4747
}
4848

49+
func (cr *configResources) Update(bndl *channelconfig.Bundle) {
50+
channelconfig.LogSanityChecks(bndl)
51+
cr.mutableResources.Update(bndl)
52+
}
53+
4954
func (cr *configResources) SharedConfig() channelconfig.Orderer {
5055
oc, ok := cr.OrdererConfig()
5156
if !ok {
@@ -219,6 +224,7 @@ func (r *Registrar) newLedgerResources(configTx *cb.Envelope) *ledgerResources {
219224
if err != nil {
220225
logger.Panicf("Error creating channelconfig bundle: %s", err)
221226
}
227+
channelconfig.LogSanityChecks(bundle)
222228

223229
ledger, err := r.ledgerFactory.GetOrCreate(chdr.ChannelId)
224230
if err != nil {

0 commit comments

Comments
 (0)