Refactoring: move declarations to rest.h

This facilitates unit testing
This commit is contained in:
stickies-v 2022-01-27 21:20:05 +00:00
parent 219d728fcb
commit 9f1c54787c
No known key found for this signature in database
GPG Key ID: 5CB1CE6E5E66A757
3 changed files with 24 additions and 8 deletions

View File

@ -198,6 +198,7 @@ BITCOIN_CORE_H = \
psbt.h \ psbt.h \
random.h \ random.h \
randomenv.h \ randomenv.h \
rest.h \
reverse_iterator.h \ reverse_iterator.h \
rpc/blockchain.h \ rpc/blockchain.h \
rpc/client.h \ rpc/client.h \

View File

@ -3,6 +3,8 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <rest.h>
#include <blockfilter.h> #include <blockfilter.h>
#include <chain.h> #include <chain.h>
#include <chainparams.h> #include <chainparams.h>
@ -27,6 +29,7 @@
#include <version.h> #include <version.h>
#include <any> #include <any>
#include <string>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -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 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; static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000;
enum class RetFormat {
UNDEF,
BINARY,
HEX,
JSON,
};
static const struct { static const struct {
RetFormat rf; RetFormat rf;
const char* name; const char* name;
@ -137,7 +133,7 @@ static ChainstateManager* GetChainman(const std::any& context, HTTPRequest* req)
return node_context->chainman.get(); 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('.'); const std::string::size_type pos = strReq.rfind('.');
if (pos == std::string::npos) if (pos == std::string::npos)

19
src/rest.h Normal file
View File

@ -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 <string>
enum class RetFormat {
UNDEF,
BINARY,
HEX,
JSON,
};
RetFormat ParseDataFormat(std::string& param, const std::string& strReq);
#endif // BITCOIN_REST_H