1 Star 0 Fork 0

peter/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scc.go 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
Jason Yellick 提交于 2018-07-27 02:15 +08:00 . FAB-11519 Create new SCC for new lifecycle
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package lifecycle
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
// SCC implements the required methods to satisfy the chaincode interface.
// It routes the invocation calls to the backing implementations.
type SCC struct{}
// Name returns "+lifecycle"
func (scc *SCC) Name() string {
return "+lifecycle"
}
// Path returns "github.com/hyperledger/fabric/core/chaincode/lifecycle"
func (scc *SCC) Path() string {
return "github.com/hyperledger/fabric/core/chaincode/lifecycle"
}
// InitArgs returns nil
func (scc *SCC) InitArgs() [][]byte {
return nil
}
// Chaincode returns a reference to itself
func (scc *SCC) Chaincode() shim.Chaincode {
return scc
}
// InvokableExternal returns true
func (scc *SCC) InvokableExternal() bool {
return true
}
// InvokableCC2CC returns true
func (scc *SCC) InvokableCC2CC() bool {
return true
}
// Enabled returns true
func (scc *SCC) Enabled() bool {
return true
}
// Init is mostly useless for system chaincodes and always returns success
func (scc *SCC) Init(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Success(nil)
}
// Invoke takes chaincode invocation arguments and routes them to the correct
// underlying lifecycle operation.
func (scc *SCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
args := stub.GetArgs()
if len(args) == 0 {
return shim.Error("lifecycle scc must be invoked with arguments")
}
funcName := args[0]
switch funcName {
// Each lifecycle SCC function gets a case here
default:
return shim.Error(fmt.Sprintf("unknown lifecycle function: %s", funcName))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peter_code_git/fabric.git
git@gitee.com:peter_code_git/fabric.git
peter_code_git
fabric
fabric
v1.3.0

搜索帮助