Exemple #1
0
func info(resp http.ResponseWriter) string {
	lastBlock, err := env.DB.GetLastBlock()
	if err != nil {
		log.Printf("Error while serving /info: %v", err)
	}
	json, err := json.Marshal(Info{Mining: server.GetMiningStatus(), LastBlock: lastBlock})
	if err != nil {
		log.Printf("Error while serving /info: %v", err)
	}
	resp.Header().Add("Content-Type", "application/json")
	return string(json)
}
Exemple #2
0
func InfoHandler(srv *context.T, log log15.Logger) func(http.ResponseWriter, *http.Request) {
	return func(resp http.ResponseWriter, req *http.Request) {
		log := log.New("http")
		lastBlock, err := srv.DB.GetLastBlock()
		if err != nil {
			log.Error("error serving /info", "err", err)
		}
		info := Info{
			Mining:    server.GetMiningStatus(),
			LastBlock: lastBlock,
		}
		info.Debug.NumGoroutine = runtime.NumGoroutine()
		json, err := json.Marshal(info)
		if err != nil {
			log.Error("error serving /info", "err", err)
		}
		resp.Header().Add("Content-Type", "application/json")
		resp.Write(json)
	}

}