From 9f1c54787c81177dd56a31c881a9ad2834a122dc Mon Sep 17 00:00:00 2001 From: stickies-v Date: Thu, 27 Jan 2022 21:20:05 +0000 Subject: Refactoring: move declarations to rest.h This facilitates unit testing --- src/Makefile.am | 1 + src/rest.cpp | 12 ++++-------- src/rest.h | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 src/rest.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 0b177480c8..3189871697 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -198,6 +198,7 @@ BITCOIN_CORE_H = \ psbt.h \ random.h \ randomenv.h \ + rest.h \ reverse_iterator.h \ rpc/blockchain.h \ rpc/client.h \ diff --git a/src/rest.cpp b/src/rest.cpp index 063872b47a..418d4796be 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -3,6 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include + #include #include #include @@ -27,6 +29,7 @@ #include #include +#include #include @@ -40,13 +43,6 @@ using node::ReadBlockFromDisk; static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000; -enum class RetFormat { - UNDEF, - BINARY, - HEX, - JSON, -}; - static const struct { RetFormat rf; const char* name; @@ -137,7 +133,7 @@ static ChainstateManager* GetChainman(const std::any& context, HTTPRequest* req) return node_context->chainman.get(); } -static RetFormat ParseDataFormat(std::string& param, const std::string& strReq) +RetFormat ParseDataFormat(std::string& param, const std::string& strReq) { const std::string::size_type pos = strReq.rfind('.'); if (pos == std::string::npos) diff --git a/src/rest.h b/src/rest.h new file mode 100644 index 0000000000..70fed99879 --- /dev/null +++ b/src/rest.h @@ -0,0 +1,19 @@ +// Copyright (c) 2015-2022 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_REST_H +#define BITCOIN_REST_H + +#include + +enum class RetFormat { + UNDEF, + BINARY, + HEX, + JSON, +}; + +RetFormat ParseDataFormat(std::string& param, const std::string& strReq); + +#endif // BITCOIN_REST_H -- cgit v1.2.3