【发布时间】:2021-10-18 12:08:27
【问题描述】:
我目前在同一个频道上提交了两个智能合约定义。两者都是用 Go 编写的,有些基础,只做基本的 CRUD 操作。但是,我注意到用一个链码编写的键/值对对另一个链码不可用。
所以,我使用go-audit 创建了以下记录:
然后,我尝试使用链码 go-asset 对密钥 ping 执行获取操作,但未找到以下错误(由链码返回)
bad request: failed to invoke go-asset: Error: No valid responses from any peers. Errors: **someurl***, status=500, message=the asset ping does not exist.
这是这样的交易:
func (c *GoAssetContract) ReadGoAsset(ctx contractapi.TransactionContextInterface, goAssetID string) (*GoAsset, error) {
exists, err := c.GoAssetExists(ctx, hlpAssetID)
if err != nil {
return nil, fmt.Errorf("could not read from world state. %s", err)
} else if !exists {
return nil, fmt.Errorf("the asset %s does not exist", goAssetID)
}
bytes, _ := ctx.GetStub().GetState(goAssetID)
goAsset := new(GoAsset)
err = json.Unmarshal(bytes, goAsset)
if err != nil {
return nil, fmt.Errorf("could not unmarshal world state data to type GoAsset")
}
return GoAsset, nil
}
和 GoAsset 结构
// GoAsset stores a value
type GoAsset struct {
Value string `json:"value"`
}
世界状态不应该对通道上批准/提交的所有链码都可用吗?
【问题讨论】:
标签: hyperledger-fabric hyperledger-chaincode