fSetup := blockchain.FabricSetup{
// Channel parameters
ChannelID: "chainhero",
ChannelConfig: os.Getenv("GOPATH") + "/src/github.com/chainHero/heroes-service/fixtures/artifacts/chainhero.channel.tx",
// Chaincode parameters
ChainCodeID: "heroes-service",
ChaincodeGoPath: os.Getenv("GOPATH"),
ChaincodePath: "github.com/chainHero/heroes-service/chaincode/",
OrgAdmin: "Admin",
OrgName: "Org1",
ConfigFile: "config.yaml",
// User parameters
UserName: "User1",
}
fmt.Printf("第一個chiancode!!!")
fmt.Println(fSetup)
// Initialization of the Fabric SDK from the previously set properties
err := fSetup.Initialize()
if err != nil {
fmt.Printf("Unable to initialize the Fabric SDK: %v\n", err)
}
// Install and instantiate the chaincode
err = fSetup.InstallAndInstantiateCC()
if err != nil {
fmt.Printf("Unable to install and instantiate the chaincode: %v\n", err)
}
fmt.Printf("第二個chiancode!!!")
fSetup2 := &blockchain.FabricSetup{
// Channel parameters
ChannelID: "chainhero",
ChannelConfig: os.Getenv("GOPATH") + "/src/github.com/chainHero/heroes-service/fixtures/artifacts/chainhero.channel.tx",
// Chaincode parameters
ChainCodeID: "initLedger",
ChaincodeGoPath: os.Getenv("GOPATH"),
ChaincodePath: "github.com/chainHero/heroes-service/chaincode/initLedger/",
OrgAdmin: "Admin",
OrgName: "Org1",
ConfigFile: "config.yaml",
// User parameters
UserName: "User1",
}
fmt.Println(*fSetup2)
// Initialization of the Fabric SDK from the previously set properties
/*err2 := fSetup2.Initialize2()
if err2 != nil {
fmt.Printf("Unable to initialize the Fabric SDK: %v\n", err2)
}*/
// Install and instantiate the chaincode
err2 := fSetup2.InstallAndInstantiateCC()
if err2 != nil {
fmt.Printf("Unable to install and instantiate the chaincode: %v\n", err2)
}
I try to install and instantiate multiple chaincode, but some error happened.
Environment up
Start app ...
第一個chiancode!!!{config.yaml chainhero heroes-service false /opt/gopath//src/ github.com/chainHero/heroes-service/fixtures/artifacts/chainhero.channel.tx /opt /gopath/ github.com/chainHero/heroes-service/chaincode/ Admin Org1 User1 <nil> < nil> <nil>}
[fabric_sdk_go] 2018/06/29 04:44:13 UTC - config.initConfig -> INFO config fabr ic_sdk_go logging level is set to: INFO
Initialization Successful
Chaincode Installation & Instantiation Successful
第二個chiancode!!!{config.yaml chainhero initLedger false /opt/gopath//src/gith ub.com/chainHero/heroes-service/fixtures/artifacts/chainhero.channel.tx /opt/gop ath/ github.com/chainHero/heroes-service/chaincode/initLedger/ Admin Org1 User1 <nil> <nil> <nil>}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x9a302d]
goroutine 1 [running]:
github.com/chainHero/heroes-service/blockchain.(*FabricSetup).InstallAndInstanti ateCC(0xc420181dd0, 0x1, 0x1)
/opt/gopath/src/github.com/chainHero/heroes-service/blockchain/setup.go: 119 +0x1ad
main.main()
/opt/gopath/src/github.com/chainHero/heroes-service/main.go:74 +0x529
Makefile:29: recipe for target 'run' failed
make: *** [run] Error 2