return nil if the address is not found

pull/169/head
Minh Doan 6 years ago committed by Minh Doan
parent 2c04f062a2
commit d2dd4aee46
  1. 7
      services/explorer/service.go

@ -233,19 +233,18 @@ func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request) {
data := &Data{}
if id == "" {
json.NewEncoder(w).Encode(data.Address)
json.NewEncoder(w).Encode(nil)
return
}
db := s.storage.GetDB()
bytes, err := db.Get([]byte(key))
if err != nil {
json.NewEncoder(w).Encode(data.Address)
json.NewEncoder(w).Encode(nil)
return
}
var address Address
if err = rlp.DecodeBytes(bytes, &address); err != nil {
fmt.Println(err)
json.NewEncoder(w).Encode(data.Address)
json.NewEncoder(w).Encode(nil)
return
}
data.Address = address

Loading…
Cancel
Save