我在構建自己的鏈式代碼時遇到了問題。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")
}
}