rpc: move getversion RPC to a separate func

This commit is contained in:
Evgenii Stratonikov 2020-03-13 10:04:57 +03:00
parent 99d02d5de0
commit 90fdde4018

View file

@ -244,11 +244,7 @@ Methods:
results, resultsErr = s.getValidators() results, resultsErr = s.getValidators()
case "getversion": case "getversion":
results = result.Version{ results, resultsErr = s.getVersion(reqParams)
Port: s.coreServer.Port,
Nonce: s.coreServer.ID(),
UserAgent: s.coreServer.UserAgent,
}
case "getpeers": case "getpeers":
results, resultsErr = s.getPeers(reqParams) results, resultsErr = s.getPeers(reqParams)
@ -313,6 +309,14 @@ Methods:
s.WriteResponse(req, w, results) 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) { func (s *Server) getPeers(_ request.Params) (interface{}, error) {
peers := result.NewGetPeers() peers := result.NewGetPeers()
peers.AddUnconnected(s.coreServer.UnconnectedPeers()) peers.AddUnconnected(s.coreServer.UnconnectedPeers())