1 Star 0 Fork 1

核辐射/fabric-sdk

forked from czy/fabric-sdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 2.50 KB
一键复制 编辑 原始数据 按行查看 历史
czy 提交于 2021-11-09 16:11 . recover sdk
package main
import (
"fabric-sdk/sdk"
"fabric-sdk/server"
"fmt"
"os"
)
const (
cc_name = "mycc"
cc_version = "1.0.0"
GOPATH = "/home/mcloud/go/"
)
// var Server sdk.Server
func main() {
// init orgs information
orgs := []*sdk.OrgInfo{
{
OrgAdminUser: "Admin",
OrgName: "Org1",
OrgMspId: "Org1MSP",
OrgUser: "User1",
OrgPeerNum: 2,
OrgAnchorFile: GOPATH + "src/fabric-sdk/gen_crypto/channel-artifacts/Org1MSPanchors.tx",
},
{
OrgAdminUser: "Admin",
OrgName: "Org2",
OrgMspId: "Org2MSP",
OrgUser: "User1",
OrgPeerNum: 2,
OrgAnchorFile: GOPATH + "src/fabric-sdk/gen_crypto/channel-artifacts/Org2MSPanchors.tx",
},
{
OrgAdminUser: "Admin",
OrgName: "Org3",
OrgMspId: "Org3MSP",
OrgUser: "User1",
OrgPeerNum: 2,
OrgAnchorFile: GOPATH + "src/fabric-sdk/gen_crypto/channel-artifacts/Org3MSPanchors.tx",
},
{
OrgAdminUser: "Admin",
OrgName: "Org4",
OrgMspId: "Org4MSP",
OrgUser: "User1",
OrgPeerNum: 2,
OrgAnchorFile: GOPATH + "src/fabric-sdk/gen_crypto/channel-artifacts/Org4MSPanchors.tx",
},
}
// init sdk env info
info := sdk.SdkEnvInfo{
ChannelID: "mychannel",
ChannelConfig: GOPATH + "src/fabric-sdk/gen_crypto/channel-artifacts/channel.tx",
Orgs: orgs,
OrdererAdminUser: "Admin",
OrdererOrgName: "OrdererOrg",
OrdererEndpoint: "orderer1.demo.com",
ChaincodeID: cc_name,
ChaincodePath: GOPATH + "src/fabric-sdk/chaincode/",
ChaincodeVersion: cc_version,
}
// fmt.Println("%v", info)
// sdk setup
sdk, err := sdk.Setup("config.yaml", &info)
if err != nil {
fmt.Println(">> SDK setup error:", err)
os.Exit(-1)
}
// // create channel and join
// if err := sdk.CreateAndJoinChannel(&info); err != nil {
// fmt.Println(">> Create channel and join error:", err)
// os.Exit(-1)
// }
// // create chaincode lifecycle
// if err := sdk.CreateCCLifecycle(&info, 1, false, sdk); err != nil {
// fmt.Println(">> create chaincode lifecycle error: %v", err)
// os.Exit(-1)
// }
// invoke chaincode set status
// fmt.Println(">> 通过链码外部服务设置链码状态......")
fmt.Print(">> 启动服务 ... ")
err = info.InitService(info.ChaincodeID, info.ChannelID, info.Orgs[0], sdk)
if err != nil {
fmt.Println("InitService error")
os.Exit(-1)
}
fmt.Println("done")
serverInfo := server.Server{
SdkEnvInfo: &info,
}
// fmt.Println("%v", serverInfo)
server.ServerStart(serverInfo)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lifengjiex/fabric-sdk.git
git@gitee.com:lifengjiex/fabric-sdk.git
lifengjiex
fabric-sdk
fabric-sdk
master

搜索帮助