Hyperledger Fabric System Chaincode插件-缺少示例 [英] Hyperledger Fabric System Chaincode Plugin - missing sample
问题描述
根据位于以下位置的系统链码文档:
according to the system chaincode documentation located at:
https://hyperledger-fabric.readthedocs.io/en/latest /systemchaincode.html
存储库中应该有一个样本:
there should be a sample at the repository:
每个系统链代码都必须实现链代码接口,并导出与主程序包中的签名函数func New()shim.Chaincode匹配的构造函数方法.可以在示例库/examples/plugin/scc中找到一个示例."
"Every system chaincode must implement the Chaincode Interface and export a constructor method that matches the signature func New() shim.Chaincode in the main package. An example can be found in the repository at examples/plugin/scc."
但是github构造存储库上的任何地方都不存在文件夹examples/plugin/scc ...
yet the folder examples/plugin/scc is not present anywhere on github fabric repository ...
有人能指出我正确的方向吗?谢谢
can someone please point me in the right direction? thanks
编辑
我发现的唯一样本是
https://github.com/hyperledger/fabric/tree /release/core/scc/samplesyscc
这是文档所引用的示例吗?如果是的话,也许更新您的文档...
is this the sample the documentation is refering to? if yes, maybe update your documentation ...
推荐答案
事实上,实现常规链码和系统链码之间没有太大区别.唯一的区别是系统链码已编译到对等体中并在对等体内部运行,或者可以作为插入方式打开.
As a matter of fact there is no big difference between implementing a regular chaincode and the system chaincode. The only difference is that system chaincode is compiled into the peer and run inside peer process or could be turned on as a plugging.
所以,是的,您找到的示例是您可以自己实现系统链码的示例,例如 https://github.com/hyperledger/fabric/blob/release/core/scc/samplesyscc/samplesyscc.go .
So, yes example you have found is the one you can use to implement system chaincode on your own, e.g. https://github.com/hyperledger/fabric/blob/release/core/scc/samplesyscc/samplesyscc.go.
此外,您可以查看其他系统链码以获得更一般的想法,例如,您可以从
Moreover you can take a look on other system chaincode to get more general idea, for example you can learn from QSCC (Query System ChainCode).
要启用系统链码,您需要确保在core.yaml
文件中启用它,例如,这是编译成对等代码的系统链码的样子:
In order to enable system chaincode you need to make sure to enable it inside core.yaml
file for example this is how it looks like for system chaincode compiled into peer code:
# system chaincodes whitelist. To add system chaincode "myscc" to the
# whitelist, add "myscc: enable" to the list below, and register in
# chaincode/importsysccs.go
system:
cscc: enable
lscc: enable
escc: enable
vscc: enable
qscc: enable
rscc: disable
此外,您需要在importsysccs.go
中列出,例如:
in addition you need to list inside importsysccs.go
, e.g.:
var systemChaincodes = []*SystemChaincode{
{
Enabled: true,
Name: "cscc",
Path: "github.com/hyperledger/fabric/core/scc/cscc",
InitArgs: [][]byte{[]byte("")},
Chaincode: &cscc.PeerConfiger{},
InvokableExternal: true, // cscc is invoked to join a channel
},
{
Enabled: true,
Name: "lscc",
Path: "github.com/hyperledger/fabric/core/scc/lscc",
InitArgs: [][]byte{[]byte("")},
Chaincode: lscc.NewLifeCycleSysCC(),
InvokableExternal: true, // lscc is invoked to deploy new chaincodes
InvokableCC2CC: true, // lscc can be invoked by other chaincodes
},
{
Enabled: true,
Name: "escc",
Path: "github.com/hyperledger/fabric/core/scc/escc",
InitArgs: [][]byte{[]byte("")},
Chaincode: &escc.EndorserOneValidSignature{},
},
{
Enabled: true,
Name: "vscc",
Path: "github.com/hyperledger/fabric/core/scc/vscc",
InitArgs: [][]byte{[]byte("")},
Chaincode: &vscc.ValidatorOneValidSignature{},
},
{
Enabled: true,
Name: "qscc",
Path: "github.com/hyperledger/fabric/core/chaincode/qscc",
InitArgs: [][]byte{[]byte("")},
Chaincode: &qscc.LedgerQuerier{},
InvokableExternal: true, // qscc can be invoked to retrieve blocks
InvokableCC2CC: true, // qscc can be invoked to retrieve blocks also by a cc
},
{
Enabled: true,
Name: "rscc",
Path: "github.com/hyperledger/fabric/core/chaincode/rscc",
InitArgs: [][]byte{[]byte("")},
Chaincode: rscc.NewRscc(),
InvokableExternal: true, // rscc can be invoked to update policies
InvokableCC2CC: false, // rscc cannot be invoked from a cc
},
}
作为替代方案,您可以将系统链码作为插件,要启用它,您需要在core.yaml
中进行设置:
as alternative you can have your system chaincode as plugin, to enable it you need to setup it within core.yaml
:
# System chaincode plugins: in addition to being imported and compiled
# into fabric through core/chaincode/importsysccs.go, system chaincodes
# can also be loaded as shared objects compiled as Go plugins.
# See examples/plugins/scc for an example.
# Like regular system chaincodes, plugins must also be white listed in the
# chaincode.system section above.
systemPlugins:
# example configuration:
# - enabled: true
# name: myscc
# path: /opt/lib/myscc.so
# invokableExternal: true
# invokableCC2CC: true
这篇关于Hyperledger Fabric System Chaincode插件-缺少示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!