rpc: move validateaddress RPC to a separate func

This commit is contained in:
Evgenii Stratonikov 2020-03-13 10:01:49 +03:00
parent 70eb0b175a
commit 4e25c9121b

View file

@ -269,12 +269,7 @@ Methods:
results, resultsErr = s.getStorage(reqParams)
case "validateaddress":
param, ok := reqParams.Value(0)
if !ok {
resultsErr = response.ErrInvalidParams
break Methods
}
results = validateAddress(param.Value)
results, resultsErr = s.validateAddress(reqParams)
case "getassetstate":
results, resultsErr = s.getAssetState(reqParams)
@ -327,6 +322,14 @@ Methods:
s.WriteResponse(req, w, results)
}
func (s *Server) validateAddress(reqParams request.Params) (interface{}, error) {
param, ok := reqParams.Value(0)
if !ok {
return nil, response.ErrInvalidParams
}
return validateAddress(param.Value), nil
}
func (s *Server) getAssetState(reqParams request.Params) (interface{}, error) {
param, ok := reqParams.ValueWithType(0, request.StringT)
if !ok {