From dfb4171e3ccccedad21c22088b5f9998cdbb86e8 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 13 Mar 2020 10:03:01 +0300 Subject: [PATCH] rpc: move getrawmempool RPC to a separate func --- pkg/rpc/server/server.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 3333d5570..27e8ee4e8 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -258,12 +258,7 @@ Methods: results = peers case "getrawmempool": - mp := s.chain.GetMemPool() - hashList := make([]util.Uint256, 0) - for _, item := range mp.GetVerifiedTransactions() { - hashList = append(hashList, item.Tx.Hash()) - } - results = hashList + results, resultsErr = s.getRawMempool(reqParams) case "getstorage": results, resultsErr = s.getStorage(reqParams) @@ -322,6 +317,15 @@ Methods: s.WriteResponse(req, w, results) } +func (s *Server) getRawMempool(_ request.Params) (interface{}, error) { + mp := s.chain.GetMemPool() + hashList := make([]util.Uint256, 0) + for _, item := range mp.GetVerifiedTransactions() { + hashList = append(hashList, item.Tx.Hash()) + } + return hashList, nil +} + func (s *Server) validateAddress(reqParams request.Params) (interface{}, error) { param, ok := reqParams.Value(0) if !ok {