第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在Fabric SDK Go中添加集合配置?

如何在Fabric SDK Go中添加集合配置?

Go
aluckdog 2023-07-04 10:03:22
我正在使用 Fabric SDK Go 將私有數(shù)據(jù)添加到 Hyperledger 中,但在調(diào)用數(shù)據(jù)時(shí)出現(xiàn)錯(cuò)誤。實(shí)例化鏈碼ccPolicy, err := cauthdsl.FromString("AND ('Org1MSP.member','Org2MSP.member')")resMgmt.InstantiateCC(    setup.Org.ChannelID,    resmgmt.InstantiateCCRequest{        Name:    chaincodeId,        Path:    setup.Org.ChaincodePath,        Version: chaincodeVersion,        Args:    [][]byte{[]byte("init")},        Policy:  ccPolicy,    },resmgmt.WithRetry(retry.DefaultResMgmtOpts))集合配置.json[   {       "name": "collectionMedium",       "policy": "AND ('Org1MSP.member', 'Org2MSP.member')",       "requiredPeerCount": 0,       "maxPeerCount": 3,       "blockToLive":1000000   },   {       "name": "collectionPrivate",       "policy": "OR('Org2MSP.member')",       "requiredPeerCount": 0,       "maxPeerCount": 3,       "blockToLive":5   }]調(diào)用product := &model.Product{id, name, color, length, width}productBytes, err1 := json.Marshal(product)if err1 != nil {    return shim.Error(err1.Error())}   err2 := stub.PutPrivateData("collectionMedium", id, productBytes)if err2 != nil {    return shim.Error(err2.Error())}錯(cuò)誤Chaincode status Code: (500) UNKNOWN. Description: PUT_STATE failed: collection config not defined for chaincode [CC_ORG_V00], pass the collection configuration upon chaincode definition/instantiation因此,它表示在鏈碼實(shí)例化期間未定義集合配置。但是,我不知道如何在鏈代碼實(shí)例化請(qǐng)求中添加集合配置。請(qǐng)建議我解決方案。
查看完整描述

1 回答

?
炎炎設(shè)計(jì)

TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊

我能夠通過以下方式創(chuàng)建 CollConfig 請(qǐng)求,并能夠?qū)⒓吓渲锰砑拥轿业逆湸a實(shí)例化中。


我的解決方案


#CollConfig 1


var collCfg1RequiredPeerCount, collCfg1MaximumPeerCount int32

var collCfg1BlockToLive uint64


collCfg1Name              := "collectionMedium"

collCfg1BlockToLive       = 1000

collCfg1RequiredPeerCount = 0

collCfg1MaximumPeerCount  = 3

collCfg1Policy            := "OR('Org1MSP.member','Org2MSP.member')"


collCfg1, err := newCollectionConfig(collCfg1Name,collCfg1Policy, collCfg1RequiredPeerCount,collCfg1MaximumPeerCount,collCfg1BlockToLive)


if err != nil {

    return errors.WithMessage(err, "failed to create collection config 1")

}

#CollConfig 2


var collCfg2RequiredPeerCount, collCfg2MaximumPeerCount int32

var collCfg2BlockToLive uint64 


collCfg2Name              := "collectionPrivate"

collCfg2BlockToLive       = 100

collCfg2RequiredPeerCount = 0

collCfg2MaximumPeerCount  = 3

collCfg2Policy            := "OR('Org2MSP.member')"


collCfg2, err := newCollectionConfig(collCfg2Name,collCfg2Policy, collCfg2RequiredPeerCount,collCfg2MaximumPeerCount,collCfg2BlockToLive)


if err != nil {

    return errors.WithMessage(err, "failed to create collection config 1")

}

# 實(shí)例化鏈碼


 cfg := []*cb.CollectionConfig{collCfg1,collCfg2}


resp, err := resMgmt.InstantiateCC(

    setup.Org.ChannelID,

    resmgmt.InstantiateCCRequest{


        Name:    chaincodeId,

        Path:    setup.Org.ChaincodePath,

        Version: chaincodeVersion,

        Args:    [][]byte{[]byte("init")},

        Policy:  ccPolicy,

        CollConfig: cfg,


},resmgmt.WithRetry(retry.DefaultResMgmtOpts))

#CollConfig 創(chuàng)建請(qǐng)求方法


func newCollectionConfig(colName, policy string, reqPeerCount, maxPeerCount int32, 


blockToLive uint64) (*cb.CollectionConfig, error) {

    p, err := cauthdsl.FromString(policy)

    if err != nil {

        return nil, err

    }

    cpc := &cb.CollectionPolicyConfig{

        Payload: &cb.CollectionPolicyConfig_SignaturePolicy{

            SignaturePolicy: p,

        },

    }

    return &cb.CollectionConfig{

        Payload: &cb.CollectionConfig_StaticCollectionConfig{

            StaticCollectionConfig: &cb.StaticCollectionConfig{

                Name:              colName,

                MemberOrgsPolicy:  cpc,

                RequiredPeerCount: reqPeerCount,

                MaximumPeerCount:  maxPeerCount,

                BlockToLive:       blockToLive,

            },

        },

    }, nil }


查看完整回答
反對(duì) 回復(fù) 2023-07-04
  • 1 回答
  • 0 關(guān)注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)