예제 #1
0
// GetMSPManagerFromBlock returns a new MSP manager from a ConfigurationEnvelope
func GetMSPManagerFromBlock(b *common.Block) (msp.MSPManager, error) {
	mgrConfig, err := msputils.GetMSPManagerConfigFromBlock(b)
	if err != nil {
		return nil, err
	}

	mgr := msp.NewMSPManager()
	err = mgr.Setup(mgrConfig)
	if err != nil {
		return nil, err
	}

	return mgr, nil
}
예제 #2
0
파일: mgmt.go 프로젝트: hyperledger/fabric
// GetManagerForChain returns the msp manager for the supplied
// chain; if no such manager exists, one is created
func GetManagerForChain(ChainID string) msp.MSPManager {
	var mspMgr msp.MSPManager
	var created bool = false
	{
		m.Lock()
		defer m.Unlock()

		mspMgr = mspMap[ChainID]
		if mspMgr == nil {
			created = true
			mspMgr = msp.NewMSPManager()
			mspMap[ChainID] = mspMgr
		}
	}

	if created {
		peerLogger.Infof("Created new msp manager for chain %s", ChainID)
	} else {
		peerLogger.Infof("Returinging existing manager for chain %s", ChainID)
	}

	return mspMgr
}