2016-08-20 126 views
1

我试图通过遵循Windows安装程序在我的笔记本电脑上设置Hyperledger blocchain,能够启动docker映像并运行,但是当我尝试部署提供的示例时,它总是抛出JSON输入中的错误,如下所示。HyperLedger-Fabric ChainCode部署 - Base64错误

peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' 

响应:

[email protected]:~/go/$ docker exec -it aa413f4c4289 bash 
[email protected]:/opt/gopath/src/github.com/hyperledger/fabric# peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' 

04:30:55.822 [logging] LoggingInit -> DEBU 001 Setting default logging level to DEBUG for command 'chaincode' Error: Non-empty JSON chaincode parameters must contain exactly 1 key: 'Args' 

我在邮差试图从主机:

​​

得到的回应作为

{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"}," 

这类似于错误消息我无法解决这个问题l,根据建议创建一个新帖子,请帮我解决这个问题。

Similar issue reported but that also doesn't answer

回答

2

在最新面料的版本请求的格式改变。函数名称应该在Args中,所有参数都应该是base64编码的。
相反的:

{"function":"init","args":["a", "1000", "b", "2000"]}}

的部署命令的参数看起来像:

{"args":['aW5pdA==', 'YQ==', 'MTAwMA==', 'Yg==', 'MjAwMA==']}

更新:格式再被更改了。 Base64编码不再需要。在最新的面料正确的有效载荷是:

{“args”:['init', 'a', '100', 'b', '100']}

+0

非常感谢谢尔盖!,它的工作的罚款。下面是实际的代码 '{ “jsonrpc”: “2.0”, “方法”: “部署”, “PARAMS”:{ “类型”:1, “chaincodeID”:{ “路径” :“github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02” }, “ctorMsg”:{ “args”:[“aW5pdA ==”,“YQ ==”,“MTAwMA ==” “YG ==”, “MjAwMA ==”] } }, “ID”:1 }' – Logumay

+1

塞吉,我看到两个格式支持: '{ “功能”: “初始化”, “args”:[“a”,“1000”,“b”,“2000”]}}' as '{“args”:[“init”,“a”,“1000”,“b”,“2000”]}}' – Mil4n

+0

@ Mil4n嗯,那是对的。它看起来像现在支持这两种格式。只用“函数,参数”和“参数”进行了测试,两个请求都被接受。谢谢你的信息。 –