rpc: move getpeers RPC to a separate func

This commit is contained in:
Evgenii Stratonikov 2020-03-13 10:03:58 +03:00
parent dfb4171e3c
commit 99d02d5de0

View file

@ -251,11 +251,7 @@ Methods:
}
case "getpeers":
peers := result.NewGetPeers()
peers.AddUnconnected(s.coreServer.UnconnectedPeers())
peers.AddConnected(s.coreServer.ConnectedPeers())
peers.AddBad(s.coreServer.BadPeers())
results = peers
results, resultsErr = s.getPeers(reqParams)
case "getrawmempool":
results, resultsErr = s.getRawMempool(reqParams)
@ -317,6 +313,14 @@ Methods:
s.WriteResponse(req, w, results)
}
func (s *Server) getPeers(_ request.Params) (interface{}, error) {
peers := result.NewGetPeers()
peers.AddUnconnected(s.coreServer.UnconnectedPeers())
peers.AddConnected(s.coreServer.ConnectedPeers())
peers.AddBad(s.coreServer.BadPeers())
return peers, nil
}
func (s *Server) getRawMempool(_ request.Params) (interface{}, error) {
mp := s.chain.GetMemPool()
hashList := make([]util.Uint256, 0)