extended info rest request - returns bestblock of the index
This commit is contained in:
parent
48057b2453
commit
cb3cdb6701
@ -76,10 +76,20 @@ func respondHashData(w http.ResponseWriter, hash string) {
|
|||||||
|
|
||||||
func (s *HttpServer) info(w http.ResponseWriter, r *http.Request) {
|
func (s *HttpServer) info(w http.ResponseWriter, r *http.Request) {
|
||||||
type info struct {
|
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{
|
json.NewEncoder(w).Encode(info{
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
|
BestBlockHeight: height,
|
||||||
|
BestBlockHash: hash,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user