Skip to content

Commit f885b67

Browse files
committed
refactor: Make rest.cpp dependency on *toJSON in blockchain.cpp explicit
1 parent 8d8f28d commit f885b67

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/rest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "primitives/transaction.h"
1010
#include "validation.h"
1111
#include "httpserver.h"
12+
#include "rpc/blockchain.h"
1213
#include "rpc/server.h"
1314
#include "streams.h"
1415
#include "sync.h"
@@ -55,12 +56,9 @@ struct CCoin {
5556
}
5657
};
5758

58-
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
59-
extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
60-
extern UniValue mempoolInfoToJSON();
61-
extern UniValue mempoolToJSON(bool fVerbose = false);
62-
extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
63-
extern UniValue blockheaderToJSON(const CBlockIndex* blockindex);
59+
/* Defined in rawtransaction.cpp */
60+
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
61+
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
6462

6563
static bool RESTERR(HTTPRequest* req, enum HTTPStatusCode status, std::string message)
6664
{

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
101101
return result;
102102
}
103103

104-
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
104+
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails)
105105
{
106106
UniValue result(UniValue::VOBJ);
107107
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex()));
@@ -378,7 +378,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
378378
info.push_back(Pair("depends", depends));
379379
}
380380

381-
UniValue mempoolToJSON(bool fVerbose = false)
381+
UniValue mempoolToJSON(bool fVerbose)
382382
{
383383
if (fVerbose)
384384
{

src/rpc/blockchain.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
#ifndef BITCOIN_RPC_BLOCKCHAIN_H
66
#define BITCOIN_RPC_BLOCKCHAIN_H
77

8+
class CBlock;
89
class CBlockIndex;
10+
class CScript;
11+
class CTransaction;
12+
class uint256;
13+
class UniValue;
914

1015
/**
1116
* Get the difficulty of the net wrt to the given block index, or the chain tip if
@@ -19,5 +24,17 @@ double GetDifficulty(const CBlockIndex* blockindex = nullptr);
1924
/** Callback for when block tip changed. */
2025
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
2126

27+
/** Block description to JSON */
28+
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
29+
30+
/** Mempool information to JSON */
31+
UniValue mempoolInfoToJSON();
32+
33+
/** Mempool to JSON */
34+
UniValue mempoolToJSON(bool fVerbose = false);
35+
36+
/** Block header to JSON */
37+
UniValue blockheaderToJSON(const CBlockIndex* blockindex);
38+
2239
#endif
2340

0 commit comments

Comments
 (0)