()
| 38 | ) |
| 39 | |
| 40 | func StartLocalServer() error { |
| 41 | log.Debug() |
| 42 | http.HandleFunc(LOCAL_DIR, rpc.Handle) |
| 43 | |
| 44 | rpc.HandleFunc("getneighbor", rpc.GetNeighbor) |
| 45 | rpc.HandleFunc("getnodestate", rpc.GetNodeState) |
| 46 | rpc.HandleFunc("startconsensus", rpc.StartConsensus) |
| 47 | rpc.HandleFunc("stopconsensus", rpc.StopConsensus) |
| 48 | rpc.HandleFunc("setdebuginfo", rpc.SetDebugInfo) |
| 49 | |
| 50 | // TODO: only listen to local host |
| 51 | err := http.ListenAndServe(LOCAL_HOST+":"+strconv.Itoa(int(cfg.DefConfig.Rpc.HttpLocalPort)), nil) |
| 52 | if err != nil { |
| 53 | return fmt.Errorf("ListenAndServe error:%s", err) |
| 54 | } |
| 55 | return nil |
| 56 | } |
no test coverage detected