Skip to content

Commit 9f1c547

Browse files
committed
Refactoring: move declarations to rest.h
This facilitates unit testing
1 parent 219d728 commit 9f1c547

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ BITCOIN_CORE_H = \
198198
psbt.h \
199199
random.h \
200200
randomenv.h \
201+
rest.h \
201202
reverse_iterator.h \
202203
rpc/blockchain.h \
203204
rpc/client.h \

src/rest.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#include <rest.h>
7+
68
#include <blockfilter.h>
79
#include <chain.h>
810
#include <chainparams.h>
@@ -27,6 +29,7 @@
2729
#include <version.h>
2830

2931
#include <any>
32+
#include <string>
3033

3134
#include <boost/algorithm/string.hpp>
3235

@@ -40,13 +43,6 @@ using node::ReadBlockFromDisk;
4043
static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once
4144
static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000;
4245

43-
enum class RetFormat {
44-
UNDEF,
45-
BINARY,
46-
HEX,
47-
JSON,
48-
};
49-
5046
static const struct {
5147
RetFormat rf;
5248
const char* name;
@@ -137,7 +133,7 @@ static ChainstateManager* GetChainman(const std::any& context, HTTPRequest* req)
137133
return node_context->chainman.get();
138134
}
139135

140-
static RetFormat ParseDataFormat(std::string& param, const std::string& strReq)
136+
RetFormat ParseDataFormat(std::string& param, const std::string& strReq)
141137
{
142138
const std::string::size_type pos = strReq.rfind('.');
143139
if (pos == std::string::npos)

src/rest.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2015-2022 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_REST_H
6+
#define BITCOIN_REST_H
7+
8+
#include <string>
9+
10+
enum class RetFormat {
11+
UNDEF,
12+
BINARY,
13+
HEX,
14+
JSON,
15+
};
16+
17+
RetFormat ParseDataFormat(std::string& param, const std::string& strReq);
18+
19+
#endif // BITCOIN_REST_H

0 commit comments

Comments
 (0)