github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/api/consensus.go (about) 1 package api 2 3 import ( 4 "net/http" 5 6 "github.com/NebulousLabs/Sia/types" 7 8 "github.com/julienschmidt/httprouter" 9 ) 10 11 // ConsensusGET contains general information about the consensus set, with tags 12 // to support idiomatic json encodings. 13 type ConsensusGET struct { 14 Synced bool `json:"synced"` 15 Height types.BlockHeight `json:"height"` 16 CurrentBlock types.BlockID `json:"currentblock"` 17 Target types.Target `json:"target"` 18 } 19 20 // consensusHandler handles the API calls to /consensus. 21 func (srv *Server) consensusHandler(w http.ResponseWriter, req *http.Request, _ httprouter.Params) { 22 cbid := srv.cs.CurrentBlock().ID() 23 currentTarget, _ := srv.cs.ChildTarget(cbid) 24 writeJSON(w, ConsensusGET{ 25 Synced: srv.cs.Synced(), 26 Height: srv.cs.Height(), 27 CurrentBlock: cbid, 28 Target: currentTarget, 29 }) 30 }