实例化Hyperledger Fabric 1.1.0中的链码时出错

时间:2019-06-30 03:22:40

标签: hyperledger-fabric

我正在尝试在Hyperledger Fabric对等1.1.0中实例化chaincode。我已经下载了1.1.0版本的结构样本和Docker容器。 fabcar应用程序已成功实例化。

但是,当我实例化我的链码时,对等端退出并出现以下错误。

2019-06-29 12:01:47.916 UTC [kvledger] CommitWithPvtData -> INFO 042 Channel [mychannel]: Committed block [3] with 1 transaction(s)
panic: assignment to entry in nil map

goroutine 569 [running]:
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.createCouchdbDocJSON(0xc422170890, 0x6, 0x0, 0x0, 0xc422170898, 0x4, 0x4, 0xc422170ae0, 0xc42001e000, 0xc42001e070, ...)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:984 +0x1d8
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).processUpdateBatch(0xc4215691d0, 0xc4217c7df0, 0x0, 0x0, 0x0, 0xc422170898, 0x4)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:669 +0x550
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).ApplyUpdates.func1(0xc422170eb0, 0xc42000eb68, 0xc4215691d0, 0xc422197140, 0xc422170870, 0x7)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:577 +0x8a5
created by github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).ApplyUpdates
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:509 +0x11d

正如我在上面看到的那样,它不是从$ GOPATH中获取go代码,它是/ home / ubuntu / software / golang。

我已经使用命令安装了结构和样本。

中所述

https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html

传递参数“ 1.1.0 1.1.0 0.4.15”

我可以看到chaincode init方法已从应用程序日志中执行。

func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
        fmt.Println("Init firing.")

    // Initialize the collection of commercial paper keys
    fmt.Println("Initializing user accounts")
    //t.createUser(stub, []string{"importerBank", "importerBank", "Importer Bank"})
    //t.createUser(stub, []string{"customs", "customs", "Customs"})
    //t.createUser(stub, []string{"exporterBank", "exporterBank", "Exporter Bank"})
    //t.createUser(stub, []string{"exporter", "exporter", "Exporter"})

    fmt.Println("Initializing LC keys collection if not present")
    valAsbytes, err := stub.GetState("LCKeys")
    if err == nil {
            var keys []string
            err = json.Unmarshal(valAsbytes, &keys)
            fmt.Println("Existing LC : %v", keys);
            if len(keys) > 0 {
                    for _, key := range keys {
                            valAsbytes, err := stub.GetState(key)
                            if err == nil {
                                    var lc LC
                                    err = json.Unmarshal(valAsbytes, &lc)
                                    if err == nil {
                                            if lc.CurrentStatus == "" {
                                                    lc.CurrentStatus = "Created"
                                                    keysBytesToWrite, _ := json.Marshal(lc)
                                                    if err == nil {
                                                            err = stub.PutState(key, keysBytesToWrite)
                                                            if err != nil {
                                                                    fmt.Println("Error writing LC to chain" + err.Error())
                                                            }
                                                    }
                                            }
                                    }
                            }
                    }
            }
    }

    fmt.Println("Initialization complete")
  1. 我想知道同伴为什么退出? orderer.example.com: container_name:orderer.example.com 图片:超级账本/织物订购者 环境:
    • ORDERER_GENERAL_LOGLEVEL =调试
    • ORDERER_GENERAL_LISTENADDRESS = 0.0.0.0
    • ORDERER_GENERAL_GENESISMETHOD =文件
    • ORDERER_GENERAL_GENESISFILE = / etc / hyperledger / configtx / genesis.block
    • ORDERER_GENERAL_LOCALMSPID = OrdererMSP
    • ORDERER_GENERAL_LOCALMSPDIR = / etc / hyperledger / msp / orderer / msp
    • GODEBUG = netdns = go working_dir:/opt/gopath/src/github.com/hyperledger/fabric/orderer 命令:订购者 端口:
    • 7050:7050 数量:
      • ./ config /:/ etc / hyperledger / configtx
      • ./ crypto-config / ordererOrganizations / example.com / orderers / orderer.example.com /:/ etc / hyperledger / msp / orderer
      • ./ crypto-config / peerOrganizations / org1.example.com / peers / peer0.org1.example.com /:/ etc / hyperledger / msp / peerOrg1 网络:
    • 基本

1 个答案:

答案 0 :(得分:1)

尝试在docker compose文件的环境部分为每个对等方和订购者添加UnitPrice