From cb3cdb67013e0b5a233589403a87139aea666a99 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Thu, 25 Jan 2018 12:31:31 +0100 Subject: [PATCH] extended info rest request - returns bestblock of the index --- server/https.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/https.go b/server/https.go index 77914ad2..9424a9ef 100644 --- a/server/https.go +++ b/server/https.go @@ -76,10 +76,20 @@ func respondHashData(w http.ResponseWriter, hash string) { func (s *HttpServer) info(w http.ResponseWriter, r *http.Request) { type info struct { - Version string `json:"version"` + Version string `json:"version"` + BestBlockHeight uint32 `json:"bestBlockHeight"` + BestBlockHash string `json:"bestBlockHash"` } + + height, hash, err := s.db.GetBestBlock() + if err != nil { + log.Printf("https info: %v", err) + } + json.NewEncoder(w).Encode(info{ - Version: "0.0.1", + Version: "0.0.1", + BestBlockHeight: height, + BestBlockHash: hash, }) }