问题描述
主要问题是从客户端的角度获取负载错误。
基本设置:
Fabric 链码 -> 使用 Fabric-chaincode-shim 用 Java 实现:v2.3.0
应用程序客户端 -> 使用 Fabric-network: 2.2.5 在 Typescript 中实现。
实现的每个事务都可以正常工作,但我想知道如何实现客户端应该可读的 error_codes。
当我抛出 ChaincodeException 时,负载如下,然后我从客户端应用程序的角度获得了空缓冲区属性。
从链码的角度来看示例代码:
public void createAsset(final Context ctx,String createAssetDto) {
throw new ChaincodeException("Sample message","SamplePayloadWithSpecifiedCode");
}
从应用程序客户端角度的示例代码:
try {
await contract.submitTransaction('createAsset',JSON.stringify(createAssetDto));
success = true;
} catch (err) {
logException(err);
success = false;
}
我注意到在对等实现中有一个函数将 ChaincodeMessage 解析为错误
case pb.ChaincodeMessage_ERROR:
return nil,resp.ChaincodeEvent,errors.Errorf("transaction returned with failure: %s",resp.Payload)
从同行的角度来看日志:
failed to invoke chaincode ecmr,error: transaction returned with failure: Sample Message
github.com/hyperledger/fabric/core/chaincode.processChaincodeExecutionResult
/go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:182
从这个角度来看,它意味着 ChaincodeException 消息是有效负载。
从客户端的角度来看错误有:
{
status: 500,message: "error in simulation: transaction returned with failure: Sample Message",payload: {
},}
我认为我应该在 response.payload 属性中得到“SamplePayloadWithSpecifiedCode”。
我已经在源代码中找到了可能的地方,在 java 链码实现中,消息被设置为来自 ChaincodeException 的有效负载:
欢迎任何建议。谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)