通过REST在hyperledger上部署链代码时“获取链代码包字节时出错”

时间:2016-10-21 07:53:45

标签: ibm-cloud blockchain hyperledger hyperledger-fabric

我正在尝试通过POST / REST在hyperledger(Bluemix服务)上部署链代码

/ chaincode QuerySpec

  

{“jsonrpc”:“2.0”,“method”:“deploy”,“params”:{“type”:1,   “chaincodeID”:{“path”:   “https://github.com/romeokienzler/learn-chaincode/tree/master/finished”   },“ctorMsg”:{“function”:“init”,“args”:[“hi there”]},   “secureContext”:“user_type1_0”},“id”:1}

我也试过那些链接

https://github.com/romeokienzler/learn-chaincode/blob/master/finished/chaincode_finished?raw=true

https://raw.githubusercontent.com/romeokienzler/learn-chaincode/master/finished/chaincode_finished.go

我总是得到

  

{“jsonrpc”:“2.0”,“error”:{       “代码”: - 32001,       “消息”:“部署失败”,       “data”:“部署链码时出错:获取链码包字节时出错:获取代码'go get'失败,错误:'退出   状态1'\ npackage   github.com/romeokienzler/learn-chaincode/tree/master/finished:不能   找到包裹   'github.com/romeokienzler/learn-chaincode/tree/master/finished'中的任何一个   的:\ n \ t在/ usr /本地/去/ src目录/ github.com / romeokienzler /学习-chaincode /树/主/成品   (从   $ GOROOT)\ n \吨/去/ 用户代码 /552962906/src/github.com/romeokienzler/learn-chaincode/tree/master/finished   (从   $ GOPATH)\ n \ t /去/ src目录/ github.com / romeokienzler /学习-chaincode /树/主/结束\ n”   },“id”:1}

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

考虑到您正在使用Bluemix服务,我假设您正在关注"Implementing your first chain code tutorial"

如果您的分叉存储库您将看到使用分支v1.0进行Bluemix区块链服务(link)的说明,那么IBM BMX服务仍在使用Fabric v0.5。

使用其中一个可用的注册ID注册后,您应该能够使用 DeploySpec 部署您的链代码(请注意路径:" https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished")

{
"jsonrpc": "2.0",
  "method": "deploy",
  "params": {
    "type": 1,
    "chaincodeID": {
      "path": "https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished"
    },
    "ctorMsg": {
      "function": "init",
      "args": [
        "hi there"
      ]
    },
    "secureContext": "user_type1_0"
  },
  "id": 1
}

答案 1 :(得分:0)

首先应将deploy命令更改为(路径变量的值已更改):

{
    "jsonrpc": "2.0",
    "method": "deploy",
    "params": {
        "type": 1,
        "chaincodeID": {
            "path": "https://github.com/romeokienzler/learn-chaincode/finished"
        },
        "ctorMsg": {
            "function": "init",
            "args": ["hi there"]
        },
        "secureContext": "user_type1_0"
    },
    "id": 1
}

P.S。正如@ Mil4n正确提到的那样,IBM Bluemix仍然可以与Fabric v0.5一起使用。此版本应采用Chaincode romeokienzler/learn-chaincode/finished

例如,shim.ChaincodeStubInterface尚不可用,应替换为*shim.ChaincodeStub