函数上传在合约智能合约 - 超级账本结构中找不到的数据



我正在更改超级账本结构的fabcar版本并编写了一些函数。当我执行时,我收到下面提到的错误(下面提到的命令是shell脚本(

$ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA -C $CHANNEL_NAME -n cloud $PEER_CONN_PARMS --isInit -c '{"function":"uploadData","Args":["DATA1","ID12345","/home/samplefile___pdf","3"]}'
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: transaction returned with failure: Function uploadData not found in contract SmartContract"

下面是链码(抽象提到(

type SmartContract struct {
contractapi.Contract
}
type Data struct {
Owner  string `json:"owner"`
File string `json:"file"`
FileChunkNumber string `json:"filechunknumber"`
SHA256 string `json:"sha256"`
}
// Uploads new data to the world state with given details
func (s *SmartContract) uploadData(ctx contractapi.TransactionContextInterface, args []string) error {
/*...*/
}

我不知道在哪里更改更改

我假设您在安装和实例化时更新了链码版本号或链码名称。(1.4.6(

您是否尝试过链码的预先存在的函数,它们是否与您的调用命令一起工作。 如果没有,请按照以下调用命令操作:

peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n cloud $PEER_CONN_PARMS -c '{"Args":["uploadData","DATA1","ID12345","/home/samplefile___pdf","3"]}'

我以前遇到过类似的问题;可能有 2 个可能的错误:

  1. Fabric 可能正在使用旧的链码 docker 镜像;因此请尝试 删除该映像,然后使用更新的 Docker 映像重新创建 链码。
  2. uploadData 函数的主体中可能存在一些问题(可能是语法或逻辑错误(,您必须对其进行调试。

希望对您有所帮助!

最新更新