我正在尝试编写chainCode,并且为了实现逻辑,我需要使用外部节点程序包,该程序包不是Fabric API的一部分。有可能这样做吗?
我从未见过需要外部节点模块的chainCode示例。如果您知道示例,请与我分享。
此外,如果可能的话,我想知道这样做的风险以及将风险最小化的好的设计。
答案 0 :(得分:0)
“严格使用”
const {Shim} = require('fabric-shim')
const path = require(“ path”)
const fs = require('fs')
const examplecc = require('./ lib / examplecontract.js')
function main(){
const tlsCertsPath=path.resolve(__dirname,"lib", "tls")
const tlsKey = fs.readFileSync( path.resolve(tlsCertsPath, "server.key"))
const tlsCert = fs.readFileSync(path.resolve(tlsCertsPath, "server.crt"))
const rootCert = fs.readFileSync(path.resolve(tlsCertsPath, "ca.crt"))
const config={
ccid:
“ examplecc:1177322ea1cb10e56c4499016dsdb2fbf0be155660e97a38ca48de76326b12362”,
address: "0.0.0.0:9992"}
const server= Shim.server(new examplecc(),{
ccid: config.ccid,
address: config.address,
tlsProps: {
disabled: true,
key: tlsKey,
cert: tlsCert,
clientCACerts: rootCert,
}
} )
server.start().then((res)=>{
console.log("Server running successfully @" + config.address )
})
}
main()