removed /latest endpoints and checks

This commit is contained in:
Fabian
2018-03-17 22:14:19 +01:00
committed by Ethan Buchman
parent abfa409d37
commit e8e1e2899b
4 changed files with 40 additions and 30 deletions
+6 -6
View File
@@ -101,12 +101,12 @@ func BlockRequestHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ERROR: Couldn't parse block height. Assumed format is '/block/{height}'."))
return
}
chainHeight, err := GetChainHeight()
if height > chainHeight {
w.WriteHeader(404)
w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
return
}
// chainHeight, err := GetChainHeight()
// if height > chainHeight {
// w.WriteHeader(404)
// w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
// return
// }
output, err := getBlock(&height)
if err != nil {
w.WriteHeader(500)
+2 -2
View File
@@ -47,8 +47,8 @@ func initClientCommand() *cobra.Command {
func RegisterRoutes(r *mux.Router) {
r.HandleFunc("/node_info", NodeInfoRequestHandler).Methods("GET")
r.HandleFunc("/syncing", NodeSyncingRequestHandler).Methods("GET")
r.HandleFunc("/blocks/latest", LatestBlockRequestHandler).Methods("GET")
// r.HandleFunc("/blocks/latest", LatestBlockRequestHandler).Methods("GET")
r.HandleFunc("/blocks/{height}", BlockRequestHandler).Methods("GET")
r.HandleFunc("/validatorsets/latest", LatestValidatorsetRequestHandler).Methods("GET")
// r.HandleFunc("/validatorsets/latest", LatestValidatorsetRequestHandler).Methods("GET")
r.HandleFunc("/validatorsets/{height}", ValidatorsetRequestHandler).Methods("GET")
}
+6 -6
View File
@@ -78,12 +78,12 @@ func ValidatorsetRequestHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ERROR: Couldn't parse block height. Assumed format is '/validatorsets/{height}'."))
return
}
chainHeight, err := GetChainHeight()
if height > chainHeight {
w.WriteHeader(404)
w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
return
}
// chainHeight, err := GetChainHeight()
// if height > chainHeight {
// w.WriteHeader(404)
// w.Write([]byte("ERROR: Requested block height is bigger then the chain length."))
// return
// }
output, err := getValidators(&height)
if err != nil {
w.WriteHeader(500)