代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import (
"sync"
"github.com/hyperledger/fabric/protos/gossip"
)
// InstalledChaincode defines metadata about an installed chaincode
type InstalledChaincode struct {
Name string
Version string
Id []byte
}
// Metadata defines channel-scoped metadata of a chaincode
type Metadata struct {
Name string
Version string
Policy []byte
Id []byte
CollectionsConfig []byte
}
// MetadataSet defines an aggregation of Metadata
type MetadataSet []Metadata
// AsChaincodes converts this MetadataSet to a slice of gossip.Chaincodes
func (ccs MetadataSet) AsChaincodes() []*gossip.Chaincode {
var res []*gossip.Chaincode
for _, cc := range ccs {
res = append(res, &gossip.Chaincode{
Name: cc.Name,
Version: cc.Version,
})
}
return res
}
// MetadataMapping defines a mapping from chaincode name to Metadata
type MetadataMapping struct {
sync.RWMutex
mdByName map[string]Metadata
}
// NewMetadataMapping creates a new metadata mapping
func NewMetadataMapping() *MetadataMapping {
return &MetadataMapping{
mdByName: make(map[string]Metadata),
}
}
// Lookup returns the Metadata that is associated with the given chaincode
func (m *MetadataMapping) Lookup(cc string) (Metadata, bool) {
m.RLock()
defer m.RUnlock()
md, exists := m.mdByName[cc]
return md, exists
}
// Update updates the chaincode metadata in the mapping
func (m *MetadataMapping) Update(ccMd Metadata) {
m.Lock()
defer m.Unlock()
m.mdByName[ccMd.Name] = ccMd
}
// Aggregate aggregates all Metadata to a MetadataSet
func (m *MetadataMapping) Aggregate() MetadataSet {
m.RLock()
defer m.RUnlock()
var set MetadataSet
for _, md := range m.mdByName {
set = append(set, md)
}
return set
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。