MCPcopy
hub / github.com/canopy-network/canopy / RootChainInfo

Method RootChainInfo

cmd/rpc/query.go:138–155  ·  view source on GitHub ↗

RootChainInfo retrieves the root chain info for the specified chain

(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Source from the content-addressed store, hash-verified

136
137// RootChainInfo retrieves the root chain info for the specified chain
138func (s *Server) RootChainInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
139 req := new(heightAndIdRequest)
140 // unmarshal request parameters
141 if ok := unmarshal(w, r, req); !ok {
142 return
143 }
144 // if height is 0; set to the latest height
145 if req.Height == 0 {
146 req.Height = s.controller.FSM.Height()
147 }
148 // load the root chain info directly
149 got, err := s.controller.FSM.LoadRootChainInfo(req.ID, req.Height)
150 if err != nil {
151 write(w, err, http.StatusBadRequest)
152 return
153 }
154 write(w, got, http.StatusOK)
155}
156
157// CommitteeData retrieves the committee data for the specified chain id
158func (s *Server) CommitteeData(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {

Callers 3

query.goFile · 0.45
GetRootChainInfoMethod · 0.45
dialWithBackoffMethod · 0.45

Calls 4

writeFunction · 0.85
LoadRootChainInfoMethod · 0.80
unmarshalFunction · 0.70
HeightMethod · 0.45

Tested by

no test coverage detected