From 376021a0f59848643add323f3b07f3a7d33aecc5 Mon Sep 17 00:00:00 2001 From: Srinivasan Muralidharan Date: Sun, 22 Jan 2017 11:51:48 -0500 Subject: [PATCH] FAB-1800 peer should not load channel with bad config https://jira.hyperledger.org/browse/FAB-1800 peer should stop loading the channel but continue to load the next chain. Also added a panic to the system chaincode if there's no ledger registered with the chain. Change-Id: Ia581c70c636c3be21fbb05e9cd01fafe36c91b09 Signed-off-by: Srinivasan Muralidharan --- core/chaincode/sysccapi.go | 3 +++ core/peer/peer.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/chaincode/sysccapi.go b/core/chaincode/sysccapi.go index c3706e6669b..7a789104f26 100644 --- a/core/chaincode/sysccapi.go +++ b/core/chaincode/sysccapi.go @@ -99,6 +99,9 @@ func deploySysCC(chainID string, syscc *SystemChaincode) error { ctxt := context.Background() if !syscc.ChainlessCC { lgr := peer.GetLedger(chainID) + if lgr == nil { + panic(fmt.Sprintf("syschain %s start up failure - unexpected nil ledger for channel %s", syscc.Name, chainID)) + } var txsim ledger.TxSimulator if txsim, err = lgr.NewTxSimulator(); err != nil { return err diff --git a/core/peer/peer.go b/core/peer/peer.go index b37461ca6d3..a39afefd983 100644 --- a/core/peer/peer.go +++ b/core/peer/peer.go @@ -92,8 +92,9 @@ func Initialize(dsProvider func(string) error) { } // Create a chain if we get a valid ledger with config block if err = createChain(cid, ledger, cb); err != nil { - peerLogger.Warning("Failed to load chain %s", cid) + peerLogger.Warningf("Failed to load chain %s(%s)", cid, err) peerLogger.Debug("Error reloading chain %s with message %s. We continue to the next chain rather than abort.", cid, err) + continue } // now create the delivery service for this chain