Skip to content

Commit

Permalink
[FAB-5946] Restore policies sanity check logging
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jason Yellick committed Aug 30, 2017
1 parent 10d340c commit 2bcc04a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ SPDX-License-Identifier: Apache-2.0

package channelconfig

// TODO, move this code elsewhere
/*
if ppr.initializationLogSuppression {
ppr.initializationLogSuppression = false
}
import (
"github.com/hyperledger/fabric/common/policies"
)

pm := ppr.policyManager
func LogSanityChecks(res Resources) {
pm := res.PolicyManager()
for _, policyName := range []string{policies.ChannelReaders, policies.ChannelWriters} {
_, ok := pm.GetPolicy(policyName)
if !ok {
Expand Down Expand Up @@ -45,4 +44,4 @@ package channelconfig
}
}
}
*/
}
5 changes: 5 additions & 0 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (cs *chainSupport) Apply(configtx *common.ConfigEnvelope) error {
if err != nil {
return err
}

channelconfig.LogSanityChecks(bundle)

err = cs.bundleSource.ValidateNew(bundle)
if err != nil {
return err
Expand Down Expand Up @@ -217,6 +220,8 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
return err
}

channelconfig.LogSanityChecks(bundle)

gossipEventer := service.GetGossipService().NewConfigEventer()

gossipCallbackWrapper := func(bundle *channelconfig.Bundle) {
Expand Down
6 changes: 6 additions & 0 deletions orderer/common/multichannel/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (cr *configResources) CreateBundle(channelID string, config *cb.Config) (*c
return channelconfig.NewBundle(channelID, config)
}

func (cr *configResources) Update(bndl *channelconfig.Bundle) {
channelconfig.LogSanityChecks(bndl)
cr.mutableResources.Update(bndl)
}

func (cr *configResources) SharedConfig() channelconfig.Orderer {
oc, ok := cr.OrdererConfig()
if !ok {
Expand Down Expand Up @@ -219,6 +224,7 @@ func (r *Registrar) newLedgerResources(configTx *cb.Envelope) *ledgerResources {
if err != nil {
logger.Panicf("Error creating channelconfig bundle: %s", err)
}
channelconfig.LogSanityChecks(bundle)

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

0 comments on commit 2bcc04a

Please sign in to comment.