mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Merge #10095: refactor: Move GetDifficulty out of rpc/server.h
f885b67
refactor: Make rest.cpp dependency on `*toJSON` in `blockchain.cpp` explicit (Wladimir J. van der Laan)8d8f28d
refactor: Move RPCNotifyBlockChange out of `rpc/server.h` (Wladimir J. van der Laan)e6dcfee
refactor: Move GetDifficulty out of `rpc/server.h` (Wladimir J. van der Laan) Tree-SHA512: fc2656611d18442f2fddba5ac1554d958151f6785c2039afdfc36735d7e71592d9686ff6cc7b2ad95180071d7514470e62c52d697c5a1e88f851bddaf5942edb
This commit is contained in:
commit
4aa07fa735
@ -122,6 +122,7 @@ BITCOIN_CORE_H = \
|
|||||||
protocol.h \
|
protocol.h \
|
||||||
random.h \
|
random.h \
|
||||||
reverselock.h \
|
reverselock.h \
|
||||||
|
rpc/blockchain.h \
|
||||||
rpc/client.h \
|
rpc/client.h \
|
||||||
rpc/protocol.h \
|
rpc/protocol.h \
|
||||||
rpc/server.h \
|
rpc/server.h \
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "policy/policy.h"
|
#include "policy/policy.h"
|
||||||
#include "rpc/server.h"
|
#include "rpc/server.h"
|
||||||
#include "rpc/register.h"
|
#include "rpc/register.h"
|
||||||
|
#include "rpc/blockchain.h"
|
||||||
#include "script/standard.h"
|
#include "script/standard.h"
|
||||||
#include "script/sigcache.h"
|
#include "script/sigcache.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
10
src/rest.cpp
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)
|
||||||
{
|
{
|
||||||
|
@ -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 "rpc/blockchain.h"
|
||||||
|
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
#include "chain.h"
|
#include "chain.h"
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
@ -42,13 +44,6 @@ static CUpdatedBlock latestblock;
|
|||||||
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
|
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
|
||||||
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
|
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the difficulty of the net wrt to the given block index, or the chain tip if
|
|
||||||
* not provided.
|
|
||||||
*
|
|
||||||
* @return A floating point number that is a multiple of the main net minimum
|
|
||||||
* difficulty (4295032833 hashes).
|
|
||||||
*/
|
|
||||||
double GetDifficulty(const CBlockIndex* blockindex)
|
double GetDifficulty(const CBlockIndex* blockindex)
|
||||||
{
|
{
|
||||||
if (blockindex == NULL)
|
if (blockindex == NULL)
|
||||||
@ -106,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()));
|
||||||
@ -383,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)
|
||||||
{
|
{
|
||||||
|
40
src/rpc/blockchain.h
Normal file
40
src/rpc/blockchain.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2017 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_RPC_BLOCKCHAIN_H
|
||||||
|
#define BITCOIN_RPC_BLOCKCHAIN_H
|
||||||
|
|
||||||
|
class CBlock;
|
||||||
|
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
|
||||||
|
* not provided.
|
||||||
|
*
|
||||||
|
* @return A floating point number that is a multiple of the main net minimum
|
||||||
|
* difficulty (4295032833 hashes).
|
||||||
|
*/
|
||||||
|
double GetDifficulty(const CBlockIndex* blockindex = nullptr);
|
||||||
|
|
||||||
|
/** Callback for when block tip changed. */
|
||||||
|
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
|
||||||
|
|
@ -16,6 +16,7 @@
|
|||||||
#include "miner.h"
|
#include "miner.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "pow.h"
|
#include "pow.h"
|
||||||
|
#include "rpc/blockchain.h"
|
||||||
#include "rpc/server.h"
|
#include "rpc/server.h"
|
||||||
#include "txmempool.h"
|
#include "txmempool.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "validation.h"
|
#include "validation.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "netbase.h"
|
#include "netbase.h"
|
||||||
|
#include "rpc/blockchain.h"
|
||||||
#include "rpc/server.h"
|
#include "rpc/server.h"
|
||||||
#include "timedata.h"
|
#include "timedata.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -191,7 +191,6 @@ extern std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKe
|
|||||||
|
|
||||||
extern CAmount AmountFromValue(const UniValue& value);
|
extern CAmount AmountFromValue(const UniValue& value);
|
||||||
extern UniValue ValueFromAmount(const CAmount& amount);
|
extern UniValue ValueFromAmount(const CAmount& amount);
|
||||||
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
|
|
||||||
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
||||||
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
||||||
|
|
||||||
@ -199,7 +198,6 @@ bool StartRPC();
|
|||||||
void InterruptRPC();
|
void InterruptRPC();
|
||||||
void StopRPC();
|
void StopRPC();
|
||||||
std::string JSONRPCExecBatch(const UniValue& vReq);
|
std::string JSONRPCExecBatch(const UniValue& vReq);
|
||||||
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
|
|
||||||
|
|
||||||
// Retrieves any serialization flags requested in command line argument
|
// Retrieves any serialization flags requested in command line argument
|
||||||
int RPCSerializationFlags();
|
int RPCSerializationFlags();
|
||||||
|
Loading…
Reference in New Issue
Block a user