【问题标题】:How to fix "syntax error: unexpected shim, expecting comma or )" in chaincode?如何修复链码中的“语法错误:意外的垫片,期待逗号或)”?
【发布时间】:2019-08-21 02:21:06
【问题描述】:

我有链码,它应该加密数据并放入分类帐并进行查询。

我已经更新了结构二进制文件,但在其他结构示例链代码中,这一行是相同的并且没有任何错误。

func (s *SmartContract) queryPatient(APIstub shim.ChaincodeStubInterface, args []string) sc.Response { 
     if len(args) != 1 {
         return shim.Error("Incorrect number of arguments. Expecting 1")
     }

    patientAsBytes, err := fc.Decrypter(APIstub, args[0])
    if err != nil {
        return shim.Error(err.Error())
    }

     return shim.Success(patientAsBytes)
 }

错误指向 queryPatient(APIstub shim.ChaincodeStubInterface, args []string) sc.Response { .

【问题讨论】:

  • 这段代码的语法没有错,所以它不会产生那个错误。错误来自其他地方或实际代码不同。

标签: go hyperledger-fabric hyperledger-chaincode chaincode


【解决方案1】:

不知道 sc.Response 中的内容,但在所有情况下,您都返回了 shim.Error() 类型。根据术语存根,我认为您使用的是 gRPC,它应该返回响应和错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-19
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多