From 90fdde401882b03dca637cdfab8e6ea026994f7d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 13 Mar 2020 10:04:57 +0300 Subject: [PATCH] rpc: move getversion RPC to a separate func --- pkg/rpc/server/server.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 84e2e3620..2f7956752 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -244,11 +244,7 @@ Methods: results, resultsErr = s.getValidators() case "getversion": - results = result.Version{ - Port: s.coreServer.Port, - Nonce: s.coreServer.ID(), - UserAgent: s.coreServer.UserAgent, - } + results, resultsErr = s.getVersion(reqParams) case "getpeers": results, resultsErr = s.getPeers(reqParams) @@ -313,6 +309,14 @@ Methods: s.WriteResponse(req, w, results) } +func (s *Server) getVersion(_ request.Params) (interface{}, error) { + return result.Version{ + Port: s.coreServer.Port, + Nonce: s.coreServer.ID(), + UserAgent: s.coreServer.UserAgent, + }, nil +} + func (s *Server) getPeers(_ request.Params) (interface{}, error) { peers := result.NewGetPeers() peers.AddUnconnected(s.coreServer.UnconnectedPeers())