从教程https://github.com/chainHero/heroes-service开始使用 fabric-sdk-go 版 v1.0.0-alpha3 时,我收到了类似的警告。这是什么意思?
[fabsdk/fab] 2018/06/03 07:56:03 UTC - connection.(*DeliverConnection).Receive -> WARN Received error from stream: [rpc error: code = Unimplemented desc = unknown service protos.Deliver]. Sending disconnected event.
Unable to install and instantiate the chaincode: failed to instantiate the chaincode: CreateAndSendTransaction failed: SendTransaction failed: calling orderer 'orderer.hf.leadiq.com:7050' failed: Orderer Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection timed out [orderer.hf.leadiq.com:7050]
[fabsdk/fab] 2018/06/03 07:56:03 UTC - client.(*Client).monitorConnection -> WARN Event client has disconnected. Details: rpc error: code = Unimplemented desc = unknown service protos.Deliver
[fabsdk/fab] 2018/06/03 07:56:03 UTC - client.(*Client).monitorConnection -> WARN Attempting to reconnect...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45000ec]
这是我创建频道和链代码的方式。
func (setup *FabricSetup) Initialize() error {
if setup.initialized {
return fmt.Errorf("sdk already initialized")
}
sdk, err := fabsdk.New(config.FromFile(setup.ConfigFile))
if err != nil {
return fmt.Errorf("failed to create sdk: %v", err)
}
setup.sdk = sdk
orgAdminClientContext := sdk.Context(fabsdk.WithUser(setup.OrgAdmin), fabsdk.WithOrg(setup.OrgName))
chMgmtClient, err := resmgmt.New(orgAdminClientContext)
if err != nil {
return fmt.Errorf("failed to add Admin user to sdk: %v", err)
}
setup.admin = chMgmtClient
orgAdminUser, err := GetSigningIdentity(sdk, setup.OrgAdmin, setup.OrgName)
if err != nil {
return fmt.Errorf("failed to get session for %s, %s: %s", setup.OrgName, setup.OrgAdmin, err)
}
r, err := os.Open(setup.ChannelConfig)
if err != nil {
return fmt.Errorf("opening channel config file failed: %v", err)
}
defer r.Close()
req := resmgmt.SaveChannelRequest{ChannelID: setup.ChannelID, ChannelConfig: r, SigningIdentities: []msp.SigningIdentity{orgAdminUser}}
if err = chMgmtClient.SaveChannel(req); err != nil {
return fmt.Errorf("failed to create channel: %v", err)
}
time.Sleep(time.Second * 5)
if err = setup.admin.JoinChannel(setup.ChannelID); err != nil {
return fmt.Errorf("org peers failed to join the channel: %v", err)
}
fmt.Println("Initialization Successful")
setup.initialized = true
return nil
}
func (setup *FabricSetup) InstallAndInstantiateCC() error {
ccPkg, err := packager.NewCCPackage(setup.ChaincodePath, setup.ChaincodeGoPath)
if err != nil {
return fmt.Errorf("failed to create chaincode package: %v", err)
}
ccReq := resmgmt.InstallCCRequest{Name: setup.ChainCodeID, Path: setup.ChaincodePath, Version: "1.0", Package: ccPkg}
_, err = setup.admin.InstallCC(ccReq) // THIS LINE THROWS THE ERROR
if err != nil {
return fmt.Errorf("failed to install cc to org peers %v", err)
}
....
}