Browse Source

refactor: Make rest.cpp dependency on `*toJSON` in `blockchain.cpp` explicit

0.15
Wladimir J. van der Laan 8 years ago
parent
commit
f885b67029
  1. 10
      src/rest.cpp
  2. 4
      src/rpc/blockchain.cpp
  3. 17
      src/rpc/blockchain.h

10
src/rest.cpp

@ -9,6 +9,7 @@
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "validation.h" #include "validation.h"
#include "httpserver.h" #include "httpserver.h"
#include "rpc/blockchain.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "streams.h" #include "streams.h"
#include "sync.h" #include "sync.h"
@ -55,12 +56,9 @@ struct CCoin {
} }
}; };
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); /* Defined in rawtransaction.cpp */
extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false); void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
extern UniValue mempoolInfoToJSON(); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
extern UniValue mempoolToJSON(bool fVerbose = false);
extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
extern UniValue blockheaderToJSON(const CBlockIndex* blockindex);
static bool RESTERR(HTTPRequest* req, enum HTTPStatusCode status, std::string message) static bool RESTERR(HTTPRequest* req, enum HTTPStatusCode status, std::string message)
{ {

4
src/rpc/blockchain.cpp

@ -101,7 +101,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
return result; return result;
} }
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails)
{ {
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex()));
@ -378,7 +378,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
info.push_back(Pair("depends", depends)); info.push_back(Pair("depends", depends));
} }
UniValue mempoolToJSON(bool fVerbose = false) UniValue mempoolToJSON(bool fVerbose)
{ {
if (fVerbose) if (fVerbose)
{ {

17
src/rpc/blockchain.h

@ -5,7 +5,12 @@
#ifndef BITCOIN_RPC_BLOCKCHAIN_H #ifndef BITCOIN_RPC_BLOCKCHAIN_H
#define BITCOIN_RPC_BLOCKCHAIN_H #define BITCOIN_RPC_BLOCKCHAIN_H
class CBlock;
class CBlockIndex; class CBlockIndex;
class CScript;
class CTransaction;
class uint256;
class UniValue;
/** /**
* Get the difficulty of the net wrt to the given block index, or the chain tip if * 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);
/** Callback for when block tip changed. */ /** Callback for when block tip changed. */
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *); void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
/** Block description to JSON */
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
/** Mempool information to JSON */
UniValue mempoolInfoToJSON();
/** Mempool to JSON */
UniValue mempoolToJSON(bool fVerbose = false);
/** Block header to JSON */
UniValue blockheaderToJSON(const CBlockIndex* blockindex);
#endif #endif

Loading…
Cancel
Save