MCPcopy Create free account
hub / github.com/DNAProject/DNA / startSigSvr

Function startSigSvr

sigsvr.go:63–112  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

61}
62
63func startSigSvr(ctx *cli.Context) {
64 logLevel := ctx.GlobalInt(utils.GetFlagName(utils.LogLevelFlag))
65 log.InitLog(logLevel, log.PATH, log.Stdout)
66
67 walletDirPath := ctx.String(utils.GetFlagName(utils.CliWalletDirFlag))
68 if walletDirPath == "" {
69 log.Errorf("Please using --walletdir flag to specific wallet saving path")
70 return
71 }
72
73 walletStore, err := store.NewWalletStore(walletDirPath)
74 if err != nil {
75 log.Errorf("NewWalletStore error:%s", err)
76 return
77 }
78 clisvrcom.DefWalletStore = walletStore
79
80 accountNum, err := walletStore.GetAccountNumber()
81 if err != nil {
82 log.Errorf("GetAccountNumber error:%s", err)
83 return
84 }
85 log.Infof("Load wallet data success. Account number:%d", accountNum)
86
87 rpcAddress := ctx.String(utils.GetFlagName(utils.CliAddressFlag))
88 rpcPort := ctx.Uint(utils.GetFlagName(utils.CliRpcPortFlag))
89 if rpcPort == 0 {
90 log.Errorf("Please using sig server port by --%s flag", utils.GetFlagName(utils.CliRpcPortFlag))
91 return
92 }
93 go cmdsvr.DefCliRpcSvr.Start(rpcAddress, rpcPort)
94
95 abiPath := ctx.GlobalString(utils.GetFlagName(utils.CliABIPathFlag))
96 abi.DefAbiMgr.Init(abiPath)
97
98 log.Infof("Sig server init success")
99 log.Infof("Sig server listing on: %s:%d", rpcAddress, rpcPort)
100
101 exit := make(chan bool, 0)
102 sc := make(chan os.Signal, 1)
103 signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
104 go func() {
105 for sig := range sc {
106 log.Infof("Sig server received exit signal:%v.", sig.String())
107 close(exit)
108 break
109 }
110 }()
111 <-exit
112}
113
114func main() {
115 if err := setupSigSvr().Run(os.Args); err != nil {

Callers

nothing calls this directly

Calls 10

GetAccountNumberMethod · 0.95
GetFlagNameFunction · 0.92
InitLogFunction · 0.92
ErrorfFunction · 0.92
NewWalletStoreFunction · 0.92
InfofFunction · 0.92
NotifyMethod · 0.80
StartMethod · 0.65
StringMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected