V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
janda
V2EX  ›  问与答

fabric 实例化链码的时候出现这样的错误!安装的时候是没有问题的、这个是怎么回事呢?找了很久都没有找到解决方案

  •  
  •   janda · 2021-02-23 15:06:06 +08:00 · 753 次点击
    这是一个创建于 1130 天前的主题,其中的信息可能已经有所发展或是发生改变。

    官方简单的一个 demo 链码、init 的方法都是直接返回一个字符串

    链码内容:

    为了直观展示就 init 只返回了一个错误的字符串

    func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
    	return shim.Error("hello")
    }
    

    安装链码且实例化链码的过程如下:

    # 安装链码
    root@cli-6d4b59664-p4xfc:/opt/gopath/src/chaincode# peer chaincode install -n mycca -v 1.0 -p chaincode/
    2021-02-23 06:46:23.904 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2021-02-23 06:46:23.904 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2021-02-23 06:46:24.054 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
    
    #实例化链码
    root@cli-6d4b59664-p4xfc:/opt/gopath/src/chaincode# peer chaincode instantiate -o orderer0.adminnodborderer:7050 --tls --cafile /etc/hyperledger/crypto-config/ordererOrganizations/adminnodborderer/orderers/orderer0.adminnodborderer/msp/tlscacerts/tlsca.adminnodborderer-cert.pem -C myc -n mycca -v 1.0 -c '{"Args":["init"]}'
    2021-02-23 06:48:49.284 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2021-02-23 06:48:49.285 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode registration failed: container exited with 0
    

    已尝试根据network处解决、可最终结果还是不行

    玩这个的大佬、麻烦指教下

    7 条回复    2021-02-23 18:52:10 +08:00
    learningman
        1
    learningman  
       2021-02-23 15:19:26 +08:00 via Android
    500 怎么看怎么像他炸了
    smallyu
        2
    smallyu  
       2021-02-23 15:24:38 +08:00
    为什么要 return Error 呢?
    janda
        3
    janda  
    OP
       2021-02-23 15:24:53 +08:00
    @learningman 可以安装、就是实例化的时候不行!这个一般是什么问题导致的
    janda
        4
    janda  
    OP
       2021-02-23 15:25:30 +08:00
    @smallyu 我觉得这不是重点、只是实例化的时候打印下、能证明实例化成功了!问题是现在都实例化不成功
    smallyu
        5
    smallyu  
       2021-02-23 16:23:10 +08:00
    return shim.Success(nil)
    janda
        6
    janda  
    OP
       2021-02-23 16:44:05 +08:00
    @smallyu 试过了、没有用
    jonathanchoo
        7
    jonathanchoo  
       2021-02-23 18:52:10 +08:00
    看 peer 日志
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2859 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:01 · PVG 21:01 · LAX 06:01 · JFK 09:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.