我在构建自己的链式代码时遇到了问题。HyperledgerFabric v1.0.0 * SampleChaincode没有实现shim.Chaincode
Hypeledger面料版本1.0.0 -v
> cannot use new(SampleChaincode) (type *SampleChaincode) as type
> shim.Chaincode in argument to shim.Start:
> *SampleChaincode does not implement shim.Chaincode (wrong type for Init method)
> have Init(shim.ChaincodeStubInterface, string, []string) ([]byte, error)
> want Init(shim.ChaincodeStubInterface) peer.Response
我尝试在V0.6面料编译和它成功。然而,当我实例化链码,我收到相同的消息,可能是因为我的区块链运行在v1.0.0
因此,有没有办法解决这个问题?
这是我的代码
func main() {
lld, _ := shim.LogLevel("DEBUG")
fmt.Println(lld)
logger.SetLevel(lld)
fmt.Println(logger.IsEnabledFor(lld))
err := shim.Start(new(SampleChaincode))
if err != nil {
logger.Error("Could not start SampleChaincode")
} else {
logger.Info("SampleChaincode successfully started")
}
}