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{} data := &Data{}
if id == "" { if id == "" {
json.NewEncoder(w).Encode(data.Address) json.NewEncoder(w).Encode(nil)
return return
} }
db := s.storage.GetDB() db := s.storage.GetDB()
bytes, err := db.Get([]byte(key)) bytes, err := db.Get([]byte(key))
if err != nil { if err != nil {
json.NewEncoder(w).Encode(data.Address) json.NewEncoder(w).Encode(nil)
return return
} }
var address Address var address Address
if err = rlp.DecodeBytes(bytes, &address); err != nil { if err = rlp.DecodeBytes(bytes, &address); err != nil {
fmt.Println(err) json.NewEncoder(w).Encode(nil)
json.NewEncoder(w).Encode(data.Address)
return return
} }
data.Address = address data.Address = address

Loading…
Cancel
Save