From 4e25c9121b1a0bd6391a5641cf1d651240634852 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 13 Mar 2020 10:01:49 +0300 Subject: [PATCH] rpc: move validateaddress RPC to a separate func --- pkg/rpc/server/server.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 7f4bebb12..3333d5570 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -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 {