Skip to content

Commit f2c1a47

Browse files
committed
FAB-10855 Cleanup unsupported capabilities panic msgs
This CR cleans up the panic messages when unsupported capabilities are detected. The messages were seemingly written to include simply the channel ID instead of the entire ConfigtxValidator() object. This CR also cleans up a few other error messages and a linter problem. Change-Id: I337dc6cdecc7c4ab897e414530798e5659bf85e5 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent c899926 commit f2c1a47

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

core/peer/peer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ func capabilitiesSupportedOrPanic(res channelconfig.Resources) {
130130
}
131131

132132
if err := ac.Capabilities().Supported(); err != nil {
133-
peerLogger.Panicf("[channel %s] incompatible %s", res.ConfigtxValidator(), err)
133+
peerLogger.Panicf("[channel %s] incompatible: %s", res.ConfigtxValidator().ChainID(), err)
134134
}
135135

136136
if err := res.ChannelConfig().Capabilities().Supported(); err != nil {
137-
peerLogger.Panicf("[channel %s] incompatible %s", res.ConfigtxValidator(), err)
137+
peerLogger.Panicf("[channel %s] incompatible: %s", res.ConfigtxValidator().ChainID(), err)
138138
}
139139
}
140140

@@ -232,7 +232,7 @@ func Initialize(init func(string), ccp ccprovider.ChaincodeProvider, sccp sysccp
232232
func InitChain(cid string) {
233233
if chainInitializer != nil {
234234
// Initialize chaincode, namely deploy system CC
235-
peerLogger.Debugf("Init chain %s", cid)
235+
peerLogger.Debugf("Initializing channel %s", cid)
236236
chainInitializer(cid)
237237
}
238238
}
@@ -372,13 +372,13 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block, ccp ccp
372372

373373
ordererAddresses := bundle.ChannelConfig().OrdererAddresses()
374374
if len(ordererAddresses) == 0 {
375-
return errors.New("No ordering service endpoint provided in configuration block")
375+
return errors.New("no ordering service endpoint provided in configuration block")
376376
}
377377

378378
// TODO: does someone need to call Close() on the transientStoreFactory at shutdown of the peer?
379379
store, err := TransientStoreFactory.OpenStore(bundle.ConfigtxValidator().ChainID())
380380
if err != nil {
381-
return errors.Wrapf(err, "Failed opening transient store for %s", bundle.ConfigtxValidator().ChainID())
381+
return errors.Wrapf(err, "[channel %s] failed opening transient store", bundle.ConfigtxValidator().ChainID())
382382
}
383383
csStoreSupport := &collectionSupport{
384384
PeerLedger: ledger,
@@ -413,7 +413,7 @@ func CreateChainFromBlock(cb *common.Block, ccp ccprovider.ChaincodeProvider, sc
413413

414414
var l ledger.PeerLedger
415415
if l, err = ledgermgmt.CreateLedger(cb); err != nil {
416-
return fmt.Errorf("Cannot create ledger from genesis block, due to %s", err)
416+
return errors.WithMessage(err, "cannot create ledger from genesis block")
417417
}
418418

419419
return createChain(cid, l, cb, ccp, sccp, pluginMapper)
@@ -612,15 +612,15 @@ func GetMSPIDs(cid string) []string {
612612
return nil
613613
}
614614

615-
// SetCurrConfigBlock sets the current config block of the specified chain
615+
// SetCurrConfigBlock sets the current config block of the specified channel
616616
func SetCurrConfigBlock(block *common.Block, cid string) error {
617617
chains.Lock()
618618
defer chains.Unlock()
619619
if c, ok := chains.list[cid]; ok {
620620
c.cb = block
621621
return nil
622622
}
623-
return fmt.Errorf("Chain %s doesn't exist on the peer", cid)
623+
return errors.Errorf("[channel %s] channel not associated with this peer", cid)
624624
}
625625

626626
// GetLocalIP returns the non loopback local IP of the host
@@ -724,7 +724,7 @@ func (flbs fileLedgerBlockStore) RetrieveBlocks(startBlockNumber uint64) (common
724724
return flbs.GetBlocksIterator(startBlockNumber)
725725
}
726726

727-
// NewResourceConfigSupport returns
727+
// NewConfigSupport returns
728728
func NewConfigSupport() cc.Manager {
729729
return &configSupport{}
730730
}
@@ -741,7 +741,7 @@ func (*configSupport) GetChannelConfig(channel string) cc.Config {
741741
defer chains.RUnlock()
742742
chain := chains.list[channel]
743743
if chain == nil {
744-
peerLogger.Error("GetChannelConfig: channel", channel, "not found in the list of channels associated with this peer")
744+
peerLogger.Errorf("[channel %s] channel not associated with this peer", channel)
745745
return nil
746746
}
747747
return chain.cs.bundleSource.ConfigtxValidator()

0 commit comments

Comments
 (0)